Merge "Stop camera enumeration after finding first camera"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 51de802..d435731 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -203,10 +203,6 @@
             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>
@@ -1487,7 +1483,6 @@
         <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" />
@@ -2620,23 +2615,6 @@
         <activity android:name=".notification.NotificationAccessConfirmationActivity"
                   android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert" />
 
-        <receiver android:name=".widget.SettingsAppWidgetProvider"
-                android:label="@string/gadget_title"
-                android:exported="false"
-                android:enabled="@bool/has_powercontrol_widget">
-            <intent-filter>
-                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
-                <action android:name="android.appwidget.action.APPWIDGET_ENABLED" />
-                <action android:name="android.appwidget.action.APPWIDGET_DISABLED" />
-                <action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
-                <action android:name="android.net.conn.BACKGROUND_DATA_SETTING_CHANGED" />
-                <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
-                <action android:name="android.location.MODE_CHANGED" />
-                <action android:name="com.android.sync.SYNC_CONN_STATUS_CHANGED" />
-            </intent-filter>
-            <meta-data android:name="android.appwidget.provider" android:resource="@xml/appwidget_info" />
-        </receiver>
-
         <receiver android:name="com.android.settingslib.bluetooth.BluetoothDiscoverableTimeoutReceiver">
             <intent-filter>
                 <action android:name="android.bluetooth.intent.DISCOVERABLE_TIMEOUT" />
@@ -3120,6 +3098,10 @@
                   android:taskAffinity="com.android.settings"
                   android:parentActivityName="Settings$ConnectedDeviceDashboardActivity">
             <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="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
@@ -3182,6 +3164,12 @@
         <service android:name=".fuelgauge.batterytip.AnomalyDetectionJobService"
                  android:permission="android.permission.BIND_JOB_SERVICE" />
 
+        <provider
+            android:name=".homepage.CardContentProvider"
+            android:authorities="com.android.settings.homepage.CardContentProvider"
+            android:exported="true"
+            android:permission="android.permission.WRITE_SETTINGS_HOMEPAGE_DATA" />
+
         <!-- This is the longest AndroidManifest.xml ever. -->
     </application>
 </manifest>
diff --git a/res/drawable-hdpi/appwidget_bg_holo.9.png b/res/drawable-hdpi/appwidget_bg_holo.9.png
deleted file mode 100644
index 9dc01d7..0000000
--- a/res/drawable-hdpi/appwidget_bg_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_inner_focused_c_holo.9.png b/res/drawable-hdpi/appwidget_inner_focused_c_holo.9.png
deleted file mode 100644
index 47f7af0..0000000
--- a/res/drawable-hdpi/appwidget_inner_focused_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_inner_focused_l_holo.9.png b/res/drawable-hdpi/appwidget_inner_focused_l_holo.9.png
deleted file mode 100644
index 4eae69c..0000000
--- a/res/drawable-hdpi/appwidget_inner_focused_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_inner_focused_r_holo.9.png b/res/drawable-hdpi/appwidget_inner_focused_r_holo.9.png
deleted file mode 100644
index 598ae03..0000000
--- a/res/drawable-hdpi/appwidget_inner_focused_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_inner_pressed_c_holo.9.png b/res/drawable-hdpi/appwidget_inner_pressed_c_holo.9.png
deleted file mode 100644
index 056ee4a..0000000
--- a/res/drawable-hdpi/appwidget_inner_pressed_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_inner_pressed_l_holo.9.png b/res/drawable-hdpi/appwidget_inner_pressed_l_holo.9.png
deleted file mode 100644
index 2cb3a54..0000000
--- a/res/drawable-hdpi/appwidget_inner_pressed_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_inner_pressed_r_holo.9.png b/res/drawable-hdpi/appwidget_inner_pressed_r_holo.9.png
deleted file mode 100644
index 034b994..0000000
--- a/res/drawable-hdpi/appwidget_inner_pressed_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_settings_divider_holo.9.png b/res/drawable-hdpi/appwidget_settings_divider_holo.9.png
deleted file mode 100644
index cfe0f3b..0000000
--- a/res/drawable-hdpi/appwidget_settings_divider_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_settings_ind_mid_c_holo.9.png b/res/drawable-hdpi/appwidget_settings_ind_mid_c_holo.9.png
deleted file mode 100644
index 60c0da4..0000000
--- a/res/drawable-hdpi/appwidget_settings_ind_mid_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_settings_ind_mid_l_holo.9.png b/res/drawable-hdpi/appwidget_settings_ind_mid_l_holo.9.png
deleted file mode 100644
index 7cedcd5..0000000
--- a/res/drawable-hdpi/appwidget_settings_ind_mid_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_settings_ind_mid_r_holo.9.png b/res/drawable-hdpi/appwidget_settings_ind_mid_r_holo.9.png
deleted file mode 100644
index 19f08b4..0000000
--- a/res/drawable-hdpi/appwidget_settings_ind_mid_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_settings_ind_off_c_holo.9.png b/res/drawable-hdpi/appwidget_settings_ind_off_c_holo.9.png
deleted file mode 100644
index d4d4688..0000000
--- a/res/drawable-hdpi/appwidget_settings_ind_off_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_settings_ind_off_l_holo.9.png b/res/drawable-hdpi/appwidget_settings_ind_off_l_holo.9.png
deleted file mode 100644
index d06dc98..0000000
--- a/res/drawable-hdpi/appwidget_settings_ind_off_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_settings_ind_off_r_holo.9.png b/res/drawable-hdpi/appwidget_settings_ind_off_r_holo.9.png
deleted file mode 100644
index d287c8e..0000000
--- a/res/drawable-hdpi/appwidget_settings_ind_off_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_settings_ind_on_c_holo.9.png b/res/drawable-hdpi/appwidget_settings_ind_on_c_holo.9.png
deleted file mode 100644
index d37af4e..0000000
--- a/res/drawable-hdpi/appwidget_settings_ind_on_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_settings_ind_on_l_holo.9.png b/res/drawable-hdpi/appwidget_settings_ind_on_l_holo.9.png
deleted file mode 100644
index 60dac8b..0000000
--- a/res/drawable-hdpi/appwidget_settings_ind_on_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_settings_ind_on_r_holo.9.png b/res/drawable-hdpi/appwidget_settings_ind_on_r_holo.9.png
deleted file mode 100644
index d68a538..0000000
--- a/res/drawable-hdpi/appwidget_settings_ind_on_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_appwidget_settings_bluetooth_off_holo.png b/res/drawable-hdpi/ic_appwidget_settings_bluetooth_off_holo.png
deleted file mode 100644
index 1dd1a931..0000000
--- a/res/drawable-hdpi/ic_appwidget_settings_bluetooth_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_appwidget_settings_bluetooth_on_holo.png b/res/drawable-hdpi/ic_appwidget_settings_bluetooth_on_holo.png
deleted file mode 100644
index 86d5fa0..0000000
--- a/res/drawable-hdpi/ic_appwidget_settings_bluetooth_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_appwidget_settings_brightness_auto_holo.png b/res/drawable-hdpi/ic_appwidget_settings_brightness_auto_holo.png
deleted file mode 100644
index 5f4a87a..0000000
--- a/res/drawable-hdpi/ic_appwidget_settings_brightness_auto_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_appwidget_settings_brightness_full_holo.png b/res/drawable-hdpi/ic_appwidget_settings_brightness_full_holo.png
deleted file mode 100644
index abbe883..0000000
--- a/res/drawable-hdpi/ic_appwidget_settings_brightness_full_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_appwidget_settings_brightness_half_holo.png b/res/drawable-hdpi/ic_appwidget_settings_brightness_half_holo.png
deleted file mode 100644
index 6217e55..0000000
--- a/res/drawable-hdpi/ic_appwidget_settings_brightness_half_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_appwidget_settings_brightness_off_holo.png b/res/drawable-hdpi/ic_appwidget_settings_brightness_off_holo.png
deleted file mode 100644
index 877454d..0000000
--- a/res/drawable-hdpi/ic_appwidget_settings_brightness_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_appwidget_settings_location_off_holo.png b/res/drawable-hdpi/ic_appwidget_settings_location_off_holo.png
deleted file mode 100644
index 58fd997..0000000
--- a/res/drawable-hdpi/ic_appwidget_settings_location_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_appwidget_settings_location_on_holo.png b/res/drawable-hdpi/ic_appwidget_settings_location_on_holo.png
deleted file mode 100644
index b1ce371..0000000
--- a/res/drawable-hdpi/ic_appwidget_settings_location_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_appwidget_settings_location_saving_holo.png b/res/drawable-hdpi/ic_appwidget_settings_location_saving_holo.png
deleted file mode 100644
index e1fe786..0000000
--- a/res/drawable-hdpi/ic_appwidget_settings_location_saving_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_appwidget_settings_sync_off_holo.png b/res/drawable-hdpi/ic_appwidget_settings_sync_off_holo.png
deleted file mode 100644
index c31ef00..0000000
--- a/res/drawable-hdpi/ic_appwidget_settings_sync_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_appwidget_settings_sync_on_holo.png b/res/drawable-hdpi/ic_appwidget_settings_sync_on_holo.png
deleted file mode 100644
index 2f47235..0000000
--- a/res/drawable-hdpi/ic_appwidget_settings_sync_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_appwidget_settings_wifi_off_holo.png b/res/drawable-hdpi/ic_appwidget_settings_wifi_off_holo.png
deleted file mode 100644
index aa6cf26..0000000
--- a/res/drawable-hdpi/ic_appwidget_settings_wifi_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_appwidget_settings_wifi_on_holo.png b/res/drawable-hdpi/ic_appwidget_settings_wifi_on_holo.png
deleted file mode 100644
index 64c3992..0000000
--- a/res/drawable-hdpi/ic_appwidget_settings_wifi_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-hdpi/ic_appwidget_settings_brightness_half_holo.png b/res/drawable-ldrtl-hdpi/ic_appwidget_settings_brightness_half_holo.png
deleted file mode 100644
index 9d8b24a..0000000
--- a/res/drawable-ldrtl-hdpi/ic_appwidget_settings_brightness_half_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-mdpi/ic_appwidget_settings_brightness_half_holo.png b/res/drawable-ldrtl-mdpi/ic_appwidget_settings_brightness_half_holo.png
deleted file mode 100644
index 90941e4..0000000
--- a/res/drawable-ldrtl-mdpi/ic_appwidget_settings_brightness_half_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-xhdpi/ic_appwidget_settings_brightness_half_holo.png b/res/drawable-ldrtl-xhdpi/ic_appwidget_settings_brightness_half_holo.png
deleted file mode 100644
index b06324e..0000000
--- a/res/drawable-ldrtl-xhdpi/ic_appwidget_settings_brightness_half_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_bg_holo.9.png b/res/drawable-mdpi/appwidget_bg_holo.9.png
deleted file mode 100644
index cdfa203..0000000
--- a/res/drawable-mdpi/appwidget_bg_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_inner_focused_c_holo.9.png b/res/drawable-mdpi/appwidget_inner_focused_c_holo.9.png
deleted file mode 100644
index 45332bd..0000000
--- a/res/drawable-mdpi/appwidget_inner_focused_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_inner_focused_l_holo.9.png b/res/drawable-mdpi/appwidget_inner_focused_l_holo.9.png
deleted file mode 100644
index 36605a6..0000000
--- a/res/drawable-mdpi/appwidget_inner_focused_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_inner_focused_r_holo.9.png b/res/drawable-mdpi/appwidget_inner_focused_r_holo.9.png
deleted file mode 100644
index 70fd6bd..0000000
--- a/res/drawable-mdpi/appwidget_inner_focused_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_inner_pressed_c_holo.9.png b/res/drawable-mdpi/appwidget_inner_pressed_c_holo.9.png
deleted file mode 100644
index b717279..0000000
--- a/res/drawable-mdpi/appwidget_inner_pressed_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_inner_pressed_l_holo.9.png b/res/drawable-mdpi/appwidget_inner_pressed_l_holo.9.png
deleted file mode 100644
index 45a0175..0000000
--- a/res/drawable-mdpi/appwidget_inner_pressed_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_inner_pressed_r_holo.9.png b/res/drawable-mdpi/appwidget_inner_pressed_r_holo.9.png
deleted file mode 100644
index f06d3c3..0000000
--- a/res/drawable-mdpi/appwidget_inner_pressed_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_settings_divider_holo.9.png b/res/drawable-mdpi/appwidget_settings_divider_holo.9.png
deleted file mode 100644
index 27e35a3..0000000
--- a/res/drawable-mdpi/appwidget_settings_divider_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_settings_ind_mid_c_holo.9.png b/res/drawable-mdpi/appwidget_settings_ind_mid_c_holo.9.png
deleted file mode 100644
index 22aedaa..0000000
--- a/res/drawable-mdpi/appwidget_settings_ind_mid_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_settings_ind_mid_l_holo.9.png b/res/drawable-mdpi/appwidget_settings_ind_mid_l_holo.9.png
deleted file mode 100644
index f71c3c3..0000000
--- a/res/drawable-mdpi/appwidget_settings_ind_mid_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_settings_ind_mid_r_holo.9.png b/res/drawable-mdpi/appwidget_settings_ind_mid_r_holo.9.png
deleted file mode 100644
index 3621791..0000000
--- a/res/drawable-mdpi/appwidget_settings_ind_mid_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_settings_ind_off_c_holo.9.png b/res/drawable-mdpi/appwidget_settings_ind_off_c_holo.9.png
deleted file mode 100644
index 80b3d3c..0000000
--- a/res/drawable-mdpi/appwidget_settings_ind_off_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_settings_ind_off_l_holo.9.png b/res/drawable-mdpi/appwidget_settings_ind_off_l_holo.9.png
deleted file mode 100644
index 30c05d9..0000000
--- a/res/drawable-mdpi/appwidget_settings_ind_off_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_settings_ind_off_r_holo.9.png b/res/drawable-mdpi/appwidget_settings_ind_off_r_holo.9.png
deleted file mode 100644
index 7253365..0000000
--- a/res/drawable-mdpi/appwidget_settings_ind_off_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_settings_ind_on_c_holo.9.png b/res/drawable-mdpi/appwidget_settings_ind_on_c_holo.9.png
deleted file mode 100644
index c9d9f7e..0000000
--- a/res/drawable-mdpi/appwidget_settings_ind_on_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_settings_ind_on_l_holo.9.png b/res/drawable-mdpi/appwidget_settings_ind_on_l_holo.9.png
deleted file mode 100644
index 5c0a157..0000000
--- a/res/drawable-mdpi/appwidget_settings_ind_on_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_settings_ind_on_r_holo.9.png b/res/drawable-mdpi/appwidget_settings_ind_on_r_holo.9.png
deleted file mode 100644
index 48bf90d..0000000
--- a/res/drawable-mdpi/appwidget_settings_ind_on_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_appwidget_settings_bluetooth_off_holo.png b/res/drawable-mdpi/ic_appwidget_settings_bluetooth_off_holo.png
deleted file mode 100644
index 8f30b90..0000000
--- a/res/drawable-mdpi/ic_appwidget_settings_bluetooth_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_appwidget_settings_bluetooth_on_holo.png b/res/drawable-mdpi/ic_appwidget_settings_bluetooth_on_holo.png
deleted file mode 100644
index f921eb9..0000000
--- a/res/drawable-mdpi/ic_appwidget_settings_bluetooth_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_appwidget_settings_brightness_auto_holo.png b/res/drawable-mdpi/ic_appwidget_settings_brightness_auto_holo.png
deleted file mode 100644
index b726c17..0000000
--- a/res/drawable-mdpi/ic_appwidget_settings_brightness_auto_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_appwidget_settings_brightness_full_holo.png b/res/drawable-mdpi/ic_appwidget_settings_brightness_full_holo.png
deleted file mode 100644
index 82b0101..0000000
--- a/res/drawable-mdpi/ic_appwidget_settings_brightness_full_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_appwidget_settings_brightness_half_holo.png b/res/drawable-mdpi/ic_appwidget_settings_brightness_half_holo.png
deleted file mode 100644
index ad6f15e..0000000
--- a/res/drawable-mdpi/ic_appwidget_settings_brightness_half_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_appwidget_settings_brightness_off_holo.png b/res/drawable-mdpi/ic_appwidget_settings_brightness_off_holo.png
deleted file mode 100644
index 20a6fcf..0000000
--- a/res/drawable-mdpi/ic_appwidget_settings_brightness_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_appwidget_settings_location_off_holo.png b/res/drawable-mdpi/ic_appwidget_settings_location_off_holo.png
deleted file mode 100644
index 15bb918..0000000
--- a/res/drawable-mdpi/ic_appwidget_settings_location_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_appwidget_settings_location_on_holo.png b/res/drawable-mdpi/ic_appwidget_settings_location_on_holo.png
deleted file mode 100644
index a7bca04..0000000
--- a/res/drawable-mdpi/ic_appwidget_settings_location_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_appwidget_settings_location_saving_holo.png b/res/drawable-mdpi/ic_appwidget_settings_location_saving_holo.png
deleted file mode 100644
index dec6059..0000000
--- a/res/drawable-mdpi/ic_appwidget_settings_location_saving_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_appwidget_settings_sync_off_holo.png b/res/drawable-mdpi/ic_appwidget_settings_sync_off_holo.png
deleted file mode 100644
index 4fe5573..0000000
--- a/res/drawable-mdpi/ic_appwidget_settings_sync_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_appwidget_settings_sync_on_holo.png b/res/drawable-mdpi/ic_appwidget_settings_sync_on_holo.png
deleted file mode 100644
index fa37c63..0000000
--- a/res/drawable-mdpi/ic_appwidget_settings_sync_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_appwidget_settings_wifi_off_holo.png b/res/drawable-mdpi/ic_appwidget_settings_wifi_off_holo.png
deleted file mode 100644
index b10cd36..0000000
--- a/res/drawable-mdpi/ic_appwidget_settings_wifi_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_appwidget_settings_wifi_on_holo.png b/res/drawable-mdpi/ic_appwidget_settings_wifi_on_holo.png
deleted file mode 100644
index 7a56cf2..0000000
--- a/res/drawable-mdpi/ic_appwidget_settings_wifi_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-nodpi/preview.png b/res/drawable-nodpi/preview.png
deleted file mode 100644
index 0ffb700..0000000
--- a/res/drawable-nodpi/preview.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_bg_holo.9.png b/res/drawable-xhdpi/appwidget_bg_holo.9.png
deleted file mode 100644
index 454e84a..0000000
--- a/res/drawable-xhdpi/appwidget_bg_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_inner_focused_c_holo.9.png b/res/drawable-xhdpi/appwidget_inner_focused_c_holo.9.png
deleted file mode 100644
index 5aafacd..0000000
--- a/res/drawable-xhdpi/appwidget_inner_focused_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_inner_focused_l_holo.9.png b/res/drawable-xhdpi/appwidget_inner_focused_l_holo.9.png
deleted file mode 100644
index 3161a7a..0000000
--- a/res/drawable-xhdpi/appwidget_inner_focused_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_inner_focused_r_holo.9.png b/res/drawable-xhdpi/appwidget_inner_focused_r_holo.9.png
deleted file mode 100644
index 5e7968a..0000000
--- a/res/drawable-xhdpi/appwidget_inner_focused_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_inner_pressed_c_holo.9.png b/res/drawable-xhdpi/appwidget_inner_pressed_c_holo.9.png
deleted file mode 100644
index de40bd0..0000000
--- a/res/drawable-xhdpi/appwidget_inner_pressed_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_inner_pressed_l_holo.9.png b/res/drawable-xhdpi/appwidget_inner_pressed_l_holo.9.png
deleted file mode 100644
index 1802d9a..0000000
--- a/res/drawable-xhdpi/appwidget_inner_pressed_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_inner_pressed_r_holo.9.png b/res/drawable-xhdpi/appwidget_inner_pressed_r_holo.9.png
deleted file mode 100644
index d5971c2..0000000
--- a/res/drawable-xhdpi/appwidget_inner_pressed_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_settings_divider_holo.9.png b/res/drawable-xhdpi/appwidget_settings_divider_holo.9.png
deleted file mode 100644
index 940c1ed..0000000
--- a/res/drawable-xhdpi/appwidget_settings_divider_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_settings_ind_mid_c_holo.9.png b/res/drawable-xhdpi/appwidget_settings_ind_mid_c_holo.9.png
deleted file mode 100644
index 12fbb33..0000000
--- a/res/drawable-xhdpi/appwidget_settings_ind_mid_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_settings_ind_mid_l_holo.9.png b/res/drawable-xhdpi/appwidget_settings_ind_mid_l_holo.9.png
deleted file mode 100644
index 76677ee..0000000
--- a/res/drawable-xhdpi/appwidget_settings_ind_mid_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_settings_ind_mid_r_holo.9.png b/res/drawable-xhdpi/appwidget_settings_ind_mid_r_holo.9.png
deleted file mode 100644
index 3a32944..0000000
--- a/res/drawable-xhdpi/appwidget_settings_ind_mid_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_settings_ind_off_c_holo.9.png b/res/drawable-xhdpi/appwidget_settings_ind_off_c_holo.9.png
deleted file mode 100644
index ed8f93e..0000000
--- a/res/drawable-xhdpi/appwidget_settings_ind_off_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_settings_ind_off_l_holo.9.png b/res/drawable-xhdpi/appwidget_settings_ind_off_l_holo.9.png
deleted file mode 100644
index 706af0b..0000000
--- a/res/drawable-xhdpi/appwidget_settings_ind_off_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_settings_ind_off_r_holo.9.png b/res/drawable-xhdpi/appwidget_settings_ind_off_r_holo.9.png
deleted file mode 100644
index 5f24769..0000000
--- a/res/drawable-xhdpi/appwidget_settings_ind_off_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_settings_ind_on_c_holo.9.png b/res/drawable-xhdpi/appwidget_settings_ind_on_c_holo.9.png
deleted file mode 100644
index 94f1068..0000000
--- a/res/drawable-xhdpi/appwidget_settings_ind_on_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_settings_ind_on_l_holo.9.png b/res/drawable-xhdpi/appwidget_settings_ind_on_l_holo.9.png
deleted file mode 100644
index e9b5749..0000000
--- a/res/drawable-xhdpi/appwidget_settings_ind_on_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_settings_ind_on_r_holo.9.png b/res/drawable-xhdpi/appwidget_settings_ind_on_r_holo.9.png
deleted file mode 100644
index be6b9ff..0000000
--- a/res/drawable-xhdpi/appwidget_settings_ind_on_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_appwidget_settings_bluetooth_off_holo.png b/res/drawable-xhdpi/ic_appwidget_settings_bluetooth_off_holo.png
deleted file mode 100644
index 4c1fa33..0000000
--- a/res/drawable-xhdpi/ic_appwidget_settings_bluetooth_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_appwidget_settings_bluetooth_on_holo.png b/res/drawable-xhdpi/ic_appwidget_settings_bluetooth_on_holo.png
deleted file mode 100644
index 7e2ac3a..0000000
--- a/res/drawable-xhdpi/ic_appwidget_settings_bluetooth_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_appwidget_settings_brightness_auto_holo.png b/res/drawable-xhdpi/ic_appwidget_settings_brightness_auto_holo.png
deleted file mode 100644
index eab788f..0000000
--- a/res/drawable-xhdpi/ic_appwidget_settings_brightness_auto_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_appwidget_settings_brightness_full_holo.png b/res/drawable-xhdpi/ic_appwidget_settings_brightness_full_holo.png
deleted file mode 100644
index 9b60097..0000000
--- a/res/drawable-xhdpi/ic_appwidget_settings_brightness_full_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_appwidget_settings_brightness_half_holo.png b/res/drawable-xhdpi/ic_appwidget_settings_brightness_half_holo.png
deleted file mode 100644
index 39f069b..0000000
--- a/res/drawable-xhdpi/ic_appwidget_settings_brightness_half_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_appwidget_settings_brightness_off_holo.png b/res/drawable-xhdpi/ic_appwidget_settings_brightness_off_holo.png
deleted file mode 100644
index a941265..0000000
--- a/res/drawable-xhdpi/ic_appwidget_settings_brightness_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_appwidget_settings_location_off_holo.png b/res/drawable-xhdpi/ic_appwidget_settings_location_off_holo.png
deleted file mode 100644
index e1a600c..0000000
--- a/res/drawable-xhdpi/ic_appwidget_settings_location_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_appwidget_settings_location_on_holo.png b/res/drawable-xhdpi/ic_appwidget_settings_location_on_holo.png
deleted file mode 100644
index 982573a..0000000
--- a/res/drawable-xhdpi/ic_appwidget_settings_location_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_appwidget_settings_location_saving_holo.png b/res/drawable-xhdpi/ic_appwidget_settings_location_saving_holo.png
deleted file mode 100644
index c62edce..0000000
--- a/res/drawable-xhdpi/ic_appwidget_settings_location_saving_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_appwidget_settings_sync_off_holo.png b/res/drawable-xhdpi/ic_appwidget_settings_sync_off_holo.png
deleted file mode 100644
index 18c7d3a..0000000
--- a/res/drawable-xhdpi/ic_appwidget_settings_sync_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_appwidget_settings_sync_on_holo.png b/res/drawable-xhdpi/ic_appwidget_settings_sync_on_holo.png
deleted file mode 100644
index c9f3878..0000000
--- a/res/drawable-xhdpi/ic_appwidget_settings_sync_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_appwidget_settings_wifi_off_holo.png b/res/drawable-xhdpi/ic_appwidget_settings_wifi_off_holo.png
deleted file mode 100644
index ab7bc0a..0000000
--- a/res/drawable-xhdpi/ic_appwidget_settings_wifi_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_appwidget_settings_wifi_on_holo.png b/res/drawable-xhdpi/ic_appwidget_settings_wifi_on_holo.png
deleted file mode 100644
index 596ce06..0000000
--- a/res/drawable-xhdpi/ic_appwidget_settings_wifi_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_bg_holo.9.png b/res/drawable-xxhdpi/appwidget_bg_holo.9.png
deleted file mode 100644
index 3fb2598..0000000
--- a/res/drawable-xxhdpi/appwidget_bg_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_inner_focused_c_holo.9.png b/res/drawable-xxhdpi/appwidget_inner_focused_c_holo.9.png
deleted file mode 100644
index 7f64682..0000000
--- a/res/drawable-xxhdpi/appwidget_inner_focused_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_inner_focused_l_holo.9.png b/res/drawable-xxhdpi/appwidget_inner_focused_l_holo.9.png
deleted file mode 100644
index 0606b4d..0000000
--- a/res/drawable-xxhdpi/appwidget_inner_focused_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_inner_focused_r_holo.9.png b/res/drawable-xxhdpi/appwidget_inner_focused_r_holo.9.png
deleted file mode 100644
index cb27941..0000000
--- a/res/drawable-xxhdpi/appwidget_inner_focused_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_inner_pressed_c_holo.9.png b/res/drawable-xxhdpi/appwidget_inner_pressed_c_holo.9.png
deleted file mode 100644
index 7b37e25..0000000
--- a/res/drawable-xxhdpi/appwidget_inner_pressed_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_inner_pressed_l_holo.9.png b/res/drawable-xxhdpi/appwidget_inner_pressed_l_holo.9.png
deleted file mode 100644
index ab37d2d..0000000
--- a/res/drawable-xxhdpi/appwidget_inner_pressed_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_inner_pressed_r_holo.9.png b/res/drawable-xxhdpi/appwidget_inner_pressed_r_holo.9.png
deleted file mode 100644
index 820d2b0..0000000
--- a/res/drawable-xxhdpi/appwidget_inner_pressed_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_settings_divider_holo.9.png b/res/drawable-xxhdpi/appwidget_settings_divider_holo.9.png
deleted file mode 100644
index 0b46314..0000000
--- a/res/drawable-xxhdpi/appwidget_settings_divider_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_settings_ind_mid_c_holo.9.png b/res/drawable-xxhdpi/appwidget_settings_ind_mid_c_holo.9.png
deleted file mode 100644
index a55d364..0000000
--- a/res/drawable-xxhdpi/appwidget_settings_ind_mid_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_settings_ind_mid_l_holo.9.png b/res/drawable-xxhdpi/appwidget_settings_ind_mid_l_holo.9.png
deleted file mode 100644
index e7d8c3b..0000000
--- a/res/drawable-xxhdpi/appwidget_settings_ind_mid_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_settings_ind_mid_r_holo.9.png b/res/drawable-xxhdpi/appwidget_settings_ind_mid_r_holo.9.png
deleted file mode 100644
index cabc30a..0000000
--- a/res/drawable-xxhdpi/appwidget_settings_ind_mid_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_settings_ind_off_c_holo.9.png b/res/drawable-xxhdpi/appwidget_settings_ind_off_c_holo.9.png
deleted file mode 100644
index a6a0e30..0000000
--- a/res/drawable-xxhdpi/appwidget_settings_ind_off_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_settings_ind_off_l_holo.9.png b/res/drawable-xxhdpi/appwidget_settings_ind_off_l_holo.9.png
deleted file mode 100644
index 8a20e01..0000000
--- a/res/drawable-xxhdpi/appwidget_settings_ind_off_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_settings_ind_off_r_holo.9.png b/res/drawable-xxhdpi/appwidget_settings_ind_off_r_holo.9.png
deleted file mode 100644
index 2388b27..0000000
--- a/res/drawable-xxhdpi/appwidget_settings_ind_off_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_settings_ind_on_c_holo.9.png b/res/drawable-xxhdpi/appwidget_settings_ind_on_c_holo.9.png
deleted file mode 100644
index 3663f0a..0000000
--- a/res/drawable-xxhdpi/appwidget_settings_ind_on_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_settings_ind_on_l_holo.9.png b/res/drawable-xxhdpi/appwidget_settings_ind_on_l_holo.9.png
deleted file mode 100644
index 745f198..0000000
--- a/res/drawable-xxhdpi/appwidget_settings_ind_on_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_settings_ind_on_r_holo.9.png b/res/drawable-xxhdpi/appwidget_settings_ind_on_r_holo.9.png
deleted file mode 100644
index 5b2c64e..0000000
--- a/res/drawable-xxhdpi/appwidget_settings_ind_on_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_appwidget_settings_bluetooth_off_holo.png b/res/drawable-xxhdpi/ic_appwidget_settings_bluetooth_off_holo.png
deleted file mode 100644
index e77786f..0000000
--- a/res/drawable-xxhdpi/ic_appwidget_settings_bluetooth_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_appwidget_settings_bluetooth_on_holo.png b/res/drawable-xxhdpi/ic_appwidget_settings_bluetooth_on_holo.png
deleted file mode 100644
index e56ed35..0000000
--- a/res/drawable-xxhdpi/ic_appwidget_settings_bluetooth_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_appwidget_settings_brightness_auto_holo.png b/res/drawable-xxhdpi/ic_appwidget_settings_brightness_auto_holo.png
deleted file mode 100644
index 9cce06f..0000000
--- a/res/drawable-xxhdpi/ic_appwidget_settings_brightness_auto_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_appwidget_settings_brightness_full_holo.png b/res/drawable-xxhdpi/ic_appwidget_settings_brightness_full_holo.png
deleted file mode 100644
index 0a709a9..0000000
--- a/res/drawable-xxhdpi/ic_appwidget_settings_brightness_full_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_appwidget_settings_brightness_half_holo.png b/res/drawable-xxhdpi/ic_appwidget_settings_brightness_half_holo.png
deleted file mode 100644
index ddd8108..0000000
--- a/res/drawable-xxhdpi/ic_appwidget_settings_brightness_half_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_appwidget_settings_brightness_off_holo.png b/res/drawable-xxhdpi/ic_appwidget_settings_brightness_off_holo.png
deleted file mode 100644
index 02ed6e7..0000000
--- a/res/drawable-xxhdpi/ic_appwidget_settings_brightness_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_appwidget_settings_location_off_holo.png b/res/drawable-xxhdpi/ic_appwidget_settings_location_off_holo.png
deleted file mode 100644
index ce1797c..0000000
--- a/res/drawable-xxhdpi/ic_appwidget_settings_location_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_appwidget_settings_location_on_holo.png b/res/drawable-xxhdpi/ic_appwidget_settings_location_on_holo.png
deleted file mode 100644
index ab45286..0000000
--- a/res/drawable-xxhdpi/ic_appwidget_settings_location_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_appwidget_settings_location_saving_holo.png b/res/drawable-xxhdpi/ic_appwidget_settings_location_saving_holo.png
deleted file mode 100644
index 6268610..0000000
--- a/res/drawable-xxhdpi/ic_appwidget_settings_location_saving_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_appwidget_settings_sync_off_holo.png b/res/drawable-xxhdpi/ic_appwidget_settings_sync_off_holo.png
deleted file mode 100644
index 88e0871..0000000
--- a/res/drawable-xxhdpi/ic_appwidget_settings_sync_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_appwidget_settings_sync_on_holo.png b/res/drawable-xxhdpi/ic_appwidget_settings_sync_on_holo.png
deleted file mode 100644
index 56ebba1..0000000
--- a/res/drawable-xxhdpi/ic_appwidget_settings_sync_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_appwidget_settings_wifi_off_holo.png b/res/drawable-xxhdpi/ic_appwidget_settings_wifi_off_holo.png
deleted file mode 100644
index 1fb8019..0000000
--- a/res/drawable-xxhdpi/ic_appwidget_settings_wifi_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_appwidget_settings_wifi_on_holo.png b/res/drawable-xxhdpi/ic_appwidget_settings_wifi_on_holo.png
deleted file mode 100644
index 128c561..0000000
--- a/res/drawable-xxhdpi/ic_appwidget_settings_wifi_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_bg_holo.9.png b/res/drawable-xxxhdpi/appwidget_bg_holo.9.png
deleted file mode 100644
index 39b88d9..0000000
--- a/res/drawable-xxxhdpi/appwidget_bg_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_inner_focused_c_holo.9.png b/res/drawable-xxxhdpi/appwidget_inner_focused_c_holo.9.png
deleted file mode 100644
index 4eee026..0000000
--- a/res/drawable-xxxhdpi/appwidget_inner_focused_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_inner_focused_l_holo.9.png b/res/drawable-xxxhdpi/appwidget_inner_focused_l_holo.9.png
deleted file mode 100644
index 6af3bff..0000000
--- a/res/drawable-xxxhdpi/appwidget_inner_focused_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_inner_focused_r_holo.9.png b/res/drawable-xxxhdpi/appwidget_inner_focused_r_holo.9.png
deleted file mode 100644
index ac337c7..0000000
--- a/res/drawable-xxxhdpi/appwidget_inner_focused_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_inner_pressed_c_holo.9.png b/res/drawable-xxxhdpi/appwidget_inner_pressed_c_holo.9.png
deleted file mode 100644
index 10289ea..0000000
--- a/res/drawable-xxxhdpi/appwidget_inner_pressed_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_inner_pressed_l_holo.9.png b/res/drawable-xxxhdpi/appwidget_inner_pressed_l_holo.9.png
deleted file mode 100644
index 00da8e9..0000000
--- a/res/drawable-xxxhdpi/appwidget_inner_pressed_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_inner_pressed_r_holo.9.png b/res/drawable-xxxhdpi/appwidget_inner_pressed_r_holo.9.png
deleted file mode 100644
index 7c94a7c..0000000
--- a/res/drawable-xxxhdpi/appwidget_inner_pressed_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_settings_divider_holo.9.png b/res/drawable-xxxhdpi/appwidget_settings_divider_holo.9.png
deleted file mode 100644
index f7ad910..0000000
--- a/res/drawable-xxxhdpi/appwidget_settings_divider_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_settings_ind_mid_c_holo.9.png b/res/drawable-xxxhdpi/appwidget_settings_ind_mid_c_holo.9.png
deleted file mode 100644
index 08b1faf..0000000
--- a/res/drawable-xxxhdpi/appwidget_settings_ind_mid_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_settings_ind_mid_l_holo.9.png b/res/drawable-xxxhdpi/appwidget_settings_ind_mid_l_holo.9.png
deleted file mode 100644
index 25d80b2..0000000
--- a/res/drawable-xxxhdpi/appwidget_settings_ind_mid_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_settings_ind_mid_r_holo.9.png b/res/drawable-xxxhdpi/appwidget_settings_ind_mid_r_holo.9.png
deleted file mode 100644
index 83aa90d..0000000
--- a/res/drawable-xxxhdpi/appwidget_settings_ind_mid_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_settings_ind_off_c_holo.9.png b/res/drawable-xxxhdpi/appwidget_settings_ind_off_c_holo.9.png
deleted file mode 100644
index 928ab68..0000000
--- a/res/drawable-xxxhdpi/appwidget_settings_ind_off_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_settings_ind_off_l_holo.9.png b/res/drawable-xxxhdpi/appwidget_settings_ind_off_l_holo.9.png
deleted file mode 100644
index 77e3ef6..0000000
--- a/res/drawable-xxxhdpi/appwidget_settings_ind_off_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_settings_ind_off_r_holo.9.png b/res/drawable-xxxhdpi/appwidget_settings_ind_off_r_holo.9.png
deleted file mode 100644
index 52ac956..0000000
--- a/res/drawable-xxxhdpi/appwidget_settings_ind_off_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_settings_ind_on_c_holo.9.png b/res/drawable-xxxhdpi/appwidget_settings_ind_on_c_holo.9.png
deleted file mode 100644
index 4747a89..0000000
--- a/res/drawable-xxxhdpi/appwidget_settings_ind_on_c_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_settings_ind_on_l_holo.9.png b/res/drawable-xxxhdpi/appwidget_settings_ind_on_l_holo.9.png
deleted file mode 100644
index a0de1b0..0000000
--- a/res/drawable-xxxhdpi/appwidget_settings_ind_on_l_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_settings_ind_on_r_holo.9.png b/res/drawable-xxxhdpi/appwidget_settings_ind_on_r_holo.9.png
deleted file mode 100644
index 04a616b..0000000
--- a/res/drawable-xxxhdpi/appwidget_settings_ind_on_r_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_appwidget_settings_bluetooth_off_holo.png b/res/drawable-xxxhdpi/ic_appwidget_settings_bluetooth_off_holo.png
deleted file mode 100644
index bed7f49..0000000
--- a/res/drawable-xxxhdpi/ic_appwidget_settings_bluetooth_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_appwidget_settings_bluetooth_on_holo.png b/res/drawable-xxxhdpi/ic_appwidget_settings_bluetooth_on_holo.png
deleted file mode 100644
index fd15e3c..0000000
--- a/res/drawable-xxxhdpi/ic_appwidget_settings_bluetooth_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_appwidget_settings_brightness_auto_holo.png b/res/drawable-xxxhdpi/ic_appwidget_settings_brightness_auto_holo.png
deleted file mode 100644
index fa2fb13..0000000
--- a/res/drawable-xxxhdpi/ic_appwidget_settings_brightness_auto_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_appwidget_settings_brightness_full_holo.png b/res/drawable-xxxhdpi/ic_appwidget_settings_brightness_full_holo.png
deleted file mode 100644
index d176c2e..0000000
--- a/res/drawable-xxxhdpi/ic_appwidget_settings_brightness_full_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_appwidget_settings_brightness_half_holo.png b/res/drawable-xxxhdpi/ic_appwidget_settings_brightness_half_holo.png
deleted file mode 100644
index 0f24645..0000000
--- a/res/drawable-xxxhdpi/ic_appwidget_settings_brightness_half_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_appwidget_settings_brightness_off_holo.png b/res/drawable-xxxhdpi/ic_appwidget_settings_brightness_off_holo.png
deleted file mode 100644
index ed34dd3..0000000
--- a/res/drawable-xxxhdpi/ic_appwidget_settings_brightness_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_appwidget_settings_location_off_holo.png b/res/drawable-xxxhdpi/ic_appwidget_settings_location_off_holo.png
deleted file mode 100644
index e7d7560..0000000
--- a/res/drawable-xxxhdpi/ic_appwidget_settings_location_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_appwidget_settings_location_on_holo.png b/res/drawable-xxxhdpi/ic_appwidget_settings_location_on_holo.png
deleted file mode 100644
index 9e1222b..0000000
--- a/res/drawable-xxxhdpi/ic_appwidget_settings_location_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_appwidget_settings_location_saving_holo.png b/res/drawable-xxxhdpi/ic_appwidget_settings_location_saving_holo.png
deleted file mode 100644
index 309bde4..0000000
--- a/res/drawable-xxxhdpi/ic_appwidget_settings_location_saving_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_appwidget_settings_sync_off_holo.png b/res/drawable-xxxhdpi/ic_appwidget_settings_sync_off_holo.png
deleted file mode 100644
index 5c45bb5..0000000
--- a/res/drawable-xxxhdpi/ic_appwidget_settings_sync_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_appwidget_settings_sync_on_holo.png b/res/drawable-xxxhdpi/ic_appwidget_settings_sync_on_holo.png
deleted file mode 100644
index 07fd56f..0000000
--- a/res/drawable-xxxhdpi/ic_appwidget_settings_sync_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_appwidget_settings_wifi_off_holo.png b/res/drawable-xxxhdpi/ic_appwidget_settings_wifi_off_holo.png
deleted file mode 100644
index 392aaf4..0000000
--- a/res/drawable-xxxhdpi/ic_appwidget_settings_wifi_off_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_appwidget_settings_wifi_on_holo.png b/res/drawable-xxxhdpi/ic_appwidget_settings_wifi_on_holo.png
deleted file mode 100644
index a8b4772..0000000
--- a/res/drawable-xxxhdpi/ic_appwidget_settings_wifi_on_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/appwidget_button_center.xml b/res/drawable/appwidget_button_center.xml
deleted file mode 100644
index 3af32e5..0000000
--- a/res/drawable/appwidget_button_center.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 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.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-
-    <item android:state_pressed="true"
-        android:drawable="@drawable/appwidget_inner_pressed_c_holo" />
-
-    <item android:state_focused="true" android:state_enabled="true"
-        android:state_window_focused="true"
-        android:drawable="@drawable/appwidget_inner_focused_c_holo" />
-
-    <item
-         android:drawable="@android:color/transparent" />
-</selector>
diff --git a/res/drawable/appwidget_button_left.xml b/res/drawable/appwidget_button_left.xml
deleted file mode 100644
index e13cf99..0000000
--- a/res/drawable/appwidget_button_left.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 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.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-
-    <item android:state_pressed="true"
-        android:drawable="@drawable/appwidget_inner_pressed_l_holo" />
-
-    <item android:state_focused="true" android:state_enabled="true"
-        android:state_window_focused="true"
-        android:drawable="@drawable/appwidget_inner_focused_l_holo" />
-
-    <item
-         android:drawable="@android:color/transparent" />
-</selector>
diff --git a/res/drawable/appwidget_button_right.xml b/res/drawable/appwidget_button_right.xml
deleted file mode 100644
index e29c2fe..0000000
--- a/res/drawable/appwidget_button_right.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 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.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-
-    <item android:state_pressed="true"
-        android:drawable="@drawable/appwidget_inner_pressed_r_holo" />
-
-    <item android:state_focused="true" android:state_enabled="true"
-        android:state_window_focused="true"
-        android:drawable="@drawable/appwidget_inner_focused_r_holo" />
-
-    <item
-         android:drawable="@android:color/transparent" />
-</selector>
diff --git a/res/layout/battery_history_chart.xml b/res/layout/battery_history_chart.xml
deleted file mode 100644
index c0c37f1..0000000
--- a/res/layout/battery_history_chart.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingStart="?android:attr/listPreferredItemPaddingStart"
-        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
-
-    <com.android.settings.fuelgauge.BatteryHistoryChart
-            xmlns:android="http://schemas.android.com/apk/res/android"
-            xmlns:app="http://schemas.android.com/apk/res/com.android.settings"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:gravity="center_vertical"
-        android:id="@+id/battery_history_chart"
-        android:textAppearance="?android:attr/textAppearanceSmall"
-        android:textColor="?android:attr/textColorPrimary"
-        app:headerAppearance="?android:attr/textAppearanceMedium"
-        android:shadowRadius="4"
-        android:shadowColor="?android:attr/colorBackground"
-        android:shadowDx="2"
-        android:shadowDy="2"
-        app:barPrimaryColor="?android:attr/colorControlActivated"
-        app:barPredictionColor="@color/material_empty_color_light"
-        app:chartMinHeight="@dimen/battery_history_chart_height">
-    </com.android.settings.fuelgauge.BatteryHistoryChart>
-
-</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/dashboard.xml b/res/layout/dashboard.xml
index 536c00a..ccb50ae 100644
--- a/res/layout/dashboard.xml
+++ b/res/layout/dashboard.xml
@@ -14,7 +14,7 @@
      limitations under the License.
 -->
 
-<com.android.settings.dashboard.conditional.FocusRecyclerView
+<com.android.settings.homepage.conditional.FocusRecyclerView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/dashboard_container"
     android:layout_width="match_parent"
diff --git a/res/layout/widget.xml b/res/layout/widget.xml
deleted file mode 100644
index a125d80..0000000
--- a/res/layout/widget.xml
+++ /dev/null
@@ -1,198 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 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:id="@+id/main"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:gravity="center"
-    android:background="@drawable/appwidget_bg_holo" >
-
-    <LinearLayout
-        android:id="@+id/btn_wifi"
-        android:layout_width="0dip"
-        android:layout_weight="1"
-        android:layout_height="match_parent"
-        android:paddingTop="12dp"
-        android:background="@drawable/appwidget_button_left"
-        android:clickable="true"
-        android:focusable="true"
-        android:orientation="vertical">
-
-        <ImageView
-            android:id="@+id/img_wifi"
-            android:layout_width="match_parent"
-            android:layout_height="0dip"
-            android:layout_weight="1"
-            android:scaleType="center"
-            android:contentDescription="@null"
-            />
-
-        <ImageView
-            android:id="@+id/ind_wifi"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:scaleType="fitXY"
-            android:contentDescription="@null"
-            />
-        </LinearLayout>
-
-    <ImageView
-        android:layout_width="1dip"
-        android:layout_height="match_parent"
-        android:background="@drawable/appwidget_settings_divider_holo"
-        android:contentDescription="@null"
-        />
-
-    <LinearLayout
-        android:id="@+id/btn_bluetooth"
-        android:layout_width="0dip"
-        android:layout_weight="1"
-        android:layout_height="match_parent"
-        android:paddingTop="12dp"
-        android:background="@drawable/appwidget_button_center"
-        android:clickable="true"
-        android:focusable="true"
-        android:orientation="vertical">
-
-        <ImageView
-            android:id="@+id/img_bluetooth"
-            android:layout_width="match_parent"
-            android:layout_height="0dip"
-            android:layout_weight="1"
-            android:scaleType="center"
-            android:contentDescription="@null"
-            />
-
-        <ImageView
-            android:id="@+id/ind_bluetooth"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:scaleType="fitXY"
-            android:contentDescription="@null"
-            />
-
-    </LinearLayout>
-
-    <ImageView
-        android:layout_width="1dip"
-        android:layout_height="match_parent"
-        android:background="@drawable/appwidget_settings_divider_holo"
-        android:contentDescription="@null"
-        />
-
-    <LinearLayout
-        android:id="@+id/btn_location"
-        android:layout_width="0dip"
-        android:layout_weight="1"
-        android:layout_height="match_parent"
-        android:paddingTop="12dp"
-        android:background="@drawable/appwidget_button_center"
-        android:clickable="true"
-        android:focusable="true"
-        android:orientation="vertical">
-
-        <ImageView
-            android:id="@+id/img_location"
-            android:layout_width="match_parent"
-            android:layout_height="0dip"
-            android:layout_weight="1"
-            android:scaleType="center"
-            android:contentDescription="@null"
-            />
-
-        <ImageView
-            android:id="@+id/ind_location"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:scaleType="fitXY"
-            android:contentDescription="@null"
-            />
-    </LinearLayout>
-
-    <ImageView
-        android:layout_width="1dip"
-        android:layout_height="match_parent"
-        android:background="@drawable/appwidget_settings_divider_holo"
-        android:contentDescription="@null"
-        />    
-
-    <LinearLayout
-        android:id="@+id/btn_sync"
-        android:layout_width="0dip"
-        android:layout_weight="1"
-        android:layout_height="match_parent"
-        android:paddingTop="12dp"
-        android:background="@drawable/appwidget_button_center"
-        android:clickable="true"
-        android:focusable="true"
-        android:orientation="vertical">
-
-        <ImageView
-            android:id="@+id/img_sync"
-            android:layout_width="match_parent"
-            android:layout_height="0dip"
-            android:layout_weight="1"
-            android:scaleType="center"
-            android:contentDescription="@null"
-            />
-
-        <ImageView
-            android:id="@+id/ind_sync"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:scaleType="fitXY"
-            android:contentDescription="@null"
-            />
-    </LinearLayout>
-
-    <ImageView
-        android:layout_width="1dip"
-        android:layout_height="match_parent"
-        android:background="@drawable/appwidget_settings_divider_holo"
-        android:contentDescription="@null"
-        />
-
-    <LinearLayout
-        android:id="@+id/btn_brightness"
-        android:layout_width="0dip"
-        android:layout_weight="1"
-        android:layout_height="match_parent"
-        android:paddingTop="12dp"
-        android:background="@drawable/appwidget_button_right"
-        android:clickable="true"
-        android:focusable="true"
-        android:orientation="vertical">
-
-        <ImageView
-            android:id="@+id/img_brightness"
-            android:layout_width="match_parent"
-            android:layout_height="0dip"
-            android:layout_weight="1"
-            android:scaleType="center"
-            android:contentDescription="@null"
-            />
-
-        <ImageView
-            android:id="@+id/ind_brightness"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:scaleType="fitXY"
-            android:contentDescription="@null"
-            />
-    </LinearLayout>
-
-</LinearLayout>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 58b05d8..273225e 100755
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -24,8 +24,6 @@
     <dimen name="content_margin_left">16dip</dimen>
     <dimen name="description_margin_top">26dip</dimen>
     <dimen name="crypt_clock_size">120sp</dimen>
-    <dimen name="appwidget_min_width">325dip</dimen>
-    <dimen name="appwidget_min_height">50dip</dimen>
 
     <!-- ActionBar contentInsetStart -->
     <dimen name="actionbar_contentInsetStart">24dp</dimen>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 7bdbe6d..b77c544 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -15,35 +15,6 @@
 -->
 
 <resources>
-    <declare-styleable name="BatteryHistoryChart">
-        <!-- Base text color, typeface, size, and style. -->
-        <attr name="android:textAppearance" />
-        <!-- Text color. -->
-        <attr name="android:textColor" />
-        <!-- Size of the text. Recommended dimension type for text is "sp" for scaled-pixels (example: 15sp). -->
-        <attr name="android:textSize" />
-        <!-- Typeface (normal, sans, serif, monospace) for the text. -->
-        <attr name="android:typeface" />
-        <!-- Style (bold, italic, bolditalic) for the text. -->
-        <attr name="android:textStyle" />
-        <!-- Place a shadow of the specified color behind the text. -->
-        <attr name="android:shadowColor" />
-        <!-- Horizontal offset of the shadow. -->
-        <attr name="android:shadowDx" />
-        <!-- Vertical offset of the shadow. -->
-        <attr name="android:shadowDy" />
-        <!-- Radius of the shadow. -->
-        <attr name="android:shadowRadius" />
-        <!-- Text color, typeface, size, and style of header. -->
-        <attr name="headerAppearance" format="reference" />
-        <!-- Primary color of chart. -->
-        <attr name="barPrimaryColor" format="color|reference" />
-        <!-- Color of predicted future use part of chart. -->
-        <attr name="barPredictionColor" format="color|reference" />
-        <!-- Minimum height of the chart itself. -->
-        <attr name="chartMinHeight" format="dimension|reference" />
-    </declare-styleable>
-
     <declare-styleable name="PercentageBarChart">
         <!-- Background color -->
         <attr name="emptyColor" format="color" />
diff --git a/res/values/bools.xml b/res/values/bools.xml
index 0a928c3..f1abe9d 100644
--- a/res/values/bools.xml
+++ b/res/values/bools.xml
@@ -21,9 +21,6 @@
     <bool name="has_boot_sounds">false</bool>
     <!-- Whether there is a silent mode checkbox  -->
     <bool name="has_silent_mode">true</bool>
-    <!-- Whether the DEPRECATED power control widget is enabled for this
-         device. Should be overridden for specific product builds. -->
-    <bool name="has_powercontrol_widget">false</bool>
 
     <!-- Display additional System Update menu if true -->
     <bool name="config_additional_system_update_setting_enable">false</bool>
diff --git a/res/values/config.xml b/res/values/config.xml
index 2920ac8..f510523 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -106,9 +106,6 @@
         -->
     </string-array>
 
-    <!-- Whether or not we should tint the icon color on setting pages. -->
-    <bool name="config_tintSettingIcon">true</bool>
-
     <!-- Whether or not App & Notification screen should display recently used apps -->
     <bool name="config_display_recent_apps">true</bool>
 
@@ -133,4 +130,7 @@
          devices will be able to vary their amplitude but do not possess enough dynamic range to
          have distinct intensity levels -->
     <bool name="config_vibration_supports_multiple_intensities">false</bool>
+
+    <!-- Whether or not TopLevelSettings should force rounded icon for injected tiles -->
+    <bool name="config_force_rounded_icon_TopLevelSettings">true</bool>
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 2341728..acb895b 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -33,8 +33,6 @@
     <dimen name="bind_app_widget_dialog_checkbox_bottom_padding">16dip</dimen>
     <dimen name="installed_app_details_bullet_offset">8dip</dimen>
 
-    <dimen name="battery_history_chart_height">120dp</dimen>
-
     <dimen name="data_usage_chart_height">228dip</dimen>
     <dimen name="data_usage_chart_optimalWidth">440dip</dimen>
     <dimen name="usage_number_text_size">36sp</dimen>
@@ -47,11 +45,6 @@
     <dimen name="divider_margin_top">6dip</dimen>
     <dimen name="divider_margin_bottom">7dip</dimen>
 
-    <!--  Size of icons in the top-level of settings  -->
-    <dimen name="header_icon_width">28dp</dimen>
-    <dimen name="appwidget_min_width">280dip</dimen>
-    <dimen name="appwidget_min_height">40dip</dimen>
-
     <dimen name="pager_tabs_padding">0dp</dimen>
     <dimen name="pager_tabs_title_padding">16dp</dimen>
     <dimen name="pager_tabs_selected_indicator_height">3dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index df98e0e..0c3732b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5534,39 +5534,6 @@
     <!-- Name for buttont hat plays a sample of the currently selected text-to-speech engine. -->
     <string name="tts_play">Play</string>
 
-    <!-- Power Control Widget -->
-    <string name="gadget_title">Power control</string>
-    <string name="gadget_toggle_wifi">Updating Wi\u2011Fi setting</string>
-    <string name="gadget_toggle_bluetooth">Updating Bluetooth setting</string>
-    <!-- Template for gadget toggle button description. Populated examples are "Wi-Fi off" or "Wi-Fi turning on". -->
-    <string name="gadget_state_template"><xliff:g name="feature" example="Wi\u2011Fi">%1$s</xliff:g> <xliff:g name="state" example="off">%2$s</xliff:g></string>
-    <!-- Gadget value used to describe on state. -->
-    <string name="gadget_state_on">on</string>
-    <!-- Gadget value used to describe off state. -->
-    <string name="gadget_state_off">off</string>
-    <!-- Gadget value used to describe turning on state. -->
-    <string name="gadget_state_turning_on">turning on</string>
-    <!-- Gadget value used to describe turning off state. -->
-    <string name="gadget_state_turning_off">turning off</string>
-    <!-- Spoken description for the Wi-Fi power control gadget. -->
-    <string name="gadget_wifi">Wi\u2011Fi</string>
-    <!-- Spoken description for the Bluetooth power control gadget. -->
-    <string name="gadget_bluetooth">Bluetooth</string>
-    <!-- Spoken description for the Location power control gadget. -->
-    <string name="gadget_location">Location</string>
-    <!-- Spoken description for the data synchronization gadget. -->
-    <string name="gadget_sync">Sync</string>
-    <!-- Template for brightness gadget toggle button description. -->
-    <string name="gadget_brightness_template">Brightness <xliff:g name="state" example="half">%1$s</xliff:g></string>
-    <!-- Brightness gadget value used to describe automatic brightness state. -->
-    <string name="gadget_brightness_state_auto">auto</string>
-    <!-- Brightness gadget value used to describe maximum brightness state. -->
-    <string name="gadget_brightness_state_full">full</string>
-    <!-- Brightness gadget value used to describe half brightness state. -->
-    <string name="gadget_brightness_state_half">half</string>
-    <!-- Brightness gadget value used to describe minimum brightness state. -->
-    <string name="gadget_brightness_state_off">off</string>
-
     <!-- Title of preference to enter the VPN settings activity -->
     <string name="vpn_settings_title">VPN</string>
 
@@ -9601,7 +9568,7 @@
     <string name="ambient_display_title" product="device">Double-tap to check device</string>
 
     <!-- Summary text for ambient display double tap [CHAR LIMIT=NONE]-->
-    <string name="ambient_display_summary">To check time, notification icons, and other info, double-tap your screen.</string>
+    <string name="ambient_display_summary">To check time, notifications, and other info, double-tap your screen.</string>
 
     <!-- Preference and settings suggestion title text for ambient display pick up (phone) [CHAR LIMIT=60]-->
     <string name="ambient_display_pickup_title" product="default">Lift to check phone</string>
@@ -9611,11 +9578,11 @@
     <string name="ambient_display_pickup_title" product="device">Lift to check device</string>
 
     <!-- Summary text for ambient display (phone) [CHAR LIMIT=NONE]-->
-    <string name="ambient_display_pickup_summary" product="default">To check time, notification icons, and other info, pick up your phone.</string>
+    <string name="ambient_display_pickup_summary" product="default">To check time, notifications, and other info, pick up your phone.</string>
     <!-- Summary text for ambient display (tablet) [CHAR LIMIT=NONE]-->
-    <string name="ambient_display_pickup_summary" product="tablet">To check time, notification icons, and other info, pick up your tablet.</string>
+    <string name="ambient_display_pickup_summary" product="tablet">To check time, notifications, and other info, pick up your tablet.</string>
     <!-- Summary text for ambient display (device) [CHAR LIMIT=NONE]-->
-    <string name="ambient_display_pickup_summary" product="device">To check time, notification icons, and other info, pick up your device.</string>
+    <string name="ambient_display_pickup_summary" product="device">To check time, notifications, and other info, pick up your device.</string>
 
     <!-- Title text for swiping downwards on fingerprint sensor for notifications [CHAR LIMIT=80]-->
     <string name="fingerprint_swipe_for_notifications_title">Swipe fingerprint for notifications</string>
diff --git a/res/xml/appwidget_info.xml b/res/xml/appwidget_info.xml
deleted file mode 100644
index 2d8c81e..0000000
--- a/res/xml/appwidget_info.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 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.
--->
-
-<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
-    android:minWidth="@dimen/appwidget_min_width"
-    android:minHeight="@dimen/appwidget_min_height"
-    android:previewImage="@drawable/preview"
-    android:initialLayout="@layout/widget"
-    >
-</appwidget-provider>
diff --git a/res/xml/default_autofill_picker_settings.xml b/res/xml/default_autofill_picker_settings.xml
new file mode 100644
index 0000000..26dff7e
--- /dev/null
+++ b/res/xml/default_autofill_picker_settings.xml
@@ -0,0 +1,46 @@
+<?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.
+  -->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:key="default_autofill_picker"
+    android:title="@string/autofill_app"
+    settings:keywords="@string/autofill_keywords">
+
+  <com.android.settings.widget.GearPreference
+      android:key="default_autofill_main"
+      android:title="@string/autofill_app"
+      android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
+      settings:keywords="@string/autofill_keywords">
+    <extra android:name="for_work" android:value="false" />
+  </com.android.settings.widget.GearPreference>
+
+
+  <com.android.settings.widget.WorkOnlyCategory
+      android:key="work_app_defaults"
+      android:title="@string/default_for_work">
+
+    <com.android.settings.widget.GearPreference
+        android:key="default_autofill_work"
+        android:title="@string/autofill_app"
+        android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
+        settings:keywords="@string/autofill_keywords">
+      <extra android:name="for_work" android:value="true" />
+    </com.android.settings.widget.GearPreference>
+  </com.android.settings.widget.WorkOnlyCategory>
+</PreferenceScreen>
diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml
index ec15f0d..50c6a82 100644
--- a/res/xml/language_and_input.xml
+++ b/res/xml/language_and_input.xml
@@ -54,10 +54,10 @@
             android:persistent="false"
             android:fragment="com.android.settings.inputmethod.SpellCheckersSettings" />
 
-        <com.android.settings.widget.GearPreference
+        <Preference
             android:key="default_autofill"
             android:title="@string/autofill_app"
-            android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
+            android:fragment="com.android.settings.applications.defaultapps.AutofillPicker"
             settings:keywords="@string/autofill_keywords" />
 
         <!-- User dictionary preference title and fragment will be set programmatically. -->
diff --git a/res/xml/top_level_settings.xml b/res/xml/top_level_settings.xml
index 7aed021..6c91aea 100644
--- a/res/xml/top_level_settings.xml
+++ b/res/xml/top_level_settings.xml
@@ -26,6 +26,7 @@
         android:title="@string/network_dashboard_title"
         android:summary="@string/summary_placeholder"
         android:icon="@drawable/ic_homepage_network"
+        android:order="-110"
         android:fragment="com.android.settings.network.NetworkDashboardFragment"
         settings:controller="com.android.settings.network.TopLevelNetworkEntryPreferenceController"/>
 
@@ -34,13 +35,16 @@
         android:title="@string/connected_devices_dashboard_title"
         android:summary="@string/summary_placeholder"
         android:icon="@drawable/ic_homepage_connected_device"
-        android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment"/>
+        android:order="-100"
+        android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment"
+        settings:controller="com.android.settings.connecteddevice.TopLevelConnectedDevicesPreferenceController"/>
 
     <Preference
         android:key="top_level_apps_and_notifs"
         android:title="@string/app_and_notification_dashboard_title"
-        android:summary="@string/summary_placeholder"
+        android:summary="@string/app_and_notification_dashboard_summary"
         android:icon="@drawable/ic_homepage_apps"
+        android:order="-90"
         android:fragment="com.android.settings.applications.AppAndNotificationDashboardFragment"/>
 
     <Preference
@@ -48,20 +52,24 @@
         android:title="@string/power_usage_summary_title"
         android:summary="@string/summary_placeholder"
         android:icon="@drawable/ic_homepage_battery"
-        android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"/>
+        android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
+        android:order="-80"
+        settings:controller="com.android.settings.fuelgauge.TopLevelBatteryPreferenceController"/>
 
     <Preference
         android:key="top_level_display"
         android:title="@string/display_settings"
-        android:summary="@string/summary_placeholder"
+        android:summary="@string/display_dashboard_summary"
         android:icon="@drawable/ic_homepage_display"
+        android:order="-70"
         android:fragment="com.android.settings.DisplaySettings"/>
 
     <Preference
         android:key="top_level_sound"
         android:title="@string/sound_settings"
-        android:summary="@string/summary_placeholder"
+        android:summary="@string/sound_dashboard_summary"
         android:icon="@drawable/ic_homepage_sound"
+        android:order="-60"
         android:fragment="com.android.settings.notification.SoundSettings"/>
 
     <Preference
@@ -69,40 +77,49 @@
         android:title="@string/storage_settings"
         android:summary="@string/summary_placeholder"
         android:icon="@drawable/ic_homepage_storage"
-        android:fragment="com.android.settings.deviceinfo.StorageSettings"/>
+        android:order="-50"
+        android:fragment="com.android.settings.deviceinfo.StorageSettings"
+        settings:controller="com.android.settings.deviceinfo.TopLevelStoragePreferenceController"/>
 
     <Preference
         android:key="top_level_security"
         android:title="@string/security_settings_title"
         android:summary="@string/summary_placeholder"
         android:icon="@drawable/ic_homepage_security"
-        android:fragment="com.android.settings.security.SecuritySettings"/>
+        android:order="-40"
+        android:fragment="com.android.settings.security.SecuritySettings"
+        settings:controller="com.android.settings.security.TopLevelSecurityEntryPreferenceController"/>
 
     <Preference
         android:key="top_level_accounts"
         android:title="@string/account_dashboard_title"
         android:summary="@string/summary_placeholder"
         android:icon="@drawable/ic_homepage_accounts"
-        android:fragment="com.android.settings.accounts.AccountDashboardFragment"/>
+        android:order="-30"
+        android:fragment="com.android.settings.accounts.AccountDashboardFragment"
+        settings:controller="com.android.settings.accounts.TopLevelAccountEntryPreferenceController"/>
 
     <Preference
         android:key="top_level_accessibility"
         android:title="@string/accessibility_settings"
-        android:summary="@string/summary_placeholder"
+        android:summary="@string/accessibility_settings_summary"
         android:icon="@drawable/ic_homepage_accessibility"
+        android:order="-20"
         android:fragment="com.android.settings.accessibility.AccessibilitySettings"/>
 
     <Preference
         android:key="top_level_system"
         android:title="@string/header_category_system"
-        android:summary="@string/summary_placeholder"
+        android:summary="@string/system_dashboard_summary"
         android:icon="@drawable/ic_homepage_system_dashboard"
+        android:order="-10"
         android:fragment="com.android.settings.system.SystemDashboardFragment"/>
 
     <Preference
         android:key="top_level_support"
         android:summary="@string/support_summary"
         android:title="@string/page_tab_title_support"
-        android:icon="@drawable/ic_homepage_support"/>
+        android:icon="@drawable/ic_homepage_support"
+        android:order="100"/>
 
 </PreferenceScreen>
\ No newline at end of file
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 4f011c1..94de8da 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -121,7 +121,6 @@
     }
     public static class DirectoryAccessSettingsActivity extends SettingsActivity { /* empty */ }
 
-    public static class TopLevelSettings extends SettingsActivity { /* empty */ }
     public static class ApnSettingsActivity extends SettingsActivity { /* empty */ }
     public static class WifiCallingSettingsActivity extends SettingsActivity { /* empty */ }
     public static class MemorySettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java b/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java
new file mode 100644
index 0000000..a8d93d5
--- /dev/null
+++ b/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java
@@ -0,0 +1,68 @@
+/*
+ * 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.content.Context;
+import android.icu.text.ListFormatter;
+import android.os.UserHandle;
+import android.text.BidiFormatter;
+import android.text.TextUtils;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.accounts.AuthenticatorHelper;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TopLevelAccountEntryPreferenceController extends BasePreferenceController {
+    public TopLevelAccountEntryPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE_UNSEARCHABLE;
+    }
+
+    @Override
+    public CharSequence getSummary() {
+        final AuthenticatorHelper authHelper = new AuthenticatorHelper(mContext,
+                UserHandle.of(UserHandle.myUserId()), null /* OnAccountsUpdateListener */);
+        final String[] types = authHelper.getEnabledAccountTypes();
+        final BidiFormatter bidiFormatter = BidiFormatter.getInstance();
+        final List<CharSequence> summaries = new ArrayList<>();
+
+        if (types == null || types.length == 0) {
+            summaries.add(mContext.getString(R.string.account_dashboard_default_summary));
+        } else {
+            // Show up to 3 account types, ignore any null value
+            int accountToAdd = Math.min(3, types.length);
+
+            for (int i = 0; i < types.length && accountToAdd > 0; i++) {
+                final CharSequence label = authHelper.getLabelForType(mContext, types[i]);
+                if (TextUtils.isEmpty(label)) {
+                    continue;
+                }
+
+                summaries.add(bidiFormatter.unicodeWrap(label));
+                accountToAdd--;
+            }
+        }
+        return ListFormatter.getInstance().format(summaries);
+    }
+}
diff --git a/src/com/android/settings/applications/autofill/AutofillPickerTrampolineActivity.java b/src/com/android/settings/applications/autofill/AutofillPickerTrampolineActivity.java
index 1db3c82..9500fd5 100644
--- a/src/com/android/settings/applications/autofill/AutofillPickerTrampolineActivity.java
+++ b/src/com/android/settings/applications/autofill/AutofillPickerTrampolineActivity.java
@@ -16,6 +16,7 @@
 import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
+import android.os.UserHandle;
 import android.view.autofill.AutofillManager;
 
 import com.android.settings.applications.defaultapps.DefaultAutofillPicker;
@@ -36,7 +37,8 @@
         // First check if the current user's service already belongs to the app...
         final Intent intent = getIntent();
         final String packageName = intent.getData().getSchemeSpecificPart();
-        final String currentService = DefaultAutofillPicker.getDefaultKey(this);
+        final String currentService = DefaultAutofillPicker.getDefaultKey(
+                this, UserHandle.myUserId());
         if (currentService != null && currentService.startsWith(packageName)) {
             // ...and succeed right away if it does.
             setResult(RESULT_OK);
diff --git a/src/com/android/settings/applications/defaultapps/AutofillPicker.java b/src/com/android/settings/applications/defaultapps/AutofillPicker.java
new file mode 100644
index 0000000..3f392e5
--- /dev/null
+++ b/src/com/android/settings/applications/defaultapps/AutofillPicker.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.applications.defaultapps;
+
+import android.content.Context;
+import android.provider.SearchIndexableResource;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController;
+import com.android.settings.applications.defaultapps.DefaultWorkAutofillPreferenceController;
+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.search.SearchIndexable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
+public class AutofillPicker extends DashboardFragment {
+    private static final String TAG = "AutofillPicker";
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsProto.MetricsEvent.DEFAULT_AUTOFILL_PICKER;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.default_autofill_picker_settings;
+    }
+
+    @Override
+    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+        return buildPreferenceControllers(context);
+    }
+
+    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider() {
+                @Override
+                public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+                        boolean enabled) {
+                    SearchIndexableResource searchIndexableResource =
+                            new SearchIndexableResource(context);
+                    searchIndexableResource.xmlResId = R.xml.default_autofill_picker_settings;
+                    return Arrays.asList(searchIndexableResource);
+                }
+
+                @Override
+                public List<AbstractPreferenceController> getPreferenceControllers(Context
+                        context) {
+                    return buildPreferenceControllers(context);
+                }
+            };
+
+    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
+        return Arrays.asList(
+                new DefaultAutofillPreferenceController(context),
+                new DefaultWorkAutofillPreferenceController(context));
+    }
+}
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
index 6016dbc..78248e6 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
@@ -82,12 +82,16 @@
         final Intent settingIntent = getSettingIntent(app);
         if (settingIntent != null) {
             ((GearPreference) preference).setOnGearClickListener(
-                    p -> mContext.startActivity(settingIntent));
+                    p -> startActivity(settingIntent));
         } else {
             ((GearPreference) preference).setOnGearClickListener(null);
         }
     }
 
+    protected void startActivity(Intent intent) {
+        mContext.startActivity(intent);
+    }
+
     protected abstract DefaultAppInfo getDefaultAppInfo();
 
     /**
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java b/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java
index 9bb82d4..1705dc5 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java
@@ -27,25 +27,23 @@
 import android.content.pm.ServiceInfo;
 import android.net.Uri;
 import android.os.Bundle;
+import android.os.UserHandle;
 import android.provider.Settings;
 import android.service.autofill.AutofillService;
 import android.service.autofill.AutofillServiceInfo;
 import android.text.Html;
 import android.text.TextUtils;
 import android.util.Log;
-
+import androidx.preference.Preference;
 import com.android.internal.content.PackageMonitor;
 import com.android.internal.logging.nano.MetricsProto;
 import com.android.settings.R;
 import com.android.settingslib.applications.DefaultAppInfo;
 import com.android.settingslib.utils.ThreadUtils;
 import com.android.settingslib.widget.CandidateInfo;
-
 import java.util.ArrayList;
 import java.util.List;
 
-import androidx.preference.Preference;
-
 public class DefaultAutofillPicker extends DefaultAppPickerFragment {
 
     private static final String TAG = "DefaultAutofillPicker";
@@ -73,8 +71,10 @@
                 activity.setResult(Activity.RESULT_CANCELED);
                 activity.finish();
             };
+            // If mCancelListener is not null, fragment is started from
+            // ACTION_REQUEST_SET_AUTOFILL_SERVICE and we should always use the calling uid.
+            mUserId = UserHandle.myUserId();
         }
-
         mSettingsPackageMonitor.register(activity, activity.getMainLooper(), false);
         update();
     }
@@ -159,8 +159,10 @@
      * @return The preference or {@code null} if no service can be added
      */
     private Preference newAddServicePreferenceOrNull() {
-        final String searchUri = Settings.Secure.getString(getActivity().getContentResolver(),
-                Settings.Secure.AUTOFILL_SERVICE_SEARCH_URI);
+        final String searchUri = Settings.Secure.getStringForUser(
+                getActivity().getContentResolver(),
+                Settings.Secure.AUTOFILL_SERVICE_SEARCH_URI,
+                mUserId);
         if (TextUtils.isEmpty(searchUri)) {
             return null;
         }
@@ -189,8 +191,8 @@
     @Override
     protected List<DefaultAppInfo> getCandidates() {
         final List<DefaultAppInfo> candidates = new ArrayList<>();
-        final List<ResolveInfo> resolveInfos = mPm.queryIntentServices(
-                AUTOFILL_PROBE, PackageManager.GET_META_DATA);
+        final List<ResolveInfo> resolveInfos = mPm.queryIntentServicesAsUser(
+                AUTOFILL_PROBE, PackageManager.GET_META_DATA, mUserId);
         final Context context = getContext();
         for (ResolveInfo info : resolveInfos) {
             final String permission = info.serviceInfo.permission;
@@ -210,8 +212,9 @@
         return candidates;
     }
 
-    public static String getDefaultKey(Context context) {
-        String setting = Settings.Secure.getString(context.getContentResolver(), SETTING);
+    public static String getDefaultKey(Context context, int userId) {
+        String setting = Settings.Secure.getStringForUser(
+                context.getContentResolver(), SETTING, userId);
         if (setting != null) {
             ComponentName componentName = ComponentName.unflattenFromString(setting);
             if (componentName != null) {
@@ -223,7 +226,7 @@
 
     @Override
     protected String getDefaultKey() {
-        return getDefaultKey(getContext());
+        return getDefaultKey(getContext(), mUserId);
     }
 
     @Override
@@ -239,7 +242,7 @@
 
     @Override
     protected boolean setDefaultKey(String key) {
-        Settings.Secure.putString(getContext().getContentResolver(), SETTING, key);
+        Settings.Secure.putStringForUser(getContext().getContentResolver(), SETTING, key, mUserId);
 
         // Check if activity was launched from Settings.ACTION_REQUEST_SET_AUTOFILL_SERVICE
         // intent, and set proper result if so...
@@ -263,16 +266,19 @@
 
         private final String mSelectedKey;
         private final Context mContext;
+        private final int mUserId;
 
-        public AutofillSettingIntentProvider(Context context, String key) {
+        public AutofillSettingIntentProvider(Context context, int userId, String key) {
             mSelectedKey = key;
             mContext = context;
+            mUserId = userId;
         }
 
         @Override
         public Intent getIntent() {
-            final List<ResolveInfo> resolveInfos = mContext.getPackageManager().queryIntentServices(
-                    AUTOFILL_PROBE, PackageManager.GET_META_DATA);
+            final List<ResolveInfo> resolveInfos = mContext.getPackageManager()
+                    .queryIntentServicesAsUser(
+                            AUTOFILL_PROBE, PackageManager.GET_META_DATA, mUserId);
 
             for (ResolveInfo resolveInfo : resolveInfos) {
                 final ServiceInfo serviceInfo = resolveInfo.serviceInfo;
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java
index bab1d16..d32322b 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java
@@ -44,7 +44,7 @@
 
     @Override
     public String getPreferenceKey() {
-        return "default_autofill";
+        return "default_autofill_main";
     }
 
     @Override
@@ -54,7 +54,7 @@
         }
         final DefaultAutofillPicker.AutofillSettingIntentProvider intentProvider =
                 new DefaultAutofillPicker.AutofillSettingIntentProvider(
-                        mContext, info.getKey());
+                        mContext, mUserId, info.getKey());
         return intentProvider.getIntent();
     }
 
diff --git a/src/com/android/settings/applications/defaultapps/DefaultWorkAutofillPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultWorkAutofillPreferenceController.java
new file mode 100644
index 0000000..ea4eff6
--- /dev/null
+++ b/src/com/android/settings/applications/defaultapps/DefaultWorkAutofillPreferenceController.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.applications.defaultapps;
+
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.os.UserHandle;
+import android.provider.Settings;
+import android.text.TextUtils;
+import com.android.settings.Utils;
+import com.android.settingslib.applications.DefaultAppInfo;
+
+public class DefaultWorkAutofillPreferenceController extends DefaultAutofillPreferenceController {
+    private final UserHandle mUserHandle;
+
+    public DefaultWorkAutofillPreferenceController(Context context) {
+        super(context);
+        mUserHandle = Utils.getManagedProfile(mUserManager);
+    }
+
+    @Override
+    public boolean isAvailable() {
+        if (mUserHandle == null) {
+            return false;
+        }
+        return super.isAvailable();
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return "default_autofill_work";
+    }
+
+    @Override
+    protected DefaultAppInfo getDefaultAppInfo() {
+        final String flattenComponent = Settings.Secure.getStringForUser(
+                mContext.getContentResolver(),
+                DefaultAutofillPicker.SETTING,
+                mUserHandle.getIdentifier());
+        if (!TextUtils.isEmpty(flattenComponent)) {
+            DefaultAppInfo appInfo = new DefaultAppInfo(
+                    mContext,
+                    mPackageManager,
+                    mUserHandle.getIdentifier(),
+                    ComponentName.unflattenFromString(flattenComponent));
+            return appInfo;
+        }
+        return null;
+    }
+
+    @Override
+    protected Intent getSettingIntent(DefaultAppInfo info) {
+        if (info == null) {
+            return null;
+        }
+        final DefaultAutofillPicker.AutofillSettingIntentProvider intentProvider =
+                new DefaultAutofillPicker.AutofillSettingIntentProvider(
+                        mContext, mUserHandle.getIdentifier(), info.getKey());
+        return intentProvider.getIntent();
+    }
+
+    @Override
+    protected void startActivity(Intent intent) {
+        mContext.startActivityAsUser(intent, mUserHandle);
+    }
+}
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index 84cab40..c786356 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -15,6 +15,7 @@
  */
 package com.android.settings.bluetooth;
 
+import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothDevice;
 import android.content.Context;
 import android.os.Bundle;
@@ -115,16 +116,30 @@
      * Force to update the list of bluetooth devices
      */
     public void forceUpdate() {
-        Collection<CachedBluetoothDevice> cachedDevices =
+        if (BluetoothAdapter.getDefaultAdapter().isEnabled()) {
+            final Collection<CachedBluetoothDevice> cachedDevices =
+                    mLocalManager.getCachedDeviceManager().getCachedDevicesCopy();
+            for (CachedBluetoothDevice cachedBluetoothDevice : cachedDevices) {
+                update(cachedBluetoothDevice);
+            }
+        }
+    }
+
+    public void removeAllDevicesFromPreference() {
+        final Collection<CachedBluetoothDevice> cachedDevices =
                 mLocalManager.getCachedDeviceManager().getCachedDevicesCopy();
         for (CachedBluetoothDevice cachedBluetoothDevice : cachedDevices) {
-            update(cachedBluetoothDevice);
+            removePreference(cachedBluetoothDevice);
         }
     }
 
     @Override
     public void onBluetoothStateChanged(int bluetoothState) {
-        forceUpdate();
+        if (BluetoothAdapter.STATE_ON == bluetoothState) {
+            forceUpdate();
+        } else if (BluetoothAdapter.STATE_OFF == bluetoothState) {
+            removeAllDevicesFromPreference();
+        }
     }
 
     @Override
diff --git a/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java b/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java
index 7a56994..3c2f1b8 100644
--- a/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java
+++ b/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java
@@ -37,6 +37,7 @@
 import androidx.core.graphics.drawable.IconCompat;
 import androidx.slice.Slice;
 import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.ListBuilder.RowBuilder;
 import androidx.slice.builders.SliceAction;
 
 /**
@@ -93,7 +94,7 @@
 
         return new ListBuilder(context, BLUETOOTH_URI, ListBuilder.INFINITY)
                 .setAccentColor(color)
-                .addRow(b -> b
+                .addRow(new RowBuilder()
                         .setTitle(title)
                         .addEndItem(toggleSliceAction)
                         .setPrimaryAction(primarySliceAction))
diff --git a/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceController.java b/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceController.java
new file mode 100644
index 0000000..6f16db6
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceController.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.connecteddevice;
+
+import android.content.Context;
+
+import com.android.settings.core.BasePreferenceController;
+
+public class TopLevelConnectedDevicesPreferenceController extends BasePreferenceController {
+
+    public TopLevelConnectedDevicesPreferenceController(Context context,
+            String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE_UNSEARCHABLE;
+    }
+
+    @Override
+    public CharSequence getSummary() {
+        return mContext.getText(
+                AdvancedConnectedDeviceController.getConnectedDevicesSummaryResourceId(mContext));
+    }
+}
diff --git a/src/com/android/settings/dashboard/DashboardAdapter.java b/src/com/android/settings/dashboard/DashboardAdapter.java
index 7e7cf46..a2d810b 100644
--- a/src/com/android/settings/dashboard/DashboardAdapter.java
+++ b/src/com/android/settings/dashboard/DashboardAdapter.java
@@ -16,7 +16,6 @@
 package com.android.settings.dashboard;
 
 import android.content.Context;
-import android.content.pm.PackageManager;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.Icon;
 import android.os.Bundle;
@@ -40,17 +39,17 @@
 import com.android.settings.R;
 import com.android.settings.R.id;
 import com.android.settings.dashboard.DashboardData.ConditionHeaderData;
-import com.android.settings.dashboard.conditional.Condition;
-import com.android.settings.dashboard.conditional.ConditionAdapter;
 import com.android.settings.dashboard.suggestions.SuggestionAdapter;
+import com.android.settings.homepage.conditional.Condition;
+import com.android.settings.homepage.conditional.ConditionAdapter;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.widget.RoundedHomepageIcon;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
 import com.android.settingslib.drawer.DashboardCategory;
 import com.android.settingslib.drawer.Tile;
-import com.android.settingslib.drawer.TileUtils;
 import com.android.settingslib.suggestions.SuggestionControllerMixinCompat;
 import com.android.settingslib.utils.IconCache;
 
@@ -64,7 +63,7 @@
 
     @VisibleForTesting
     static final String STATE_CONDITION_EXPANDED = "condition_expanded";
-    static final String META_DATA_PREFERENCE_ICON_BACKGROUND_ARGB = "com.android.settings.bg.argb";
+
     private final IconCache mCache;
     private final Context mContext;
     private final MetricsFeatureProvider mMetricsFeatureProvider;
@@ -247,10 +246,6 @@
         return mDashboardData.getItemEntityById(itemId);
     }
 
-    public Suggestion getSuggestion(int position) {
-        return mSuggestionAdapter.getSuggestion(position);
-    }
-
     @VisibleForTesting
     void notifyDashboardDataChanged(DashboardData prevData) {
         if (mFirstFrameDrawn && prevData != null) {
@@ -321,31 +316,7 @@
         if (!TextUtils.equals(tileIcon.getResPackage(), mContext.getPackageName())
                 && !(icon instanceof RoundedHomepageIcon)) {
             icon = new RoundedHomepageIcon(mContext, icon);
-            final Bundle metaData = tile.getMetaData();
-            try {
-                if (metaData != null) {
-                    // Load from bg.argb first
-                    int bgColor = metaData.getInt(META_DATA_PREFERENCE_ICON_BACKGROUND_ARGB,
-                            0 /* default */);
-                    // Not found, load from bg.hint
-                    if (bgColor == 0) {
-                        final int colorRes = metaData.getInt(
-                                TileUtils.META_DATA_PREFERENCE_ICON_BACKGROUND_HINT,
-                                0 /* default */);
-                        if (colorRes != 0) {
-                            bgColor = mContext.getPackageManager()
-                                    .getResourcesForApplication(tileIcon.getResPackage())
-                                    .getColor(colorRes, null /* theme */);
-                        }
-                    }
-                    // If found anything, use it.
-                    if (bgColor != 0) {
-                        ((RoundedHomepageIcon) icon).setBackgroundColor(bgColor);
-                    }
-                }
-            } catch (PackageManager.NameNotFoundException e) {
-                Log.e(TAG, "Failed to set background color for " + tile.getPackageName());
-            }
+            ((RoundedHomepageIcon) icon).setBackgroundColor(mContext, tile);
             mCache.updateIcon(tileIcon, icon);
         }
         holder.icon.setImageDrawable(icon);
diff --git a/src/com/android/settings/dashboard/DashboardData.java b/src/com/android/settings/dashboard/DashboardData.java
index 182d79b..9716ae0 100644
--- a/src/com/android/settings/dashboard/DashboardData.java
+++ b/src/com/android/settings/dashboard/DashboardData.java
@@ -24,7 +24,7 @@
 import androidx.recyclerview.widget.DiffUtil;
 
 import com.android.settings.R;
-import com.android.settings.dashboard.conditional.Condition;
+import com.android.settings.homepage.conditional.Condition;
 import com.android.settingslib.drawer.DashboardCategory;
 import com.android.settingslib.drawer.Tile;
 
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProvider.java b/src/com/android/settings/dashboard/DashboardFeatureProvider.java
index ac11e0b..81fb99e 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProvider.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProvider.java
@@ -15,8 +15,6 @@
  */
 package com.android.settings.dashboard;
 
-import android.content.Context;
-
 import androidx.fragment.app.FragmentActivity;
 import androidx.preference.Preference;
 
@@ -36,34 +34,11 @@
     DashboardCategory getTilesForCategory(String key);
 
     /**
-     * Get tiles (wrapped as a list of Preference) for key defined in CategoryKey.
-     *
-     * @param activity Activity hosting the preference
-     * @param context UI context to inflate preference
-     * @param sourceMetricsCategory The context (source) from which an action is performed
-     * @param key Value from CategoryKey
-     * @deprecated Pages implementing {@code DashboardFragment} should use
-     * {@link #getTilesForCategory(String)} instead. Using this method will not get the benefit
-     * of auto-ordering, progressive disclosure, auto-refreshing summary text etc.
-     */
-    @Deprecated
-    List<Preference> getPreferencesForCategory(FragmentActivity activity, Context context,
-            int sourceMetricsCategory, String key);
-
-    /**
      * Get all tiles, grouped by category.
      */
     List<DashboardCategory> getAllCategories();
 
     /**
-     * Whether or not we should tint icons in setting pages.
-     *
-     * @deprecated in favor of color icons in homepage
-     */
-    @Deprecated
-    boolean shouldTintIcon();
-
-    /**
      * Returns an unique string key for the tile.
      */
     String getDashboardKeyForTile(Tile tile);
@@ -72,6 +47,7 @@
      * Binds preference to data provided by tile.
      *
      * @param activity If tile contains intent to launch, it will be launched from this activity
+     * @param forceRoundedIcon Whether or not injected tiles from other packages should be forced to rounded icon.
      * @param sourceMetricsCategory The context (source) from which an action is performed
      * @param pref The preference to bind data
      * @param tile The binding data
@@ -79,8 +55,8 @@
      * @param baseOrder The order offset value. When binding, pref's order is determined by
      * both this value and tile's own priority.
      */
-    void bindPreferenceToTile(FragmentActivity activity, int sourceMetricsCategory, Preference pref,
-            Tile tile, String key, int baseOrder);
+    void bindPreferenceToTile(FragmentActivity activity, boolean forceRoundedIcon,
+            int sourceMetricsCategory, Preference pref, Tile tile, String key, int baseOrder);
 
     /**
      * Returns additional intent filter action for dashboard tiles
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index e4dd7a6..7c65936 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -25,6 +25,7 @@
 import android.content.IContentProvider;
 import android.content.Intent;
 import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
 import android.graphics.drawable.Icon;
 import android.os.Bundle;
 import android.provider.Settings;
@@ -42,6 +43,7 @@
 import com.android.settings.SettingsActivity;
 import com.android.settings.dashboard.profileselector.ProfileSelectDialog;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.widget.RoundedHomepageIcon;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
 import com.android.settingslib.drawer.DashboardCategory;
@@ -49,7 +51,6 @@
 import com.android.settingslib.drawer.TileUtils;
 import com.android.settingslib.utils.ThreadUtils;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -81,39 +82,11 @@
     }
 
     @Override
-    public List<Preference> getPreferencesForCategory(FragmentActivity activity, Context context,
-            int sourceMetricsCategory, String key) {
-        final DashboardCategory category = getTilesForCategory(key);
-        if (category == null) {
-            Log.d(TAG, "NO dashboard tiles for " + TAG);
-            return null;
-        }
-        final List<Tile> tiles = category.getTiles();
-        if (tiles == null || tiles.isEmpty()) {
-            Log.d(TAG, "tile list is empty, skipping category " + category.key);
-            return null;
-        }
-        final List<Preference> preferences = new ArrayList<>();
-        for (Tile tile : tiles) {
-            final Preference pref = new Preference(context);
-            bindPreferenceToTile(activity, sourceMetricsCategory, pref, tile, null /* key */,
-                    Preference.DEFAULT_ORDER /* baseOrder */);
-            preferences.add(pref);
-        }
-        return preferences;
-    }
-
-    @Override
     public List<DashboardCategory> getAllCategories() {
         return mCategoryManager.getCategories(mContext);
     }
 
     @Override
-    public boolean shouldTintIcon() {
-        return mContext.getResources().getBoolean(R.bool.config_tintSettingIcon);
-    }
-
-    @Override
     public String getDashboardKeyForTile(Tile tile) {
         if (tile == null) {
             return null;
@@ -128,8 +101,8 @@
     }
 
     @Override
-    public void bindPreferenceToTile(FragmentActivity activity, int sourceMetricsCategory,
-            Preference pref, Tile tile, String key, int baseOrder) {
+    public void bindPreferenceToTile(FragmentActivity activity, boolean forceRoundedIcon,
+            int sourceMetricsCategory, Preference pref, Tile tile, String key, int baseOrder) {
         if (pref == null) {
             return;
         }
@@ -140,7 +113,7 @@
             pref.setKey(getDashboardKeyForTile(tile));
         }
         bindSummary(pref, tile);
-        bindIcon(pref, tile);
+        bindIcon(pref, tile, forceRoundedIcon);
         final Bundle metadata = tile.getMetaData();
         String clsName = null;
         String action = null;
@@ -220,10 +193,16 @@
     }
 
     @VisibleForTesting
-    void bindIcon(Preference preference, Tile tile) {
+    void bindIcon(Preference preference, Tile tile, boolean forceRoundedIcon) {
         final Icon tileIcon = tile.getIcon(mContext);
         if (tileIcon != null) {
-            preference.setIcon(tileIcon.loadDrawable(preference.getContext()));
+            Drawable iconDrawable = tileIcon.loadDrawable(preference.getContext());
+            if (forceRoundedIcon
+                    && !TextUtils.equals(mContext.getPackageName(), tile.getPackageName())) {
+                iconDrawable = new RoundedHomepageIcon(mContext, iconDrawable);
+                ((RoundedHomepageIcon) iconDrawable).setBackgroundColor(mContext, tile);
+            }
+            preference.setIcon(iconDrawable);
         } else if (tile.getMetaData() != null
                 && tile.getMetaData().containsKey(META_DATA_PREFERENCE_ICON_URI)) {
             ThreadUtils.postOnBackgroundThread(() -> {
diff --git a/src/com/android/settings/dashboard/DashboardFragment.java b/src/com/android/settings/dashboard/DashboardFragment.java
index acf885d..a90950e 100644
--- a/src/com/android/settings/dashboard/DashboardFragment.java
+++ b/src/com/android/settings/dashboard/DashboardFragment.java
@@ -207,6 +207,10 @@
     @Override
     protected abstract int getPreferenceScreenResId();
 
+    protected boolean shouldForceRoundedIcon() {
+        return false;
+    }
+
     protected <T extends AbstractPreferenceController> T use(Class<T> clazz) {
         List<AbstractPreferenceController> controllerList = mPreferenceControllers.get(clazz);
         if (controllerList != null) {
@@ -343,6 +347,7 @@
         final int tintColor = a.getColor(0, context.getColor(android.R.color.white));
         a.recycle();
         // Install dashboard tiles.
+        final boolean forceRoundedIcons = shouldForceRoundedIcon();
         for (Tile tile : tiles) {
             final String key = mDashboardFeatureProvider.getDashboardKeyForTile(tile);
             if (TextUtils.isEmpty(key)) {
@@ -361,13 +366,15 @@
             if (mDashboardTilePrefKeys.contains(key)) {
                 // Have the key already, will rebind.
                 final Preference preference = screen.findPreference(key);
-                mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), getMetricsCategory(),
-                        preference, tile, key, mPlaceholderPreferenceController.getOrder());
+                mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), forceRoundedIcons,
+                        getMetricsCategory(), preference, tile, key,
+                        mPlaceholderPreferenceController.getOrder());
             } else {
                 // Don't have this key, add it.
                 final Preference pref = new Preference(getPrefContext());
-                mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), getMetricsCategory(),
-                        pref, tile, key, mPlaceholderPreferenceController.getOrder());
+                mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), forceRoundedIcons,
+                        getMetricsCategory(), pref, tile, key,
+                        mPlaceholderPreferenceController.getOrder());
                 screen.addPreference(pref);
                 mDashboardTilePrefKeys.add(key);
             }
diff --git a/src/com/android/settings/dashboard/DashboardFragmentRegistry.java b/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
index cd478fc..f5330a7 100644
--- a/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
+++ b/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
@@ -30,6 +30,7 @@
 import com.android.settings.display.NightDisplaySettings;
 import com.android.settings.fuelgauge.PowerUsageSummary;
 import com.android.settings.gestures.GestureSettings;
+import com.android.settings.homepage.TopLevelSettings;
 import com.android.settings.language.LanguageAndInputSettings;
 import com.android.settings.network.NetworkDashboardFragment;
 import com.android.settings.notification.ConfigureNotificationSettings;
@@ -61,6 +62,9 @@
 
     static {
         PARENT_TO_CATEGORY_KEY_MAP = new ArrayMap<>();
+        // TODO(b/110405144): Add the mapping when IA.homepage intent-filter is  is removed.
+        //        PARENT_TO_CATEGORY_KEY_MAP.put(TopLevelSettings.class.getName(),
+        //                CategoryKey.CATEGORY_HOMEPAGE);
         PARENT_TO_CATEGORY_KEY_MAP.put(
                 NetworkDashboardFragment.class.getName(), CategoryKey.CATEGORY_NETWORK);
         PARENT_TO_CATEGORY_KEY_MAP.put(ConnectedDeviceDashboardFragment.class.getName(),
@@ -98,9 +102,9 @@
         PARENT_TO_CATEGORY_KEY_MAP.put(ZenModeSettings.class.getName(),
                 CategoryKey.CATEGORY_DO_NOT_DISTURB);
         PARENT_TO_CATEGORY_KEY_MAP.put(GestureSettings.class.getName(),
-            CategoryKey.CATEGORY_GESTURES);
+                CategoryKey.CATEGORY_GESTURES);
         PARENT_TO_CATEGORY_KEY_MAP.put(NightDisplaySettings.class.getName(),
-            CategoryKey.CATEGORY_NIGHT_DISPLAY);
+                CategoryKey.CATEGORY_NIGHT_DISPLAY);
 
         CATEGORY_KEY_TO_PARENT_MAP = new ArrayMap<>(PARENT_TO_CATEGORY_KEY_MAP.size());
 
diff --git a/src/com/android/settings/dashboard/DashboardSummary.java b/src/com/android/settings/dashboard/DashboardSummary.java
index c6b69e9..d7595bf 100644
--- a/src/com/android/settings/dashboard/DashboardSummary.java
+++ b/src/com/android/settings/dashboard/DashboardSummary.java
@@ -26,17 +26,22 @@
 import android.view.View;
 import android.view.ViewGroup;
 
+import androidx.annotation.VisibleForTesting;
+import androidx.annotation.WorkerThread;
+import androidx.loader.app.LoaderManager;
+import androidx.recyclerview.widget.LinearLayoutManager;
+
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.core.InstrumentedFragment;
 import com.android.settings.core.SettingsBaseActivity;
 import com.android.settings.core.SettingsBaseActivity.CategoryListener;
-import com.android.settings.dashboard.conditional.Condition;
-import com.android.settings.dashboard.conditional.ConditionManager;
-import com.android.settings.dashboard.conditional.ConditionManager.ConditionListener;
-import com.android.settings.dashboard.conditional.FocusRecyclerView;
-import com.android.settings.dashboard.conditional.FocusRecyclerView.FocusListener;
 import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
+import com.android.settings.homepage.conditional.Condition;
+import com.android.settings.homepage.conditional.ConditionManager;
+import com.android.settings.homepage.conditional.ConditionListener;
+import com.android.settings.homepage.conditional.FocusRecyclerView;
+import com.android.settings.homepage.conditional.FocusRecyclerView.FocusListener;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.widget.ActionBarShadowController;
 import com.android.settingslib.drawer.CategoryKey;
@@ -46,11 +51,12 @@
 
 import java.util.List;
 
-import androidx.annotation.VisibleForTesting;
-import androidx.annotation.WorkerThread;
-import androidx.loader.app.LoaderManager;
-import androidx.recyclerview.widget.LinearLayoutManager;
-
+/**
+ * Deprecated in favor of {@link com.android.settings.homepage.TopLevelSettings}
+ *
+ * @deprecated
+ */
+@Deprecated
 public class DashboardSummary extends InstrumentedFragment
         implements CategoryListener, ConditionListener,
         FocusListener, SuggestionControllerMixinCompat.SuggestionControllerHost {
diff --git a/src/com/android/settings/dashboard/RoundedHomepageIcon.java b/src/com/android/settings/dashboard/RoundedHomepageIcon.java
deleted file mode 100644
index 9848034..0000000
--- a/src/com/android/settings/dashboard/RoundedHomepageIcon.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.dashboard;
-
-import static androidx.annotation.VisibleForTesting.NONE;
-
-import android.content.Context;
-import android.graphics.PorterDuff;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.LayerDrawable;
-import android.util.Log;
-
-import com.android.settings.R;
-
-import androidx.annotation.VisibleForTesting;
-
-public class RoundedHomepageIcon extends LayerDrawable {
-
-    private static final String TAG = "RoundedHomepageIcon";
-
-    @VisibleForTesting(otherwise = NONE)
-    int mBackgroundColor = -1;
-
-    public RoundedHomepageIcon(Context context, Drawable foreground) {
-        super(new Drawable[] {
-                context.getDrawable(R.drawable.ic_homepage_generic_background),
-                foreground
-        });
-        final int insetPx = context.getResources()
-                .getDimensionPixelSize(R.dimen.dashboard_tile_foreground_image_inset);
-        setLayerInset(1 /* index */, insetPx, insetPx, insetPx, insetPx);
-    }
-
-    public void setBackgroundColor(int color) {
-        mBackgroundColor = color;
-        getDrawable(0).setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
-        Log.d(TAG, "Setting background color " + mBackgroundColor);
-    }
-}
diff --git a/src/com/android/settings/dashboard/SummaryLoader.java b/src/com/android/settings/dashboard/SummaryLoader.java
index c85aad7..199331d 100644
--- a/src/com/android/settings/dashboard/SummaryLoader.java
+++ b/src/com/android/settings/dashboard/SummaryLoader.java
@@ -42,12 +42,6 @@
 import java.lang.reflect.Field;
 import java.util.List;
 
-/**
- * TODO(b/110405144): Remove this when all top level settings are converted to PreferenceControllers
- *
- * @deprecated
- */
-@Deprecated
 public class SummaryLoader {
     private static final boolean DEBUG = DashboardSummary.DEBUG;
     private static final String TAG = "SummaryLoader";
diff --git a/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java b/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java
new file mode 100644
index 0000000..c6fc23b
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java
@@ -0,0 +1,57 @@
+/*
+ * 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.deviceinfo;
+
+import android.content.Context;
+import android.os.storage.StorageManager;
+import android.text.format.Formatter;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.deviceinfo.PrivateStorageInfo;
+import com.android.settingslib.deviceinfo.StorageManagerVolumeProvider;
+
+import java.text.NumberFormat;
+
+public class TopLevelStoragePreferenceController extends BasePreferenceController {
+
+    private final StorageManager mStorageManager;
+    private final StorageManagerVolumeProvider mStorageManagerVolumeProvider;
+
+    public TopLevelStoragePreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+        mStorageManager = mContext.getSystemService(StorageManager.class);
+        mStorageManagerVolumeProvider = new StorageManagerVolumeProvider(mStorageManager);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE_UNSEARCHABLE;
+    }
+
+    @Override
+    public CharSequence getSummary() {
+        // TODO: Register listener.
+        final NumberFormat percentageFormat = NumberFormat.getPercentInstance();
+        final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(
+                mStorageManagerVolumeProvider);
+        double privateUsedBytes = info.totalBytes - info.freeBytes;
+        return mContext.getString(R.string.storage_summary,
+                percentageFormat.format(privateUsedBytes / info.totalBytes),
+                Formatter.formatFileSize(mContext, info.freeBytes));
+    }
+}
diff --git a/src/com/android/settings/flashlight/FlashlightSliceBuilder.java b/src/com/android/settings/flashlight/FlashlightSliceBuilder.java
index a689fd2..d4309ca 100644
--- a/src/com/android/settings/flashlight/FlashlightSliceBuilder.java
+++ b/src/com/android/settings/flashlight/FlashlightSliceBuilder.java
@@ -42,6 +42,7 @@
 import androidx.core.graphics.drawable.IconCompat;
 import androidx.slice.Slice;
 import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.ListBuilder.RowBuilder;
 import androidx.slice.builders.SliceAction;
 
 
@@ -93,7 +94,7 @@
                 IconCompat.createWithResource(context, R.drawable.ic_signal_flashlight);
         return new ListBuilder(context, FLASHLIGHT_URI, ListBuilder.INFINITY)
             .setAccentColor(color)
-            .addRow(b -> b
+            .addRow(new RowBuilder()
                 .setTitle(context.getText(R.string.power_flashlight))
                 .setTitleItem(icon, ICON_IMAGE)
                 .setPrimaryAction(
diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java
deleted file mode 100644
index e442a07..0000000
--- a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java
+++ /dev/null
@@ -1,1366 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.ColorStateList;
-import android.content.res.TypedArray;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.DashPathEffect;
-import android.graphics.Paint;
-import android.graphics.Path;
-import android.graphics.Typeface;
-import android.os.BatteryStats;
-import android.os.BatteryStats.HistoryItem;
-import android.os.SystemClock;
-import android.telephony.ServiceState;
-import android.text.TextPaint;
-import android.text.format.DateFormat;
-import android.text.format.Formatter;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.util.TimeUtils;
-import android.util.TypedValue;
-import android.view.View;
-
-import com.android.settings.R;
-import com.android.settings.Utils;
-
-import libcore.icu.LocaleData;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Locale;
-
-public class BatteryHistoryChart extends View {
-    static final boolean DEBUG = false;
-    static final String TAG = "BatteryHistoryChart";
-
-    static final int CHART_DATA_X_MASK = 0x0000ffff;
-    static final int CHART_DATA_BIN_MASK = 0xffff0000;
-    static final int CHART_DATA_BIN_SHIFT = 16;
-
-    static class ChartData {
-        int[] mColors;
-        Paint[] mPaints;
-
-        int mNumTicks;
-        int[] mTicks;
-        int mLastBin;
-
-        void setColors(int[] colors) {
-            mColors = colors;
-            mPaints = new Paint[colors.length];
-            for (int i=0; i<colors.length; i++) {
-                mPaints[i] = new Paint();
-                mPaints[i].setColor(colors[i]);
-                mPaints[i].setStyle(Paint.Style.FILL);
-            }
-        }
-
-        void init(int width) {
-            if (width > 0) {
-                mTicks = new int[width*2];
-            } else {
-                mTicks = null;
-            }
-            mNumTicks = 0;
-            mLastBin = 0;
-        }
-
-        void addTick(int x, int bin) {
-            if (bin != mLastBin && mNumTicks < mTicks.length) {
-                mTicks[mNumTicks] = (x&CHART_DATA_X_MASK) | (bin<<CHART_DATA_BIN_SHIFT);
-                mNumTicks++;
-                mLastBin = bin;
-            }
-        }
-
-        void finish(int width) {
-            if (mLastBin != 0) {
-                addTick(width, 0);
-            }
-        }
-
-        void draw(Canvas canvas, int top, int height) {
-            int lastBin=0, lastX=0;
-            int bottom = top + height;
-            for (int i=0; i<mNumTicks; i++) {
-                int tick = mTicks[i];
-                int x = tick&CHART_DATA_X_MASK;
-                int bin = (tick&CHART_DATA_BIN_MASK) >> CHART_DATA_BIN_SHIFT;
-                if (lastBin != 0) {
-                    canvas.drawRect(lastX, top, x, bottom, mPaints[lastBin]);
-                }
-                lastBin = bin;
-                lastX = x;
-            }
-
-        }
-    }
-
-    static final int SANS = 1;
-    static final int SERIF = 2;
-    static final int MONOSPACE = 3;
-
-    // First value if for phone off; first value is "scanning"; following values
-    // are battery stats signal strength buckets.
-    static final int NUM_PHONE_SIGNALS = 7;
-
-    final Paint mBatteryBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
-    final Paint mBatteryGoodPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
-    final Paint mBatteryWarnPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
-    final Paint mBatteryCriticalPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
-    final Paint mTimeRemainPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
-    final Paint mChargingPaint = new Paint();
-    final Paint mScreenOnPaint = new Paint();
-    final Paint mGpsOnPaint = new Paint();
-    final Paint mFlashlightOnPaint = new Paint();
-    final Paint mCameraOnPaint = new Paint();
-    final Paint mWifiRunningPaint = new Paint();
-    final Paint mCpuRunningPaint = new Paint();
-    final Paint mDateLinePaint = new Paint();
-    final ChartData mPhoneSignalChart = new ChartData();
-    final TextPaint mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
-    final TextPaint mHeaderTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
-    final Paint mDebugRectPaint = new Paint();
-
-    final Path mBatLevelPath = new Path();
-    final Path mBatGoodPath = new Path();
-    final Path mBatWarnPath = new Path();
-    final Path mBatCriticalPath = new Path();
-    final Path mTimeRemainPath = new Path();
-    final Path mChargingPath = new Path();
-    final Path mScreenOnPath = new Path();
-    final Path mGpsOnPath = new Path();
-    final Path mFlashlightOnPath = new Path();
-    final Path mCameraOnPath = new Path();
-    final Path mWifiRunningPath = new Path();
-    final Path mCpuRunningPath = new Path();
-    final Path mDateLinePath = new Path();
-
-    BatteryStats mStats;
-    Intent mBatteryBroadcast;
-    long mStatsPeriod;
-    String mMaxPercentLabelString;
-    String mMinPercentLabelString;
-    String mDurationString;
-    String mChargeDurationString;
-    String mDrainString;
-    String mChargingLabel;
-    String mScreenOnLabel;
-    String mGpsOnLabel;
-    String mCameraOnLabel;
-    String mFlashlightOnLabel;
-    String mWifiRunningLabel;
-    String mCpuRunningLabel;
-    String mPhoneSignalLabel;
-
-    BatteryInfo mInfo;
-
-    int mChartMinHeight;
-    int mHeaderHeight;
-
-    int mBatteryWarnLevel;
-    int mBatteryCriticalLevel;
-
-    int mTextAscent;
-    int mTextDescent;
-    int mHeaderTextAscent;
-    int mHeaderTextDescent;
-    int mMaxPercentLabelStringWidth;
-    int mMinPercentLabelStringWidth;
-    int mDurationStringWidth;
-    int mChargeLabelStringWidth;
-    int mChargeDurationStringWidth;
-    int mDrainStringWidth;
-
-    boolean mLargeMode;
-
-    int mLastWidth = -1;
-    int mLastHeight = -1;
-
-    int mLineWidth;
-    int mThinLineWidth;
-    int mChargingOffset;
-    int mScreenOnOffset;
-    int mGpsOnOffset;
-    int mFlashlightOnOffset;
-    int mCameraOnOffset;
-    int mWifiRunningOffset;
-    int mCpuRunningOffset;
-    int mPhoneSignalOffset;
-    int mLevelOffset;
-    int mLevelTop;
-    int mLevelBottom;
-    int mLevelLeft;
-    int mLevelRight;
-
-    int mNumHist;
-    long mHistStart;
-    long mHistDataEnd;
-    long mHistEnd;
-    long mStartWallTime;
-    long mEndDataWallTime;
-    long mEndWallTime;
-    int mBatLow;
-    int mBatHigh;
-    boolean mHaveWifi;
-    boolean mHaveGps;
-    boolean mHavePhoneSignal;
-    boolean mHaveCamera;
-    boolean mHaveFlashlight;
-
-    final ArrayList<TimeLabel> mTimeLabels = new ArrayList<TimeLabel>();
-    final ArrayList<DateLabel> mDateLabels = new ArrayList<DateLabel>();
-
-    Bitmap mBitmap;
-    Canvas mCanvas;
-
-    static class TextAttrs {
-        ColorStateList textColor = null;
-        int textSize = 15;
-        int typefaceIndex = -1;
-        int styleIndex = -1;
-
-        void retrieve(Context context, TypedArray from, int index) {
-            TypedArray appearance = null;
-            int ap = from.getResourceId(index, -1);
-            if (ap != -1) {
-                appearance = context.obtainStyledAttributes(ap,
-                                    com.android.internal.R.styleable.TextAppearance);
-            }
-            if (appearance != null) {
-                int n = appearance.getIndexCount();
-                for (int i = 0; i < n; i++) {
-                    int attr = appearance.getIndex(i);
-
-                    switch (attr) {
-                    case com.android.internal.R.styleable.TextAppearance_textColor:
-                        textColor = appearance.getColorStateList(attr);
-                        break;
-
-                    case com.android.internal.R.styleable.TextAppearance_textSize:
-                        textSize = appearance.getDimensionPixelSize(attr, textSize);
-                        break;
-
-                    case com.android.internal.R.styleable.TextAppearance_typeface:
-                        typefaceIndex = appearance.getInt(attr, -1);
-                        break;
-
-                    case com.android.internal.R.styleable.TextAppearance_textStyle:
-                        styleIndex = appearance.getInt(attr, -1);
-                        break;
-                    }
-                }
-
-                appearance.recycle();
-            }
-        }
-
-        void apply(Context context, TextPaint paint) {
-            paint.density = context.getResources().getDisplayMetrics().density;
-            paint.setCompatibilityScaling(
-                    context.getResources().getCompatibilityInfo().applicationScale);
-
-            paint.setColor(textColor.getDefaultColor());
-            paint.setTextSize(textSize);
-
-            Typeface tf = null;
-            switch (typefaceIndex) {
-                case SANS:
-                    tf = Typeface.SANS_SERIF;
-                    break;
-
-                case SERIF:
-                    tf = Typeface.SERIF;
-                    break;
-
-                case MONOSPACE:
-                    tf = Typeface.MONOSPACE;
-                    break;
-            }
-
-            setTypeface(paint, tf, styleIndex);
-        }
-
-        public void setTypeface(TextPaint paint, Typeface tf, int style) {
-            if (style > 0) {
-                if (tf == null) {
-                    tf = Typeface.defaultFromStyle(style);
-                } else {
-                    tf = Typeface.create(tf, style);
-                }
-
-                paint.setTypeface(tf);
-                // now compute what (if any) algorithmic styling is needed
-                int typefaceStyle = tf != null ? tf.getStyle() : 0;
-                int need = style & ~typefaceStyle;
-                paint.setFakeBoldText((need & Typeface.BOLD) != 0);
-                paint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0);
-            } else {
-                paint.setFakeBoldText(false);
-                paint.setTextSkewX(0);
-                paint.setTypeface(tf);
-            }
-        }
-    }
-
-    static class TimeLabel {
-        final int x;
-        final String label;
-        final int width;
-
-        TimeLabel(TextPaint paint, int x, Calendar cal, boolean use24hr) {
-            this.x = x;
-            final String bestFormat = DateFormat.getBestDateTimePattern(
-                    Locale.getDefault(), use24hr ? "km" : "ha");
-            label = DateFormat.format(bestFormat, cal).toString();
-            width = (int)paint.measureText(label);
-        }
-    }
-
-    static class DateLabel {
-        final int x;
-        final String label;
-        final int width;
-
-        DateLabel(TextPaint paint, int x, Calendar cal, boolean dayFirst) {
-            this.x = x;
-            final String bestFormat = DateFormat.getBestDateTimePattern(
-                    Locale.getDefault(), dayFirst ? "dM" : "Md");
-            label = DateFormat.format(bestFormat, cal).toString();
-            width = (int)paint.measureText(label);
-        }
-    }
-
-    public BatteryHistoryChart(Context context, AttributeSet attrs) {
-        super(context, attrs);
-
-        if (DEBUG) Log.d(TAG, "New BatteryHistoryChart!");
-
-        mBatteryWarnLevel = mContext.getResources().getInteger(
-                com.android.internal.R.integer.config_lowBatteryWarningLevel);
-        mBatteryCriticalLevel = mContext.getResources().getInteger(
-                com.android.internal.R.integer.config_criticalBatteryWarningLevel);
-
-        mThinLineWidth = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
-                2, getResources().getDisplayMetrics());
-
-        int accentColor = Utils.getColorAccentDefaultColor(mContext);
-        mBatteryBackgroundPaint.setColor(accentColor);
-        mBatteryBackgroundPaint.setStyle(Paint.Style.FILL);
-        mBatteryGoodPaint.setARGB(128, 0, 128, 0);
-        mBatteryGoodPaint.setStyle(Paint.Style.STROKE);
-        mBatteryWarnPaint.setARGB(128, 128, 128, 0);
-        mBatteryWarnPaint.setStyle(Paint.Style.STROKE);
-        mBatteryCriticalPaint.setARGB(192, 128, 0, 0);
-        mBatteryCriticalPaint.setStyle(Paint.Style.STROKE);
-        mTimeRemainPaint.setColor(0xFFCED7BB);
-        mTimeRemainPaint.setStyle(Paint.Style.FILL);
-        mChargingPaint.setStyle(Paint.Style.STROKE);
-        mScreenOnPaint.setStyle(Paint.Style.STROKE);
-        mGpsOnPaint.setStyle(Paint.Style.STROKE);
-        mCameraOnPaint.setStyle(Paint.Style.STROKE);
-        mFlashlightOnPaint.setStyle(Paint.Style.STROKE);
-        mWifiRunningPaint.setStyle(Paint.Style.STROKE);
-        mCpuRunningPaint.setStyle(Paint.Style.STROKE);
-        mPhoneSignalChart.setColors(com.android.settings.Utils.BADNESS_COLORS);
-        mDebugRectPaint.setARGB(255, 255, 0, 0);
-        mDebugRectPaint.setStyle(Paint.Style.STROKE);
-        mScreenOnPaint.setColor(accentColor);
-        mGpsOnPaint.setColor(accentColor);
-        mCameraOnPaint.setColor(accentColor);
-        mFlashlightOnPaint.setColor(accentColor);
-        mWifiRunningPaint.setColor(accentColor);
-        mCpuRunningPaint.setColor(accentColor);
-        mChargingPaint.setColor(accentColor);
-
-        TypedArray a =
-            context.obtainStyledAttributes(
-                attrs, R.styleable.BatteryHistoryChart, 0, 0);
-
-        final TextAttrs mainTextAttrs = new TextAttrs();
-        final TextAttrs headTextAttrs = new TextAttrs();
-        mainTextAttrs.retrieve(context, a, R.styleable.BatteryHistoryChart_android_textAppearance);
-        headTextAttrs.retrieve(context, a, R.styleable.BatteryHistoryChart_headerAppearance);
-
-        int shadowcolor = 0;
-        float dx=0, dy=0, r=0;
-        
-        int n = a.getIndexCount();
-        for (int i = 0; i < n; i++) {
-            int attr = a.getIndex(i);
-
-            switch (attr) {
-                case R.styleable.BatteryHistoryChart_android_shadowColor:
-                    shadowcolor = a.getInt(attr, 0);
-                    break;
-
-                case R.styleable.BatteryHistoryChart_android_shadowDx:
-                    dx = a.getFloat(attr, 0);
-                    break;
-
-                case R.styleable.BatteryHistoryChart_android_shadowDy:
-                    dy = a.getFloat(attr, 0);
-                    break;
-
-                case R.styleable.BatteryHistoryChart_android_shadowRadius:
-                    r = a.getFloat(attr, 0);
-                    break;
-
-                case R.styleable.BatteryHistoryChart_android_textColor:
-                    mainTextAttrs.textColor = a.getColorStateList(attr);
-                    headTextAttrs.textColor = a.getColorStateList(attr);
-                    break;
-
-                case R.styleable.BatteryHistoryChart_android_textSize:
-                    mainTextAttrs.textSize = a.getDimensionPixelSize(attr, mainTextAttrs.textSize);
-                    headTextAttrs.textSize = a.getDimensionPixelSize(attr, headTextAttrs.textSize);
-                    break;
-
-                case R.styleable.BatteryHistoryChart_android_typeface:
-                    mainTextAttrs.typefaceIndex = a.getInt(attr, mainTextAttrs.typefaceIndex);
-                    headTextAttrs.typefaceIndex = a.getInt(attr, headTextAttrs.typefaceIndex);
-                    break;
-
-                case R.styleable.BatteryHistoryChart_android_textStyle:
-                    mainTextAttrs.styleIndex = a.getInt(attr, mainTextAttrs.styleIndex);
-                    headTextAttrs.styleIndex = a.getInt(attr, headTextAttrs.styleIndex);
-                    break;
-
-                case R.styleable.BatteryHistoryChart_barPrimaryColor:
-                    mBatteryBackgroundPaint.setColor(a.getInt(attr, 0));
-                    mScreenOnPaint.setColor(a.getInt(attr, 0));
-                    mGpsOnPaint.setColor(a.getInt(attr, 0));
-                    mCameraOnPaint.setColor(a.getInt(attr, 0));
-                    mFlashlightOnPaint.setColor(a.getInt(attr, 0));
-                    mWifiRunningPaint.setColor(a.getInt(attr, 0));
-                    mCpuRunningPaint.setColor(a.getInt(attr, 0));
-                    mChargingPaint.setColor(a.getInt(attr, 0));
-                    break;
-
-                case R.styleable.BatteryHistoryChart_barPredictionColor:
-                    mTimeRemainPaint.setColor(a.getInt(attr, 0));
-                    break;
-
-                case R.styleable.BatteryHistoryChart_chartMinHeight:
-                    mChartMinHeight = a.getDimensionPixelSize(attr, 0);
-                    break;
-            }
-        }
-        
-        a.recycle();
-        
-        mainTextAttrs.apply(context, mTextPaint);
-        headTextAttrs.apply(context, mHeaderTextPaint);
-
-        mDateLinePaint.set(mTextPaint);
-        mDateLinePaint.setStyle(Paint.Style.STROKE);
-        int hairlineWidth = mThinLineWidth/2;
-        if (hairlineWidth < 1) {
-            hairlineWidth = 1;
-        }
-        mDateLinePaint.setStrokeWidth(hairlineWidth);
-        mDateLinePaint.setPathEffect(new DashPathEffect(new float[] {
-                mThinLineWidth * 2, mThinLineWidth * 2 }, 0));
-
-        if (shadowcolor != 0) {
-            mTextPaint.setShadowLayer(r, dx, dy, shadowcolor);
-            mHeaderTextPaint.setShadowLayer(r, dx, dy, shadowcolor);
-        }
-    }
-
-    void setStats(BatteryStats stats, Intent broadcast) {
-        mStats = stats;
-        mBatteryBroadcast = broadcast;
-
-        if (DEBUG) Log.d(TAG, "Setting stats...");
-
-        final long elapsedRealtimeUs = SystemClock.elapsedRealtime() * 1000;
-
-        long uSecTime = mStats.computeBatteryRealtime(elapsedRealtimeUs,
-                BatteryStats.STATS_SINCE_CHARGED);
-        mStatsPeriod = uSecTime;
-        mChargingLabel = getContext().getString(R.string.battery_stats_charging_label);
-        mScreenOnLabel = getContext().getString(R.string.battery_stats_screen_on_label);
-        mGpsOnLabel = getContext().getString(R.string.battery_stats_gps_on_label);
-        mCameraOnLabel = getContext().getString(R.string.battery_stats_camera_on_label);
-        mFlashlightOnLabel = getContext().getString(R.string.battery_stats_flashlight_on_label);
-        mWifiRunningLabel = getContext().getString(R.string.battery_stats_wifi_running_label);
-        mCpuRunningLabel = getContext().getString(R.string.battery_stats_wake_lock_label);
-        mPhoneSignalLabel = getContext().getString(R.string.battery_stats_phone_signal_label);
-
-        mMaxPercentLabelString = Utils.formatPercentage(100);
-        mMinPercentLabelString = Utils.formatPercentage(0);
-        BatteryInfo.getBatteryInfo(getContext(), info -> {
-            mInfo = info;
-            mDrainString = "";
-            mChargeDurationString = "";
-            setContentDescription(mInfo.chargeLabel);
-
-            int pos = 0;
-            int lastInteresting = 0;
-            byte lastLevel = -1;
-            mBatLow = 0;
-            mBatHigh = 100;
-            mStartWallTime = 0;
-            mEndDataWallTime = 0;
-            mEndWallTime = 0;
-            mHistStart = 0;
-            mHistEnd = 0;
-            long lastWallTime = 0;
-            long lastRealtime = 0;
-            int aggrStates = 0;
-            int aggrStates2 = 0;
-            boolean first = true;
-            if (stats.startIteratingHistoryLocked()) {
-                final HistoryItem rec = new HistoryItem();
-                while (stats.getNextHistoryLocked(rec)) {
-                    pos++;
-                    if (first) {
-                        first = false;
-                        mHistStart = rec.time;
-                    }
-                    if (rec.cmd == HistoryItem.CMD_CURRENT_TIME
-                            || rec.cmd == HistoryItem.CMD_RESET) {
-                        // If there is a ridiculously large jump in time, then we won't be
-                        // able to create a good chart with that data, so just ignore the
-                        // times we got before and pretend like our data extends back from
-                        // the time we have now.
-                        // Also, if we are getting a time change and we are less than 5 minutes
-                        // since the start of the history real time, then also use this new
-                        // time to compute the base time, since whatever time we had before is
-                        // pretty much just noise.
-                        if (rec.currentTime > (lastWallTime+(180*24*60*60*1000L))
-                                || rec.time < (mHistStart+(5*60*1000L))) {
-                            mStartWallTime = 0;
-                        }
-                        lastWallTime = rec.currentTime;
-                        lastRealtime = rec.time;
-                        if (mStartWallTime == 0) {
-                            mStartWallTime = lastWallTime - (lastRealtime-mHistStart);
-                        }
-                    }
-                    if (rec.isDeltaData()) {
-                        if (rec.batteryLevel != lastLevel || pos == 1) {
-                            lastLevel = rec.batteryLevel;
-                        }
-                        lastInteresting = pos;
-                        mHistDataEnd = rec.time;
-                        aggrStates |= rec.states;
-                        aggrStates2 |= rec.states2;
-                    }
-                }
-            }
-            mHistEnd = mHistDataEnd + (mInfo.remainingTimeUs/1000);
-            mEndDataWallTime = lastWallTime + mHistDataEnd - lastRealtime;
-            mEndWallTime = mEndDataWallTime + (mInfo.remainingTimeUs/1000);
-            mNumHist = lastInteresting;
-            mHaveGps = (aggrStates&HistoryItem.STATE_GPS_ON_FLAG) != 0;
-            mHaveFlashlight = (aggrStates2&HistoryItem.STATE2_FLASHLIGHT_FLAG) != 0;
-            mHaveCamera = (aggrStates2&HistoryItem.STATE2_CAMERA_FLAG) != 0;
-            mHaveWifi = (aggrStates2&HistoryItem.STATE2_WIFI_RUNNING_FLAG) != 0
-                    || (aggrStates&(HistoryItem.STATE_WIFI_FULL_LOCK_FLAG
-                    |HistoryItem.STATE_WIFI_MULTICAST_ON_FLAG
-                    |HistoryItem.STATE_WIFI_SCAN_FLAG)) != 0;
-            if (!com.android.settingslib.Utils.isWifiOnly(getContext())) {
-                mHavePhoneSignal = true;
-            }
-            if (mHistEnd <= mHistStart) mHistEnd = mHistStart+1;
-        }, mStats, false /* shortString */);
-    }
-
-    @Override
-    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        mMaxPercentLabelStringWidth = (int)mTextPaint.measureText(mMaxPercentLabelString);
-        mMinPercentLabelStringWidth = (int)mTextPaint.measureText(mMinPercentLabelString);
-        mDrainStringWidth = (int)mHeaderTextPaint.measureText(mDrainString);
-        mChargeLabelStringWidth = (int) mHeaderTextPaint.measureText(
-                mInfo.chargeLabel.toString());
-        mChargeDurationStringWidth = (int)mHeaderTextPaint.measureText(mChargeDurationString);
-        mTextAscent = (int)mTextPaint.ascent();
-        mTextDescent = (int)mTextPaint.descent();
-        mHeaderTextAscent = (int)mHeaderTextPaint.ascent();
-        mHeaderTextDescent = (int)mHeaderTextPaint.descent();
-        int headerTextHeight = mHeaderTextDescent - mHeaderTextAscent;
-        mHeaderHeight = headerTextHeight*2 - mTextAscent;
-        setMeasuredDimension(getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec),
-                getDefaultSize(mChartMinHeight+mHeaderHeight, heightMeasureSpec));
-    }
-
-    void finishPaths(int w, int h, int levelh, int startX, int y, Path curLevelPath,
-            int lastX, boolean lastCharging, boolean lastScreenOn, boolean lastGpsOn,
-            boolean lastFlashlightOn, boolean lastCameraOn, boolean lastWifiRunning,
-            boolean lastCpuRunning, Path lastPath) {
-        if (curLevelPath != null) {
-            if (lastX >= 0 && lastX < w) {
-                if (lastPath != null) {
-                    lastPath.lineTo(w, y);
-                }
-                curLevelPath.lineTo(w, y);
-            }
-            curLevelPath.lineTo(w, mLevelTop+levelh);
-            curLevelPath.lineTo(startX, mLevelTop+levelh);
-            curLevelPath.close();
-        }
-        
-        if (lastCharging) {
-            mChargingPath.lineTo(w, h-mChargingOffset);
-        }
-        if (lastScreenOn) {
-            mScreenOnPath.lineTo(w, h-mScreenOnOffset);
-        }
-        if (lastGpsOn) {
-            mGpsOnPath.lineTo(w, h-mGpsOnOffset);
-        }
-        if (lastFlashlightOn) {
-            mFlashlightOnPath.lineTo(w, h-mFlashlightOnOffset);
-        }
-        if (lastCameraOn) {
-            mCameraOnPath.lineTo(w, h-mCameraOnOffset);
-        }
-        if (lastWifiRunning) {
-            mWifiRunningPath.lineTo(w, h-mWifiRunningOffset);
-        }
-        if (lastCpuRunning) {
-            mCpuRunningPath.lineTo(w, h - mCpuRunningOffset);
-        }
-        if (mHavePhoneSignal) {
-            mPhoneSignalChart.finish(w);
-        }
-    }
-
-    private boolean is24Hour() {
-        return DateFormat.is24HourFormat(getContext());
-    }
-
-    private boolean isDayFirst() {
-        final String value = LocaleData.get(getResources().getConfiguration().locale)
-                .getDateFormat(java.text.DateFormat.SHORT);
-        return value.indexOf('M') > value.indexOf('d');
-    }
-
-    @Override
-    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
-        super.onSizeChanged(w, h, oldw, oldh);
-
-        if (DEBUG) Log.d(TAG, "onSizeChanged: " + oldw + "x" + oldh + " to " + w + "x" + h);
-
-        if (mLastWidth == w && mLastHeight == h) {
-            return;
-        }
-
-        if (mLastWidth == 0 || mLastHeight == 0) {
-            return;
-        }
-
-        if (DEBUG) Log.d(TAG, "Rebuilding chart for: " + w + "x" + h);
-
-        mLastWidth = w;
-        mLastHeight = h;
-        mBitmap = null;
-        mCanvas = null;
-
-        int textHeight = mTextDescent - mTextAscent;
-        if (h > ((textHeight*10)+mChartMinHeight)) {
-            mLargeMode = true;
-            if (h > (textHeight*15)) {
-                // Plenty of room for the chart.
-                mLineWidth = textHeight/2;
-            } else {
-                // Compress lines to make more room for chart.
-                mLineWidth = textHeight/3;
-            }
-        } else {
-            mLargeMode = false;
-            mLineWidth = mThinLineWidth;
-        }
-        if (mLineWidth <= 0) mLineWidth = 1;
-
-        mLevelTop = mHeaderHeight;
-        mLevelLeft = mMaxPercentLabelStringWidth + mThinLineWidth*3;
-        mLevelRight = w;
-        int levelWidth = mLevelRight-mLevelLeft;
-
-        mTextPaint.setStrokeWidth(mThinLineWidth);
-        mBatteryGoodPaint.setStrokeWidth(mThinLineWidth);
-        mBatteryWarnPaint.setStrokeWidth(mThinLineWidth);
-        mBatteryCriticalPaint.setStrokeWidth(mThinLineWidth);
-        mChargingPaint.setStrokeWidth(mLineWidth);
-        mScreenOnPaint.setStrokeWidth(mLineWidth);
-        mGpsOnPaint.setStrokeWidth(mLineWidth);
-        mCameraOnPaint.setStrokeWidth(mLineWidth);
-        mFlashlightOnPaint.setStrokeWidth(mLineWidth);
-        mWifiRunningPaint.setStrokeWidth(mLineWidth);
-        mCpuRunningPaint.setStrokeWidth(mLineWidth);
-        mDebugRectPaint.setStrokeWidth(1);
-
-        int fullBarOffset = textHeight + mLineWidth;
-
-        if (mLargeMode) {
-            mChargingOffset = mLineWidth;
-            mScreenOnOffset = mChargingOffset + fullBarOffset;
-            mCpuRunningOffset = mScreenOnOffset + fullBarOffset;
-            mWifiRunningOffset = mCpuRunningOffset + fullBarOffset;
-            mGpsOnOffset = mWifiRunningOffset + (mHaveWifi ? fullBarOffset : 0);
-            mFlashlightOnOffset = mGpsOnOffset + (mHaveGps ? fullBarOffset : 0);
-            mCameraOnOffset = mFlashlightOnOffset + (mHaveFlashlight ? fullBarOffset : 0);
-            mPhoneSignalOffset = mCameraOnOffset + (mHaveCamera ? fullBarOffset : 0);
-            mLevelOffset = mPhoneSignalOffset + (mHavePhoneSignal ? fullBarOffset : 0)
-                    + mLineWidth*2 + mLineWidth/2;
-            if (mHavePhoneSignal) {
-                mPhoneSignalChart.init(w);
-            }
-        } else {
-            mScreenOnOffset = mGpsOnOffset = mCameraOnOffset = mFlashlightOnOffset =
-                    mWifiRunningOffset = mCpuRunningOffset = mChargingOffset =
-                    mPhoneSignalOffset = 0;
-            mLevelOffset = fullBarOffset + mThinLineWidth*4;
-            if (mHavePhoneSignal) {
-                mPhoneSignalChart.init(0);
-            }
-        }
-
-        mBatLevelPath.reset();
-        mBatGoodPath.reset();
-        mBatWarnPath.reset();
-        mTimeRemainPath.reset();
-        mBatCriticalPath.reset();
-        mScreenOnPath.reset();
-        mGpsOnPath.reset();
-        mFlashlightOnPath.reset();
-        mCameraOnPath.reset();
-        mWifiRunningPath.reset();
-        mCpuRunningPath.reset();
-        mChargingPath.reset();
-
-        mTimeLabels.clear();
-        mDateLabels.clear();
-
-        final long walltimeStart = mStartWallTime;
-        final long walltimeChange = mEndWallTime > walltimeStart
-                ? (mEndWallTime-walltimeStart) : 1;
-        long curWalltime = mStartWallTime;
-        long lastRealtime = 0;
-
-        final int batLow = mBatLow;
-        final int batChange = mBatHigh-mBatLow;
-
-        final int levelh = h - mLevelOffset - mLevelTop;
-        mLevelBottom = mLevelTop + levelh;
-
-        int x = mLevelLeft, y = 0, startX = mLevelLeft, lastX = -1, lastY = -1;
-        int i = 0;
-        Path curLevelPath = null;
-        Path lastLinePath = null;
-        boolean lastCharging = false, lastScreenOn = false, lastGpsOn = false;
-        boolean lastFlashlightOn = false, lastCameraOn = false;
-        boolean lastWifiRunning = false, lastWifiSupplRunning = false, lastCpuRunning = false;
-        int lastWifiSupplState = BatteryStats.WIFI_SUPPL_STATE_INVALID;
-        final int N = mNumHist;
-        if (mEndDataWallTime > mStartWallTime && mStats.startIteratingHistoryLocked()) {
-            final HistoryItem rec = new HistoryItem();
-            while (mStats.getNextHistoryLocked(rec) && i < N) {
-                if (rec.isDeltaData()) {
-                    curWalltime += rec.time-lastRealtime;
-                    lastRealtime = rec.time;
-                    x = mLevelLeft + (int)(((curWalltime-walltimeStart)*levelWidth)/walltimeChange);
-                    if (x < 0) {
-                        x = 0;
-                    }
-                    if (false) {
-                        StringBuilder sb = new StringBuilder(128);
-                        sb.append("walloff=");
-                        TimeUtils.formatDuration(curWalltime - walltimeStart, sb);
-                        sb.append(" wallchange=");
-                        TimeUtils.formatDuration(walltimeChange, sb);
-                        sb.append(" x=");
-                        sb.append(x);
-                        Log.d("foo", sb.toString());
-                    }
-                    y = mLevelTop + levelh - ((rec.batteryLevel-batLow)*(levelh-1))/batChange;
-
-                    if (lastX != x) {
-                        // We have moved by at least a pixel.
-                        if (lastY != y) {
-                            // Don't plot changes within a pixel.
-                            Path path;
-                            byte value = rec.batteryLevel;
-                            if (value <= mBatteryCriticalLevel) path = mBatCriticalPath;
-                            else if (value <= mBatteryWarnLevel) path = mBatWarnPath;
-                            else path = null; //mBatGoodPath;
-
-                            if (path != lastLinePath) {
-                                if (lastLinePath != null) {
-                                    lastLinePath.lineTo(x, y);
-                                }
-                                if (path != null) {
-                                    path.moveTo(x, y);
-                                }
-                                lastLinePath = path;
-                            } else if (path != null) {
-                                path.lineTo(x, y);
-                            }
-
-                            if (curLevelPath == null) {
-                                curLevelPath = mBatLevelPath;
-                                curLevelPath.moveTo(x, y);
-                                startX = x;
-                            } else {
-                                curLevelPath.lineTo(x, y);
-                            }
-                            lastX = x;
-                            lastY = y;
-                        }
-                    }
-
-                    if (mLargeMode) {
-                        final boolean charging =
-                            (rec.states&HistoryItem.STATE_BATTERY_PLUGGED_FLAG) != 0;
-                        if (charging != lastCharging) {
-                            if (charging) {
-                                mChargingPath.moveTo(x, h-mChargingOffset);
-                            } else {
-                                mChargingPath.lineTo(x, h-mChargingOffset);
-                            }
-                            lastCharging = charging;
-                        }
-
-                        final boolean screenOn =
-                            (rec.states&HistoryItem.STATE_SCREEN_ON_FLAG) != 0;
-                        if (screenOn != lastScreenOn) {
-                            if (screenOn) {
-                                mScreenOnPath.moveTo(x, h-mScreenOnOffset);
-                            } else {
-                                mScreenOnPath.lineTo(x, h-mScreenOnOffset);
-                            }
-                            lastScreenOn = screenOn;
-                        }
-
-                        final boolean gpsOn =
-                            (rec.states&HistoryItem.STATE_GPS_ON_FLAG) != 0;
-                        if (gpsOn != lastGpsOn) {
-                            if (gpsOn) {
-                                mGpsOnPath.moveTo(x, h-mGpsOnOffset);
-                            } else {
-                                mGpsOnPath.lineTo(x, h-mGpsOnOffset);
-                            }
-                            lastGpsOn = gpsOn;
-                        }
-
-                        final boolean flashlightOn =
-                            (rec.states2&HistoryItem.STATE2_FLASHLIGHT_FLAG) != 0;
-                        if (flashlightOn != lastFlashlightOn) {
-                            if (flashlightOn) {
-                                mFlashlightOnPath.moveTo(x, h-mFlashlightOnOffset);
-                            } else {
-                                mFlashlightOnPath.lineTo(x, h-mFlashlightOnOffset);
-                            }
-                            lastFlashlightOn = flashlightOn;
-                        }
-
-                        final boolean cameraOn =
-                            (rec.states2&HistoryItem.STATE2_CAMERA_FLAG) != 0;
-                        if (cameraOn != lastCameraOn) {
-                            if (cameraOn) {
-                                mCameraOnPath.moveTo(x, h-mCameraOnOffset);
-                            } else {
-                                mCameraOnPath.lineTo(x, h-mCameraOnOffset);
-                            }
-                            lastCameraOn = cameraOn;
-                        }
-
-                        final int wifiSupplState =
-                            ((rec.states2&HistoryItem.STATE2_WIFI_SUPPL_STATE_MASK)
-                                    >> HistoryItem.STATE2_WIFI_SUPPL_STATE_SHIFT);
-                        boolean wifiRunning;
-                        if (lastWifiSupplState != wifiSupplState) {
-                            lastWifiSupplState = wifiSupplState;
-                            switch (wifiSupplState) {
-                                case BatteryStats.WIFI_SUPPL_STATE_DISCONNECTED:
-                                case BatteryStats.WIFI_SUPPL_STATE_DORMANT:
-                                case BatteryStats.WIFI_SUPPL_STATE_INACTIVE:
-                                case BatteryStats.WIFI_SUPPL_STATE_INTERFACE_DISABLED:
-                                case BatteryStats.WIFI_SUPPL_STATE_INVALID:
-                                case BatteryStats.WIFI_SUPPL_STATE_UNINITIALIZED:
-                                    wifiRunning = lastWifiSupplRunning = false;
-                                    break;
-                                default:
-                                    wifiRunning = lastWifiSupplRunning = true;
-                                    break;
-                            }
-                        } else {
-                            wifiRunning = lastWifiSupplRunning;
-                        }
-                        if ((rec.states&(HistoryItem.STATE_WIFI_FULL_LOCK_FLAG
-                                |HistoryItem.STATE_WIFI_MULTICAST_ON_FLAG
-                                |HistoryItem.STATE_WIFI_SCAN_FLAG)) != 0) {
-                            wifiRunning = true;
-                        }
-                        if (wifiRunning != lastWifiRunning) {
-                            if (wifiRunning) {
-                                mWifiRunningPath.moveTo(x, h-mWifiRunningOffset);
-                            } else {
-                                mWifiRunningPath.lineTo(x, h-mWifiRunningOffset);
-                            }
-                            lastWifiRunning = wifiRunning;
-                        }
-
-                        final boolean cpuRunning =
-                            (rec.states&HistoryItem.STATE_CPU_RUNNING_FLAG) != 0;
-                        if (cpuRunning != lastCpuRunning) {
-                            if (cpuRunning) {
-                                mCpuRunningPath.moveTo(x, h - mCpuRunningOffset);
-                            } else {
-                                mCpuRunningPath.lineTo(x, h - mCpuRunningOffset);
-                            }
-                            lastCpuRunning = cpuRunning;
-                        }
-
-                        if (mLargeMode && mHavePhoneSignal) {
-                            int bin;
-                            if (((rec.states&HistoryItem.STATE_PHONE_STATE_MASK)
-                                    >> HistoryItem.STATE_PHONE_STATE_SHIFT)
-                                    == ServiceState.STATE_POWER_OFF) {
-                                bin = 0;
-                            } else if ((rec.states&HistoryItem.STATE_PHONE_SCANNING_FLAG) != 0) {
-                                bin = 1;
-                            } else {
-                                bin = (rec.states&HistoryItem.STATE_PHONE_SIGNAL_STRENGTH_MASK)
-                                        >> HistoryItem.STATE_PHONE_SIGNAL_STRENGTH_SHIFT;
-                                bin += 2;
-                            }
-                            mPhoneSignalChart.addTick(x, bin);
-                        }
-                    }
-
-                } else {
-                    long lastWalltime = curWalltime;
-                    if (rec.cmd == HistoryItem.CMD_CURRENT_TIME
-                            || rec.cmd == HistoryItem.CMD_RESET) {
-                        if (rec.currentTime >= mStartWallTime) {
-                            curWalltime = rec.currentTime;
-                        } else {
-                            curWalltime = mStartWallTime + (rec.time-mHistStart);
-                        }
-                        lastRealtime = rec.time;
-                    }
-
-                    if (rec.cmd != HistoryItem.CMD_OVERFLOW
-                            && (rec.cmd != HistoryItem.CMD_CURRENT_TIME
-                                    || Math.abs(lastWalltime-curWalltime) > (60*60*1000))) {
-                        if (curLevelPath != null) {
-                            finishPaths(x+1, h, levelh, startX, lastY, curLevelPath, lastX,
-                                    lastCharging, lastScreenOn, lastGpsOn, lastFlashlightOn,
-                                    lastCameraOn, lastWifiRunning, lastCpuRunning, lastLinePath);
-                            lastX = lastY = -1;
-                            curLevelPath = null;
-                            lastLinePath = null;
-                            lastCharging = lastScreenOn = lastGpsOn = lastFlashlightOn =
-                                    lastCameraOn = lastCpuRunning = false;
-                        }
-                    }
-                }
-
-                i++;
-            }
-            mStats.finishIteratingHistoryLocked();
-        }
-
-        if (lastY < 0 || lastX < 0) {
-            // Didn't get any data...
-            x = lastX = mLevelLeft;
-            y = lastY = mLevelTop + levelh - ((mInfo.batteryLevel -batLow)*(levelh-1))/batChange;
-            Path path;
-            byte value = (byte)mInfo.batteryLevel;
-            if (value <= mBatteryCriticalLevel) path = mBatCriticalPath;
-            else if (value <= mBatteryWarnLevel) path = mBatWarnPath;
-            else path = null; //mBatGoodPath;
-            if (path != null) {
-                path.moveTo(x, y);
-                lastLinePath = path;
-            }
-            mBatLevelPath.moveTo(x, y);
-            curLevelPath = mBatLevelPath;
-            x = w;
-        } else {
-            // Figure out where the actual data ends on the screen.
-            x = mLevelLeft + (int)(((mEndDataWallTime-walltimeStart)*levelWidth)/walltimeChange);
-            if (x < 0) {
-                x = 0;
-            }
-        }
-
-        finishPaths(x, h, levelh, startX, lastY, curLevelPath, lastX,
-                lastCharging, lastScreenOn, lastGpsOn, lastFlashlightOn, lastCameraOn,
-                lastWifiRunning, lastCpuRunning, lastLinePath);
-
-        if (x < w) {
-            // If we reserved room for the remaining time, create a final path to draw
-            // that part of the UI.
-            mTimeRemainPath.moveTo(x, lastY);
-            int fullY = mLevelTop + levelh - ((100-batLow)*(levelh-1))/batChange;
-            int emptyY = mLevelTop + levelh - ((0-batLow)*(levelh-1))/batChange;
-            if (mInfo.discharging) {
-                mTimeRemainPath.lineTo(mLevelRight, emptyY);
-            } else {
-                mTimeRemainPath.lineTo(mLevelRight, fullY);
-                mTimeRemainPath.lineTo(mLevelRight, emptyY);
-            }
-            mTimeRemainPath.lineTo(x, emptyY);
-            mTimeRemainPath.close();
-        }
-
-        if (mStartWallTime > 0 && mEndWallTime > mStartWallTime) {
-            // Create the time labels at the bottom.
-            boolean is24hr = is24Hour();
-            Calendar calStart = Calendar.getInstance();
-            calStart.setTimeInMillis(mStartWallTime);
-            calStart.set(Calendar.MILLISECOND, 0);
-            calStart.set(Calendar.SECOND, 0);
-            calStart.set(Calendar.MINUTE, 0);
-            long startRoundTime = calStart.getTimeInMillis();
-            if (startRoundTime < mStartWallTime) {
-                calStart.set(Calendar.HOUR_OF_DAY, calStart.get(Calendar.HOUR_OF_DAY)+1);
-                startRoundTime = calStart.getTimeInMillis();
-            }
-            Calendar calEnd = Calendar.getInstance();
-            calEnd.setTimeInMillis(mEndWallTime);
-            calEnd.set(Calendar.MILLISECOND, 0);
-            calEnd.set(Calendar.SECOND, 0);
-            calEnd.set(Calendar.MINUTE, 0);
-            long endRoundTime = calEnd.getTimeInMillis();
-            if (startRoundTime < endRoundTime) {
-                addTimeLabel(calStart, mLevelLeft, mLevelRight, is24hr);
-                Calendar calMid = Calendar.getInstance();
-                calMid.setTimeInMillis(mStartWallTime+((mEndWallTime-mStartWallTime)/2));
-                calMid.set(Calendar.MILLISECOND, 0);
-                calMid.set(Calendar.SECOND, 0);
-                calMid.set(Calendar.MINUTE, 0);
-                long calMidMillis = calMid.getTimeInMillis();
-                if (calMidMillis > startRoundTime && calMidMillis < endRoundTime) {
-                    addTimeLabel(calMid, mLevelLeft, mLevelRight, is24hr);
-                }
-                addTimeLabel(calEnd, mLevelLeft, mLevelRight, is24hr);
-            }
-
-            // Create the date labels if the chart includes multiple days
-            if (calStart.get(Calendar.DAY_OF_YEAR) != calEnd.get(Calendar.DAY_OF_YEAR) ||
-                    calStart.get(Calendar.YEAR) != calEnd.get(Calendar.YEAR)) {
-                boolean isDayFirst = isDayFirst();
-                calStart.set(Calendar.HOUR_OF_DAY, 0);
-                startRoundTime = calStart.getTimeInMillis();
-                if (startRoundTime < mStartWallTime) {
-                    calStart.set(Calendar.DAY_OF_YEAR, calStart.get(Calendar.DAY_OF_YEAR) + 1);
-                    startRoundTime = calStart.getTimeInMillis();
-                }
-                calEnd.set(Calendar.HOUR_OF_DAY, 0);
-                endRoundTime = calEnd.getTimeInMillis();
-                if (startRoundTime < endRoundTime) {
-                    addDateLabel(calStart, mLevelLeft, mLevelRight, isDayFirst);
-                    Calendar calMid = Calendar.getInstance();
-
-                    // The middle between two beginnings of days can be anywhere between -1 to 13
-                    // after the beginning of the "median" day.
-                    calMid.setTimeInMillis(startRoundTime + ((endRoundTime - startRoundTime) / 2)
-                                           + 2 * 60 * 60 * 1000);
-                    calMid.set(Calendar.HOUR_OF_DAY, 0);
-                    calMid.set(Calendar.MINUTE, 0);
-                    long calMidMillis = calMid.getTimeInMillis();
-                    if (calMidMillis > startRoundTime && calMidMillis < endRoundTime) {
-                        addDateLabel(calMid, mLevelLeft, mLevelRight, isDayFirst);
-                    }
-                }
-                addDateLabel(calEnd, mLevelLeft, mLevelRight, isDayFirst);
-            }
-        }
-
-        if (mTimeLabels.size() < 2) {
-            // If there are fewer than 2 time labels, then they are useless.  Just
-            // show an axis label giving the entire duration.
-            mDurationString = Formatter.formatShortElapsedTime(getContext(),
-                    mEndWallTime - mStartWallTime);
-            mDurationStringWidth = (int)mTextPaint.measureText(mDurationString);
-        } else {
-            mDurationString = null;
-            mDurationStringWidth = 0;
-        }
-    }
-
-    void addTimeLabel(Calendar cal, int levelLeft, int levelRight, boolean is24hr) {
-        final long walltimeStart = mStartWallTime;
-        final long walltimeChange = mEndWallTime-walltimeStart;
-        mTimeLabels.add(new TimeLabel(mTextPaint,
-                levelLeft + (int)(((cal.getTimeInMillis()-walltimeStart)*(levelRight-levelLeft))
-                        / walltimeChange),
-                cal, is24hr));
-    }
-
-    void addDateLabel(Calendar cal, int levelLeft, int levelRight, boolean isDayFirst) {
-        final long walltimeStart = mStartWallTime;
-        final long walltimeChange = mEndWallTime-walltimeStart;
-        mDateLabels.add(new DateLabel(mTextPaint,
-                levelLeft + (int)(((cal.getTimeInMillis()-walltimeStart)*(levelRight-levelLeft))
-                        / walltimeChange),
-                cal, isDayFirst));
-    }
-
-    @Override
-    protected void onDraw(Canvas canvas) {
-        super.onDraw(canvas);
-
-        final int width = getWidth();
-        final int height = getHeight();
-
-        //buildBitmap(width, height);
-
-        if (DEBUG) Log.d(TAG, "onDraw: " + width + "x" + height);
-        //canvas.drawBitmap(mBitmap, 0, 0, null);
-        drawChart(canvas, width, height);
-    }
-
-    void buildBitmap(int width, int height) {
-        if (mBitmap != null && width == mBitmap.getWidth() && height == mBitmap.getHeight()) {
-            return;
-        }
-
-        if (DEBUG) Log.d(TAG, "buildBitmap: " + width + "x" + height);
-
-        mBitmap = Bitmap.createBitmap(getResources().getDisplayMetrics(), width, height,
-                Bitmap.Config.ARGB_8888);
-        mCanvas = new Canvas(mBitmap);
-        drawChart(mCanvas, width, height);
-    }
-
-    void drawChart(Canvas canvas, int width, int height) {
-        final boolean layoutRtl = isLayoutRtl();
-        final int textStartX = layoutRtl ? width : 0;
-        final int textEndX = layoutRtl ? 0 : width;
-        final Paint.Align textAlignLeft = layoutRtl ? Paint.Align.RIGHT : Paint.Align.LEFT;
-        final Paint.Align textAlignRight = layoutRtl ? Paint.Align.LEFT : Paint.Align.RIGHT;
-
-        if (DEBUG) {
-            canvas.drawRect(1, 1, width, height, mDebugRectPaint);
-        }
-
-        if (DEBUG) Log.d(TAG, "Drawing level path.");
-        canvas.drawPath(mBatLevelPath, mBatteryBackgroundPaint);
-        if (!mTimeRemainPath.isEmpty()) {
-            if (DEBUG) Log.d(TAG, "Drawing time remain path.");
-            canvas.drawPath(mTimeRemainPath, mTimeRemainPaint);
-        }
-        if (mTimeLabels.size() > 1) {
-            int y = mLevelBottom - mTextAscent + (mThinLineWidth*4);
-            int ytick = mLevelBottom+mThinLineWidth+(mThinLineWidth/2);
-            mTextPaint.setTextAlign(Paint.Align.LEFT);
-            int lastX = 0;
-            for (int i=0; i<mTimeLabels.size(); i++) {
-                TimeLabel label = mTimeLabels.get(i);
-                if (i == 0) {
-                    int x = label.x - label.width/2;
-                    if (x < 0) {
-                        x = 0;
-                    }
-                    if (DEBUG) Log.d(TAG, "Drawing left label: " + label.label + " @ " + x);
-                    canvas.drawText(label.label, x, y, mTextPaint);
-                    canvas.drawLine(label.x, ytick, label.x, ytick+mThinLineWidth, mTextPaint);
-                    lastX = x + label.width;
-                } else if (i < (mTimeLabels.size()-1)) {
-                    int x = label.x - label.width/2;
-                    if (x < (lastX+mTextAscent)) {
-                        continue;
-                    }
-                    TimeLabel nextLabel = mTimeLabels.get(i+1);
-                    if (x > (width-nextLabel.width-mTextAscent)) {
-                        continue;
-                    }
-                    if (DEBUG) Log.d(TAG, "Drawing middle label: " + label.label + " @ " + x);
-                    canvas.drawText(label.label, x, y, mTextPaint);
-                    canvas.drawLine(label.x, ytick, label.x, ytick + mThinLineWidth, mTextPaint);
-                    lastX = x + label.width;
-                } else {
-                    int x = label.x - label.width/2;
-                    if ((x+label.width) >= width) {
-                        x = width-1-label.width;
-                    }
-                    if (DEBUG) Log.d(TAG, "Drawing right label: " + label.label + " @ " + x);
-                    canvas.drawText(label.label, x, y, mTextPaint);
-                    canvas.drawLine(label.x, ytick, label.x, ytick+mThinLineWidth, mTextPaint);
-                }
-            }
-        } else if (mDurationString != null) {
-            int y = mLevelBottom - mTextAscent + (mThinLineWidth*4);
-            mTextPaint.setTextAlign(Paint.Align.LEFT);
-            canvas.drawText(mDurationString,
-                    mLevelLeft + (mLevelRight-mLevelLeft)/2 - mDurationStringWidth/2,
-                    y, mTextPaint);
-        }
-
-        int headerTop = -mHeaderTextAscent + (mHeaderTextDescent-mHeaderTextAscent)/3;
-        mHeaderTextPaint.setTextAlign(textAlignLeft);
-        if (DEBUG) Log.d(TAG, "Drawing charge label string: " + mInfo.chargeLabel);
-        canvas.drawText(mInfo.chargeLabel.toString(), textStartX, headerTop,
-                mHeaderTextPaint);
-        int stringHalfWidth = mChargeDurationStringWidth / 2;
-        if (layoutRtl) stringHalfWidth = -stringHalfWidth;
-        int headerCenter = ((width-mChargeDurationStringWidth-mDrainStringWidth)/2)
-                + (layoutRtl ? mDrainStringWidth : mChargeLabelStringWidth);
-        if (DEBUG) Log.d(TAG, "Drawing charge duration string: " + mChargeDurationString);
-        canvas.drawText(mChargeDurationString, headerCenter - stringHalfWidth, headerTop,
-                mHeaderTextPaint);
-        mHeaderTextPaint.setTextAlign(textAlignRight);
-        if (DEBUG) Log.d(TAG, "Drawing drain string: " + mDrainString);
-        canvas.drawText(mDrainString, textEndX, headerTop, mHeaderTextPaint);
-
-        if (!mBatGoodPath.isEmpty()) {
-            if (DEBUG) Log.d(TAG, "Drawing good battery path");
-            canvas.drawPath(mBatGoodPath, mBatteryGoodPaint);
-        }
-        if (!mBatWarnPath.isEmpty()) {
-            if (DEBUG) Log.d(TAG, "Drawing warn battery path");
-            canvas.drawPath(mBatWarnPath, mBatteryWarnPaint);
-        }
-        if (!mBatCriticalPath.isEmpty()) {
-            if (DEBUG) Log.d(TAG, "Drawing critical battery path");
-            canvas.drawPath(mBatCriticalPath, mBatteryCriticalPaint);
-        }
-        if (mHavePhoneSignal) {
-            if (DEBUG) Log.d(TAG, "Drawing phone signal path");
-            int top = height-mPhoneSignalOffset - (mLineWidth/2);
-            mPhoneSignalChart.draw(canvas, top, mLineWidth);
-        }
-        if (!mScreenOnPath.isEmpty()) {
-            if (DEBUG) Log.d(TAG, "Drawing screen on path");
-            canvas.drawPath(mScreenOnPath, mScreenOnPaint);
-        }
-        if (!mChargingPath.isEmpty()) {
-            if (DEBUG) Log.d(TAG, "Drawing charging path");
-            canvas.drawPath(mChargingPath, mChargingPaint);
-        }
-        if (mHaveGps) {
-            if (!mGpsOnPath.isEmpty()) {
-                if (DEBUG) Log.d(TAG, "Drawing gps path");
-                canvas.drawPath(mGpsOnPath, mGpsOnPaint);
-            }
-        }
-        if (mHaveFlashlight) {
-            if (!mFlashlightOnPath.isEmpty()) {
-                if (DEBUG) Log.d(TAG, "Drawing flashlight path");
-                canvas.drawPath(mFlashlightOnPath, mFlashlightOnPaint);
-            }
-        }
-        if (mHaveCamera) {
-            if (!mCameraOnPath.isEmpty()) {
-                if (DEBUG) Log.d(TAG, "Drawing camera path");
-                canvas.drawPath(mCameraOnPath, mCameraOnPaint);
-            }
-        }
-        if (mHaveWifi) {
-            if (!mWifiRunningPath.isEmpty()) {
-                if (DEBUG) Log.d(TAG, "Drawing wifi path");
-                canvas.drawPath(mWifiRunningPath, mWifiRunningPaint);
-            }
-        }
-        if (!mCpuRunningPath.isEmpty()) {
-            if (DEBUG) Log.d(TAG, "Drawing running path");
-            canvas.drawPath(mCpuRunningPath, mCpuRunningPaint);
-        }
-
-        if (mLargeMode) {
-            if (DEBUG) Log.d(TAG, "Drawing large mode labels");
-            Paint.Align align = mTextPaint.getTextAlign();
-            mTextPaint.setTextAlign(textAlignLeft);  // large-mode labels always aligned to start
-            if (mHavePhoneSignal) {
-                canvas.drawText(mPhoneSignalLabel, textStartX,
-                        height - mPhoneSignalOffset - mTextDescent, mTextPaint);
-            }
-            if (mHaveGps) {
-                canvas.drawText(mGpsOnLabel, textStartX,
-                        height - mGpsOnOffset - mTextDescent, mTextPaint);
-            }
-            if (mHaveFlashlight) {
-                canvas.drawText(mFlashlightOnLabel, textStartX,
-                        height - mFlashlightOnOffset - mTextDescent, mTextPaint);
-            }
-            if (mHaveCamera) {
-                canvas.drawText(mCameraOnLabel, textStartX,
-                        height - mCameraOnOffset - mTextDescent, mTextPaint);
-            }
-            if (mHaveWifi) {
-                canvas.drawText(mWifiRunningLabel, textStartX,
-                        height - mWifiRunningOffset - mTextDescent, mTextPaint);
-            }
-            canvas.drawText(mCpuRunningLabel, textStartX,
-                    height - mCpuRunningOffset - mTextDescent, mTextPaint);
-            canvas.drawText(mChargingLabel, textStartX,
-                    height - mChargingOffset - mTextDescent, mTextPaint);
-            canvas.drawText(mScreenOnLabel, textStartX,
-                    height - mScreenOnOffset - mTextDescent, mTextPaint);
-            mTextPaint.setTextAlign(align);
-        }
-
-        canvas.drawLine(mLevelLeft-mThinLineWidth, mLevelTop, mLevelLeft-mThinLineWidth,
-                mLevelBottom+(mThinLineWidth/2), mTextPaint);
-        if (mLargeMode) {
-            for (int i=0; i<10; i++) {
-                int y = mLevelTop + mThinLineWidth/2 + ((mLevelBottom-mLevelTop)*i)/10;
-                canvas.drawLine(mLevelLeft-mThinLineWidth*2-mThinLineWidth/2, y,
-                        mLevelLeft-mThinLineWidth-mThinLineWidth/2, y, mTextPaint);
-            }
-        }
-        if (DEBUG) Log.d(TAG, "Drawing max percent, origw=" + mMaxPercentLabelStringWidth
-                + ", noww=" + (int)mTextPaint.measureText(mMaxPercentLabelString));
-        canvas.drawText(mMaxPercentLabelString, 0, mLevelTop, mTextPaint);
-        canvas.drawText(mMinPercentLabelString,
-                mMaxPercentLabelStringWidth-mMinPercentLabelStringWidth,
-                mLevelBottom - mThinLineWidth, mTextPaint);
-        canvas.drawLine(mLevelLeft/2, mLevelBottom+mThinLineWidth, width,
-                mLevelBottom+mThinLineWidth, mTextPaint);
-
-        if (mDateLabels.size() > 0) {
-            int ytop = mLevelTop + mTextAscent;
-            int ybottom = mLevelBottom;
-            int lastLeft = mLevelRight;
-            mTextPaint.setTextAlign(Paint.Align.LEFT);
-            for (int i=mDateLabels.size()-1; i>=0; i--) {
-                DateLabel label = mDateLabels.get(i);
-                int left = label.x - mThinLineWidth;
-                int x = label.x + mThinLineWidth*2;
-                if ((x+label.width) >= lastLeft) {
-                    x = label.x - mThinLineWidth*2 - label.width;
-                    left = x - mThinLineWidth;
-                    if (left >= lastLeft) {
-                        // okay we give up.
-                        continue;
-                    }
-                }
-                if (left < mLevelLeft) {
-                    // Won't fit on left, give up.
-                    continue;
-                }
-                mDateLinePath.reset();
-                mDateLinePath.moveTo(label.x, ytop);
-                mDateLinePath.lineTo(label.x, ybottom);
-                canvas.drawPath(mDateLinePath, mDateLinePaint);
-                canvas.drawText(label.label, x, ytop - mTextAscent, mTextPaint);
-            }
-        }
-    }
-}
diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryDetail.java b/src/com/android/settings/fuelgauge/BatteryHistoryDetail.java
deleted file mode 100644
index 1343fef..0000000
--- a/src/com/android/settings/fuelgauge/BatteryHistoryDetail.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2009 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.Intent;
-import android.os.BatteryStats;
-import android.os.BatteryStats.HistoryItem;
-import android.os.Bundle;
-import android.util.TypedValue;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.internal.os.BatteryStatsHelper;
-import com.android.settings.R;
-import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.fuelgauge.BatteryActiveView.BatteryActiveProvider;
-import com.android.settings.widget.UsageView;
-
-public class BatteryHistoryDetail extends SettingsPreferenceFragment {
-    public static final String EXTRA_STATS = "stats";
-    public static final String EXTRA_BROADCAST = "broadcast";
-    public static final String BATTERY_HISTORY_FILE = "tmp_bat_history.bin";
-
-    private BatteryStats mStats;
-    private Intent mBatteryBroadcast;
-
-    private BatteryFlagParser mChargingParser;
-    private BatteryFlagParser mScreenOn;
-    private BatteryFlagParser mGpsParser;
-    private BatteryFlagParser mFlashlightParser;
-    private BatteryFlagParser mCameraParser;
-    private BatteryWifiParser mWifiParser;
-    private BatteryFlagParser mCpuParser;
-    private BatteryCellParser mPhoneParser;
-
-    @Override
-    public void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-        String histFile = getArguments().getString(EXTRA_STATS);
-        mStats = BatteryStatsHelper.statsFromFile(getActivity(), histFile);
-        mBatteryBroadcast = getArguments().getParcelable(EXTRA_BROADCAST);
-
-        TypedValue value = new TypedValue();
-        getContext().getTheme().resolveAttribute(android.R.attr.colorAccent, value, true);
-        int accentColor = getContext().getColor(value.resourceId);
-
-        mChargingParser = new BatteryFlagParser(accentColor, false,
-                HistoryItem.STATE_BATTERY_PLUGGED_FLAG);
-        mScreenOn = new BatteryFlagParser(accentColor, false,
-                HistoryItem.STATE_SCREEN_ON_FLAG);
-        mGpsParser = new BatteryFlagParser(accentColor, false,
-                HistoryItem.STATE_GPS_ON_FLAG);
-        mFlashlightParser = new BatteryFlagParser(accentColor, true,
-                HistoryItem.STATE2_FLASHLIGHT_FLAG);
-        mCameraParser = new BatteryFlagParser(accentColor, true,
-                HistoryItem.STATE2_CAMERA_FLAG);
-        mWifiParser = new BatteryWifiParser(accentColor);
-        mCpuParser = new BatteryFlagParser(accentColor, false,
-                HistoryItem.STATE_CPU_RUNNING_FLAG);
-        mPhoneParser = new BatteryCellParser();
-        setHasOptionsMenu(true);
-    }
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,
-            Bundle savedInstanceState) {
-        return inflater.inflate(R.layout.battery_history_detail, container, false);
-    }
-
-    @Override
-    public void onViewCreated(View view, Bundle savedInstanceState) {
-        super.onViewCreated(view, savedInstanceState);
-        updateEverything();
-    }
-
-    private void updateEverything() {
-        BatteryInfo.getBatteryInfo(getContext(), info -> {
-            final View view = getView();
-            info.bindHistory((UsageView) view.findViewById(R.id.battery_usage), mChargingParser,
-                    mScreenOn, mGpsParser, mFlashlightParser, mCameraParser, mWifiParser,
-                    mCpuParser, mPhoneParser);
-            ((TextView) view.findViewById(R.id.charge)).setText(info.batteryPercentString);
-            ((TextView) view.findViewById(R.id.estimation)).setText(info.remainingLabel);
-
-            bindData(mChargingParser, R.string.battery_stats_charging_label, R.id.charging_group);
-            bindData(mScreenOn, R.string.battery_stats_screen_on_label, R.id.screen_on_group);
-            bindData(mGpsParser, R.string.battery_stats_gps_on_label, R.id.gps_group);
-            bindData(mFlashlightParser, R.string.battery_stats_flashlight_on_label,
-                    R.id.flashlight_group);
-            bindData(mCameraParser, R.string.battery_stats_camera_on_label, R.id.camera_group);
-            bindData(mWifiParser, R.string.battery_stats_wifi_running_label, R.id.wifi_group);
-            bindData(mCpuParser, R.string.battery_stats_wake_lock_label, R.id.cpu_group);
-            bindData(mPhoneParser, R.string.battery_stats_phone_signal_label,
-                    R.id.cell_network_group);
-        }, mStats, false /* shortString */);
-    }
-
-    private void bindData(BatteryActiveProvider provider, int label, int groupId) {
-        View group = getView().findViewById(groupId);
-        group.setVisibility(provider.hasData() ? View.VISIBLE : View.GONE);
-        ((TextView) group.findViewById(android.R.id.title)).setText(label);
-        ((BatteryActiveView) group.findViewById(R.id.battery_active)).setProvider(provider);
-    }
-
-    @Override
-    public int getMetricsCategory() {
-        return MetricsEvent.FUELGAUGE_BATTERY_HISTORY_DETAIL;
-    }
-}
diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java b/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java
index 89b3edd..115e72c 100644
--- a/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java
+++ b/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java
@@ -54,7 +54,7 @@
         BatteryInfo.getBatteryInfo(getContext(), info -> {
             mBatteryInfo = info;
             notifyChanged();
-        }, batteryStats.getStats(), false);
+        }, batteryStats, false);
     }
 
     public void setBottomSummary(CharSequence text) {
diff --git a/src/com/android/settings/fuelgauge/BatteryInfo.java b/src/com/android/settings/fuelgauge/BatteryInfo.java
index f642d30..dcbfaa8 100644
--- a/src/com/android/settings/fuelgauge/BatteryInfo.java
+++ b/src/com/android/settings/fuelgauge/BatteryInfo.java
@@ -134,31 +134,32 @@
     }
 
     public static void getBatteryInfo(final Context context, final Callback callback) {
-        BatteryInfo.getBatteryInfo(context, callback, false /* shortString */);
+        BatteryInfo.getBatteryInfo(context, callback, null /* statsHelper */,
+                false /* shortString */);
     }
 
     public static void getBatteryInfo(final Context context, final Callback callback,
             boolean shortString) {
-        final long startTime = System.currentTimeMillis();
-        BatteryStatsHelper statsHelper = new BatteryStatsHelper(context, true);
-        statsHelper.create((Bundle) null);
-        BatteryUtils.logRuntime(LOG_TAG, "time to make batteryStatsHelper", startTime);
-        BatteryInfo.getBatteryInfo(context, callback, statsHelper, shortString);
+        BatteryInfo.getBatteryInfo(context, callback, null /* statsHelper */, shortString);
     }
 
     public static void getBatteryInfo(final Context context, final Callback callback,
-            BatteryStatsHelper statsHelper, boolean shortString) {
-        final long startTime = System.currentTimeMillis();
-        BatteryStats stats = statsHelper.getStats();
-        BatteryUtils.logRuntime(LOG_TAG, "time for getStats", startTime);
-        getBatteryInfo(context, callback, stats, shortString);
-    }
-
-    public static void getBatteryInfo(final Context context, final Callback callback,
-            BatteryStats stats, boolean shortString) {
+            final BatteryStatsHelper statsHelper, boolean shortString) {
         new AsyncTask<Void, Void, BatteryInfo>() {
             @Override
             protected BatteryInfo doInBackground(Void... params) {
+                final BatteryStats stats;
+                final long batteryStatsTime = System.currentTimeMillis();
+                if (statsHelper == null) {
+                    final BatteryStatsHelper localStatsHelper = new BatteryStatsHelper(context,
+                            true);
+                    localStatsHelper.create((Bundle) null);
+                    stats = localStatsHelper.getStats();
+                } else {
+                    stats = statsHelper.getStats();
+                }
+                BatteryUtils.logRuntime(LOG_TAG, "time for getStats", batteryStatsTime);
+
                 final long startTime = System.currentTimeMillis();
                 PowerUsageFeatureProvider provider =
                         FeatureFactory.getFactory(context).getPowerUsageFeatureProvider(context);
diff --git a/src/com/android/settings/fuelgauge/BatterySaverController.java b/src/com/android/settings/fuelgauge/BatterySaverController.java
index e2440a5..e77393e 100644
--- a/src/com/android/settings/fuelgauge/BatterySaverController.java
+++ b/src/com/android/settings/fuelgauge/BatterySaverController.java
@@ -22,19 +22,16 @@
 import android.os.PowerManager;
 import android.provider.Settings;
 
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
 import com.android.settings.R;
 import com.android.settings.Utils;
 import com.android.settings.core.BasePreferenceController;
-import com.android.settings.dashboard.conditional.BatterySaverCondition;
-import com.android.settings.dashboard.conditional.ConditionManager;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnStart;
 import com.android.settingslib.core.lifecycle.events.OnStop;
 
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
 public class BatterySaverController extends BasePreferenceController
         implements LifecycleObserver, OnStart, OnStop, BatterySaverReceiver.BatterySaverListener {
     private static final String KEY_BATTERY_SAVER = "battery_saver_summary";
@@ -82,11 +79,6 @@
         mBatteryStateChangeReceiver.setListening(false);
     }
 
-    @VisibleForTesting
-    void refreshConditionManager() {
-        ConditionManager.get(mContext).getCondition(BatterySaverCondition.class).refreshState();
-    }
-
     @Override
     public CharSequence getSummary() {
         final boolean isPowerSaveOn = mPowerManager.isPowerSaveMode();
diff --git a/src/com/android/settings/fuelgauge/PowerUsageBase.java b/src/com/android/settings/fuelgauge/PowerUsageBase.java
index 06200a3..a11270b 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageBase.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageBase.java
@@ -72,8 +72,6 @@
     @Override
     public void onResume() {
         super.onResume();
-
-        BatteryStatsHelper.dropFile(getActivity(), BatteryHistoryDetail.BATTERY_HISTORY_FILE);
         mBatteryBroadcastReceiver.register();
     }
 
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 2ae5876..7563120 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -17,13 +17,13 @@
 package com.android.settings.fuelgauge;
 
 import static com.android.settings.fuelgauge.BatteryBroadcastReceiver.BatteryUpdateType;
+import static com.android.settings.fuelgauge.TopLevelBatteryPreferenceController.getDashboardLabel;
 
 import android.app.Activity;
 import android.content.Context;
 import android.os.BatteryStats;
 import android.os.Bundle;
 import android.provider.SearchIndexableResource;
-import android.text.BidiFormatter;
 import android.text.format.Formatter;
 import android.view.Menu;
 import android.view.MenuInflater;
@@ -32,6 +32,11 @@
 import android.view.View.OnLongClickListener;
 import android.widget.TextView;
 
+import androidx.annotation.VisibleForTesting;
+import androidx.loader.app.LoaderManager;
+import androidx.loader.app.LoaderManager.LoaderCallbacks;
+import androidx.loader.content.Loader;
+
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
@@ -51,11 +56,6 @@
 import java.util.Collections;
 import java.util.List;
 
-import androidx.annotation.VisibleForTesting;
-import androidx.loader.app.LoaderManager;
-import androidx.loader.app.LoaderManager.LoaderCallbacks;
-import androidx.loader.content.Loader;
-
 /**
  * Displays a list of apps and subsystems that consume power, ordered by how much power was
  * consumed since the last time it was unplugged.
@@ -147,9 +147,9 @@
 
     protected void updateViews(List<BatteryInfo> batteryInfos) {
         final BatteryMeterView batteryView = mBatteryLayoutPref
-            .findViewById(R.id.battery_header_icon);
+                .findViewById(R.id.battery_header_icon);
         final TextView percentRemaining =
-            mBatteryLayoutPref.findViewById(R.id.battery_percent);
+                mBatteryLayoutPref.findViewById(R.id.battery_percent);
         final TextView summary1 = mBatteryLayoutPref.findViewById(R.id.summary1);
         final TextView summary2 = mBatteryLayoutPref.findViewById(R.id.summary2);
         BatteryInfo oldInfo = batteryInfos.get(0);
@@ -160,13 +160,13 @@
         // can sometimes say 0 time remaining because battery stats requires the phone
         // be unplugged for a period of time before being willing ot make an estimate.
         summary1.setText(mPowerFeatureProvider.getOldEstimateDebugString(
-            Formatter.formatShortElapsedTime(getContext(),
-                PowerUtil.convertUsToMs(oldInfo.remainingTimeUs))));
+                Formatter.formatShortElapsedTime(getContext(),
+                        PowerUtil.convertUsToMs(oldInfo.remainingTimeUs))));
 
         // for this one we can just set the string directly
         summary2.setText(mPowerFeatureProvider.getEnhancedEstimateDebugString(
-            Formatter.formatShortElapsedTime(getContext(),
-                PowerUtil.convertUsToMs(newInfo.remainingTimeUs))));
+                Formatter.formatShortElapsedTime(getContext(),
+                        PowerUtil.convertUsToMs(newInfo.remainingTimeUs))));
 
         batteryView.setBatteryLevel(oldInfo.batteryLevel);
         batteryView.setCharging(!oldInfo.discharging);
@@ -419,19 +419,6 @@
         }
     }
 
-    @VisibleForTesting
-    static CharSequence getDashboardLabel(Context context, BatteryInfo info) {
-        CharSequence label;
-        final BidiFormatter formatter = BidiFormatter.getInstance();
-        if (info.remainingLabel == null) {
-            label = info.batteryPercentString;
-        } else {
-            label = context.getString(R.string.power_remaining_settings_home_page,
-                    formatter.unicodeWrap(info.batteryPercentString),
-                    formatter.unicodeWrap(info.remainingLabel));
-        }
-        return label;
-    }
 
     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider() {
diff --git a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
new file mode 100644
index 0000000..8205818
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.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.fuelgauge;
+
+import android.content.Context;
+import android.text.BidiFormatter;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
+
+public class TopLevelBatteryPreferenceController extends BasePreferenceController implements
+        LifecycleObserver, OnStart, OnStop {
+
+    private final BatteryBroadcastReceiver mBatteryBroadcastReceiver;
+    private Preference mPreference;
+    private BatteryInfo mBatteryInfo;
+
+    public TopLevelBatteryPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+        mBatteryBroadcastReceiver = new BatteryBroadcastReceiver(mContext);
+        mBatteryBroadcastReceiver.setBatteryChangedListener(type -> {
+            BatteryInfo.getBatteryInfo(mContext, info -> {
+                mBatteryInfo = info;
+                updateState(mPreference);
+            }, true /* shortString */);
+        });
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE_UNSEARCHABLE;
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mPreference = screen.findPreference(getPreferenceKey());
+    }
+
+    @Override
+    public void onStart() {
+        mBatteryBroadcastReceiver.register();
+    }
+
+    @Override
+    public void onStop() {
+        mBatteryBroadcastReceiver.unRegister();
+    }
+
+    @Override
+    public CharSequence getSummary() {
+        return getDashboardLabel(mContext, mBatteryInfo);
+    }
+
+    static CharSequence getDashboardLabel(Context context, BatteryInfo info) {
+        if (info == null || context == null) {
+            return null;
+        }
+        CharSequence label;
+        final BidiFormatter formatter = BidiFormatter.getInstance();
+        if (info.remainingLabel == null) {
+            label = info.batteryPercentString;
+        } else {
+            label = context.getString(R.string.power_remaining_settings_home_page,
+                    formatter.unicodeWrap(info.batteryPercentString),
+                    formatter.unicodeWrap(info.remainingLabel));
+        }
+        return label;
+    }
+}
diff --git a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
index 04bdedc..4a23570 100644
--- a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
@@ -16,7 +16,7 @@
 
 package com.android.settings.gestures;
 
-import static android.provider.Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP;
+import static android.provider.Settings.Secure.DOZE_DOUBLE_TAP_GESTURE;
 
 import android.annotation.UserIdInt;
 import android.content.Context;
@@ -36,7 +36,7 @@
 
     private static final String PREF_KEY_VIDEO = "gesture_double_tap_screen_video";
 
-    private final String SECURE_KEY = DOZE_PULSE_ON_DOUBLE_TAP;
+    private final String SECURE_KEY = DOZE_DOUBLE_TAP_GESTURE;
 
     private AmbientDisplayConfiguration mAmbientConfig;
     @UserIdInt
@@ -59,7 +59,7 @@
     @VisibleForTesting
     static boolean isSuggestionComplete(AmbientDisplayConfiguration config,
             SharedPreferences prefs) {
-        return !config.pulseOnDoubleTapAvailable()
+        return !config.doubleTapSensorAvailable()
                 || prefs.getBoolean(DoubleTapScreenSettings.PREF_KEY_SUGGESTION_COMPLETE, false);
     }
 
@@ -70,11 +70,6 @@
             return UNSUPPORTED_ON_DEVICE;
         }
 
-        // Can't change Double Tap when AOD is enabled.
-        if (!getAmbientConfig().ambientDisplayAvailable()) {
-            return DISABLED_DEPENDENT_SETTING;
-        }
-
         return AVAILABLE;
     }
 
@@ -96,12 +91,7 @@
 
     @Override
     public boolean isChecked() {
-        return getAmbientConfig().pulseOnDoubleTapEnabled(mUserId);
-    }
-
-    @Override
-    protected boolean canHandleClicks() {
-        return !getAmbientConfig().alwaysOnEnabled(mUserId);
+        return getAmbientConfig().doubleTapGestureEnabled(mUserId);
     }
 
     private AmbientDisplayConfiguration getAmbientConfig() {
diff --git a/src/com/android/settings/gestures/PickupGesturePreferenceController.java b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
index 53a4447..7460183 100644
--- a/src/com/android/settings/gestures/PickupGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
@@ -16,7 +16,7 @@
 
 package com.android.settings.gestures;
 
-import static android.provider.Settings.Secure.DOZE_PULSE_ON_PICK_UP;
+import static android.provider.Settings.Secure.DOZE_PICK_UP_GESTURE;
 
 import android.annotation.UserIdInt;
 import android.content.Context;
@@ -37,7 +37,7 @@
     private static final String PREF_KEY_VIDEO = "gesture_pick_up_video";
     private final String mPickUpPrefKey;
 
-    private final String SECURE_KEY = DOZE_PULSE_ON_PICK_UP;
+    private final String SECURE_KEY = DOZE_PICK_UP_GESTURE;
 
     private AmbientDisplayConfiguration mAmbientConfig;
     @UserIdInt
@@ -57,21 +57,16 @@
     public static boolean isSuggestionComplete(Context context, SharedPreferences prefs) {
         AmbientDisplayConfiguration ambientConfig = new AmbientDisplayConfiguration(context);
         return prefs.getBoolean(PickupGestureSettings.PREF_KEY_SUGGESTION_COMPLETE, false)
-                || !ambientConfig.pulseOnPickupAvailable();
+                || !ambientConfig.dozePickupSensorAvailable();
     }
 
     @Override
     public int getAvailabilityStatus() {
         // No hardware support for Pickup Gesture
-        if (!getAmbientConfig().dozePulsePickupSensorAvailable()) {
+        if (!getAmbientConfig().dozePickupSensorAvailable()) {
             return UNSUPPORTED_ON_DEVICE;
         }
 
-        // Can't change Pickup Gesture when AOD is enabled.
-        if (!getAmbientConfig().ambientDisplayAvailable()) {
-            return DISABLED_DEPENDENT_SETTING;
-        }
-
         return AVAILABLE;
     }
 
@@ -87,7 +82,7 @@
 
     @Override
     public boolean isChecked() {
-        return getAmbientConfig().pulseOnPickupEnabled(mUserId);
+        return getAmbientConfig().pickupGestureEnabled(mUserId);
     }
 
     @Override
@@ -101,16 +96,6 @@
                 isChecked ? ON : OFF);
     }
 
-    @Override
-    public boolean canHandleClicks() {
-        return pulseOnPickupCanBeModified();
-    }
-
-    @VisibleForTesting
-    boolean pulseOnPickupCanBeModified() {
-        return getAmbientConfig().pulseOnPickupCanBeModified(mUserId);
-    }
-
     private AmbientDisplayConfiguration getAmbientConfig() {
         if (mAmbientConfig == null) {
             mAmbientConfig = new AmbientDisplayConfiguration(mContext);
diff --git a/src/com/android/settings/homepage/CardContentProvider.java b/src/com/android/settings/homepage/CardContentProvider.java
new file mode 100644
index 0000000..3081ae1
--- /dev/null
+++ b/src/com/android/settings/homepage/CardContentProvider.java
@@ -0,0 +1,166 @@
+/*
+ * 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.homepage;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.UriMatcher;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteQueryBuilder;
+import android.net.Uri;
+import android.os.Build;
+import android.os.StrictMode;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+
+/**
+ * Provider stores and manages user interaction feedback for homepage contextual cards.
+ */
+public class CardContentProvider extends ContentProvider {
+
+    private static final String TAG = "CardContentProvider";
+
+    public static final String CARD_AUTHORITY = "com.android.settings.homepage.CardContentProvider";
+
+    /** URI matcher for ContentProvider queries. */
+    private static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
+    /** URI matcher type for cards table */
+    private static final int MATCH_CARDS = 100;
+    /** URI matcher type for card log table */
+    private static final int MATCH_CARD_LOG = 200;
+
+    static {
+        sUriMatcher.addURI(CARD_AUTHORITY, CardDatabaseHelper.CARD_TABLE, MATCH_CARDS);
+    }
+
+    private CardDatabaseHelper mDBHelper;
+
+    @Override
+    public boolean onCreate() {
+        mDBHelper = CardDatabaseHelper.getInstance(getContext());
+        return true;
+    }
+
+    @Override
+    public Uri insert(Uri uri, ContentValues values) {
+        final StrictMode.ThreadPolicy oldPolicy = StrictMode.getThreadPolicy();
+        try {
+            if (Build.IS_DEBUGGABLE) {
+                enableStrictMode(true);
+            }
+
+            final SQLiteDatabase database = mDBHelper.getWritableDatabase();
+            final String table = getTableFromMatch(uri);
+            final long ret = database.insert(table, null, values);
+            if (ret != -1) {
+                getContext().getContentResolver().notifyChange(uri, null);
+            } else {
+                Log.e(TAG, "The CardContentProvider insertion failed! Plase check SQLiteDatabase's "
+                        + "message.");
+            }
+        } finally {
+            StrictMode.setThreadPolicy(oldPolicy);
+        }
+        return uri;
+    }
+
+    @Override
+    public int delete(Uri uri, String selection, String[] selectionArgs) {
+        final StrictMode.ThreadPolicy oldPolicy = StrictMode.getThreadPolicy();
+        try {
+            if (Build.IS_DEBUGGABLE) {
+                enableStrictMode(true);
+            }
+
+            final SQLiteDatabase database = mDBHelper.getWritableDatabase();
+            final String table = getTableFromMatch(uri);
+            final int rowsDeleted = database.delete(table, selection, selectionArgs);
+            getContext().getContentResolver().notifyChange(uri, null);
+            return rowsDeleted;
+        } finally {
+            StrictMode.setThreadPolicy(oldPolicy);
+        }
+    }
+
+    @Override
+    public String getType(Uri uri) {
+        throw new UnsupportedOperationException("getType operation not supported currently.");
+    }
+
+    @Override
+    public Cursor query(Uri uri, String[] projection, String selection,
+            String[] selectionArgs, String sortOrder) {
+        final StrictMode.ThreadPolicy oldPolicy = StrictMode.getThreadPolicy();
+        try {
+            if (Build.IS_DEBUGGABLE) {
+                enableStrictMode(true);
+            }
+
+            final SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
+            final String table = getTableFromMatch(uri);
+            queryBuilder.setTables(table);
+            final SQLiteDatabase database = mDBHelper.getReadableDatabase();
+            final Cursor cursor = queryBuilder.query(database,
+                    projection, selection, selectionArgs, null, null, sortOrder);
+
+            cursor.setNotificationUri(getContext().getContentResolver(), uri);
+            return cursor;
+        } finally {
+            StrictMode.setThreadPolicy(oldPolicy);
+        }
+    }
+
+    @Override
+    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+        final StrictMode.ThreadPolicy oldPolicy = StrictMode.getThreadPolicy();
+        try {
+            if (Build.IS_DEBUGGABLE) {
+                enableStrictMode(true);
+            }
+
+            final SQLiteDatabase database = mDBHelper.getWritableDatabase();
+            final String table = getTableFromMatch(uri);
+            final int rowsUpdated = database.update(table, values, selection, selectionArgs);
+            getContext().getContentResolver().notifyChange(uri, null);
+            return rowsUpdated;
+        } finally {
+            StrictMode.setThreadPolicy(oldPolicy);
+        }
+    }
+
+    private void enableStrictMode(boolean enabled) {
+        StrictMode.setThreadPolicy(enabled
+                ? new StrictMode.ThreadPolicy.Builder().detectAll().build()
+                : StrictMode.ThreadPolicy.LAX);
+    }
+
+    @VisibleForTesting
+    String getTableFromMatch(Uri uri) {
+        final int match = sUriMatcher.match(uri);
+        String table;
+        switch (match) {
+            case MATCH_CARDS:
+                table = CardDatabaseHelper.CARD_TABLE;
+                break;
+            default:
+                throw new IllegalArgumentException("Unknown Uri format: " + uri);
+        }
+        return table;
+    }
+}
diff --git a/src/com/android/settings/homepage/CardDatabaseHelper.java b/src/com/android/settings/homepage/CardDatabaseHelper.java
new file mode 100644
index 0000000..b4dc221
--- /dev/null
+++ b/src/com/android/settings/homepage/CardDatabaseHelper.java
@@ -0,0 +1,190 @@
+/*
+ * 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.homepage;
+
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+
+import androidx.annotation.VisibleForTesting;
+
+/**
+ * Defines the schema for the Homepage Cards database.
+ */
+public class CardDatabaseHelper extends SQLiteOpenHelper {
+    private static final String DATABASE_NAME = "homepage_cards.db";
+    private static final int DATABASE_VERSION = 1;
+
+    public static final String CARD_TABLE = "cards";
+
+    public interface CardColumns {
+        /**
+         * Primary key. Name of the card.
+         */
+        String NAME = "name";
+
+        /**
+         * Type of the card.
+         */
+        String TYPE = "type";
+
+        /**
+         * Score of the card. Higher numbers have higher priorities.
+         */
+        String SCORE = "score";
+
+        /**
+         * URI of the slice card.
+         */
+        String SLICE_URI = "slice_uri";
+
+        /**
+         * Category of the card. The value is between 0 to 3.
+         */
+        String CATEGORY = "category";
+
+        /**
+         * URI decides the card can be shown.
+         */
+        String AVAILABILITY_URI = "availability_uri";
+
+        /**
+         * Keep the card last display's locale.
+         */
+        String LOCALIZED_TO_LOCALE = "localized_to_locale";
+
+        /**
+         * Package name for all card candidates.
+         */
+        String PACKAGE_NAME = "package_name";
+
+        /**
+         * Application version of the package.
+         */
+        String APP_VERSION = "app_version";
+
+        /**
+         * Title resource name of the package.
+         */
+        String TITLE_RES_NAME = "title_res_name";
+
+        /**
+         * Title of the package to be shown.
+         */
+        String TITLE_TEXT = "title_text";
+
+        /**
+         * Summary resource name of the package.
+         */
+        String SUMMARY_RES_NAME = "summary_res_name";
+
+        /**
+         * Summary of the package to be shown.
+         */
+        String SUMMARY_TEXT = "summary_text";
+
+        /**
+         * Icon resource name of the package.
+         */
+        String ICON_RES_NAME = "icon_res_name";
+
+        /**
+         * Icon resource id of the package.
+         */
+        String ICON_RES_ID = "icon_res_id";
+
+        /**
+         * PendingIntent for for custom view card candidate. Do action when user press card.
+         */
+        String CARD_ACTION = "card_action";
+
+        /**
+         * Expire time of the card. The unit of the value is mini-second.
+         */
+        String EXPIRE_TIME_MS = "expire_time_ms";
+    }
+
+    private static final String CREATE_CARD_TABLE =
+            "CREATE TABLE " + CARD_TABLE +
+                    "(" +
+                    CardColumns.NAME +
+                    " TEXT NOT NULL PRIMARY KEY, " +
+                    CardColumns.TYPE +
+                    " INTEGER NOT NULL, " +
+                    CardColumns.SCORE +
+                    " DOUBLE NOT NULL, " +
+                    CardColumns.SLICE_URI +
+                    " TEXT, " +
+                    CardColumns.CATEGORY +
+                    " INTEGER DEFAULT 0 CHECK (" +
+                    CardColumns.CATEGORY +
+                    " >= 0 AND " +
+                    CardColumns.CATEGORY +
+                    " <= 3), " +
+                    CardColumns.AVAILABILITY_URI +
+                    " TEXT, " +
+                    CardColumns.LOCALIZED_TO_LOCALE +
+                    " TEXT, " +
+                    CardColumns.PACKAGE_NAME +
+                    " TEXT NOT NULL, " +
+                    CardColumns.APP_VERSION +
+                    " TEXT NOT NULL, " +
+                    CardColumns.TITLE_RES_NAME +
+                    " TEXT, " +
+                    CardColumns.TITLE_TEXT +
+                    " TEXT, " +
+                    CardColumns.SUMMARY_RES_NAME +
+                    " TEXT, " +
+                    CardColumns.SUMMARY_TEXT +
+                    " TEXT, " +
+                    CardColumns.ICON_RES_NAME +
+                    " TEXT, " +
+                    CardColumns.ICON_RES_ID +
+                    " INTEGER DEFAULT 0, " +
+                    CardColumns.CARD_ACTION +
+                    " TEXT, " +
+                    CardColumns.EXPIRE_TIME_MS +
+                    " INTEGER " +
+                    ");";
+
+    public CardDatabaseHelper(Context context) {
+        super(context, DATABASE_NAME, null, DATABASE_VERSION);
+    }
+
+    @Override
+    public void onCreate(SQLiteDatabase db) {
+        db.execSQL(CREATE_CARD_TABLE);
+    }
+
+    @Override
+    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+        if (oldVersion < newVersion) {
+            db.execSQL("DROP TABLE IF EXISTS " + CARD_TABLE);
+            onCreate(db);
+        }
+    }
+
+    @VisibleForTesting
+    static CardDatabaseHelper sCardDatabaseHelper;
+
+    public static synchronized CardDatabaseHelper getInstance(Context context) {
+        if (sCardDatabaseHelper == null) {
+            sCardDatabaseHelper = new CardDatabaseHelper(context.getApplicationContext());
+        }
+        return sCardDatabaseHelper;
+    }
+}
diff --git a/src/com/android/settings/homepage/TopLevelSettings.java b/src/com/android/settings/homepage/TopLevelSettings.java
index 5c682cc..c450157 100644
--- a/src/com/android/settings/homepage/TopLevelSettings.java
+++ b/src/com/android/settings/homepage/TopLevelSettings.java
@@ -91,6 +91,12 @@
         return true;
     }
 
+    @Override
+    protected boolean shouldForceRoundedIcon() {
+        return getContext().getResources()
+                .getBoolean(R.bool.config_force_rounded_icon_TopLevelSettings);
+    }
+
     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider() {
                 @Override
diff --git a/src/com/android/settings/dashboard/conditional/AbnormalRingerConditionBase.java b/src/com/android/settings/homepage/conditional/AbnormalRingerConditionBase.java
similarity index 97%
rename from src/com/android/settings/dashboard/conditional/AbnormalRingerConditionBase.java
rename to src/com/android/settings/homepage/conditional/AbnormalRingerConditionBase.java
index eaec6d0..ef564fe 100644
--- a/src/com/android/settings/dashboard/conditional/AbnormalRingerConditionBase.java
+++ b/src/com/android/settings/homepage/conditional/AbnormalRingerConditionBase.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import android.content.BroadcastReceiver;
 import android.content.Context;
diff --git a/src/com/android/settings/dashboard/conditional/AirplaneModeCondition.java b/src/com/android/settings/homepage/conditional/AirplaneModeCondition.java
similarity index 98%
rename from src/com/android/settings/dashboard/conditional/AirplaneModeCondition.java
rename to src/com/android/settings/homepage/conditional/AirplaneModeCondition.java
index 792a090..9d21e43 100644
--- a/src/com/android/settings/dashboard/conditional/AirplaneModeCondition.java
+++ b/src/com/android/settings/homepage/conditional/AirplaneModeCondition.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import android.content.BroadcastReceiver;
 import android.content.Context;
diff --git a/src/com/android/settings/dashboard/conditional/BackgroundDataCondition.java b/src/com/android/settings/homepage/conditional/BackgroundDataCondition.java
similarity index 97%
rename from src/com/android/settings/dashboard/conditional/BackgroundDataCondition.java
rename to src/com/android/settings/homepage/conditional/BackgroundDataCondition.java
index d5372a2..84ae924 100644
--- a/src/com/android/settings/dashboard/conditional/BackgroundDataCondition.java
+++ b/src/com/android/settings/homepage/conditional/BackgroundDataCondition.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import android.content.Intent;
 import android.graphics.drawable.Drawable;
diff --git a/src/com/android/settings/dashboard/conditional/BatterySaverCondition.java b/src/com/android/settings/homepage/conditional/BatterySaverCondition.java
similarity index 98%
rename from src/com/android/settings/dashboard/conditional/BatterySaverCondition.java
rename to src/com/android/settings/homepage/conditional/BatterySaverCondition.java
index b0c1de4..1301b3d 100644
--- a/src/com/android/settings/dashboard/conditional/BatterySaverCondition.java
+++ b/src/com/android/settings/homepage/conditional/BatterySaverCondition.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import android.content.Intent;
 import android.graphics.drawable.Drawable;
diff --git a/src/com/android/settings/dashboard/conditional/CellularDataCondition.java b/src/com/android/settings/homepage/conditional/CellularDataCondition.java
similarity index 98%
rename from src/com/android/settings/dashboard/conditional/CellularDataCondition.java
rename to src/com/android/settings/homepage/conditional/CellularDataCondition.java
index bc0cbd5..7b382a7 100644
--- a/src/com/android/settings/dashboard/conditional/CellularDataCondition.java
+++ b/src/com/android/settings/homepage/conditional/CellularDataCondition.java
@@ -8,7 +8,7 @@
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
  */
 
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import android.content.BroadcastReceiver;
 import android.content.Context;
diff --git a/src/com/android/settings/dashboard/conditional/Condition.java b/src/com/android/settings/homepage/conditional/Condition.java
similarity index 98%
rename from src/com/android/settings/dashboard/conditional/Condition.java
rename to src/com/android/settings/homepage/conditional/Condition.java
index 82452ff..f91e422 100644
--- a/src/com/android/settings/dashboard/conditional/Condition.java
+++ b/src/com/android/settings/homepage/conditional/Condition.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import android.content.BroadcastReceiver;
 import android.content.Context;
@@ -22,12 +22,12 @@
 import android.graphics.drawable.Drawable;
 import android.os.PersistableBundle;
 
+import androidx.annotation.VisibleForTesting;
+
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
-import androidx.annotation.VisibleForTesting;
-
 public abstract class Condition {
 
     private static final String KEY_SILENCE = "silence";
diff --git a/src/com/android/settings/dashboard/conditional/ConditionAdapter.java b/src/com/android/settings/homepage/conditional/ConditionAdapter.java
similarity index 98%
rename from src/com/android/settings/dashboard/conditional/ConditionAdapter.java
rename to src/com/android/settings/homepage/conditional/ConditionAdapter.java
index a6478e2..e975146 100644
--- a/src/com/android/settings/dashboard/conditional/ConditionAdapter.java
+++ b/src/com/android/settings/homepage/conditional/ConditionAdapter.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import android.content.Context;
 import android.util.Log;
@@ -22,6 +22,10 @@
 import android.view.ViewGroup;
 import android.widget.Button;
 
+import androidx.annotation.VisibleForTesting;
+import androidx.recyclerview.widget.ItemTouchHelper;
+import androidx.recyclerview.widget.RecyclerView;
+
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardAdapter.DashboardItemHolder;
@@ -32,10 +36,6 @@
 import java.util.List;
 import java.util.Objects;
 
-import androidx.annotation.VisibleForTesting;
-import androidx.recyclerview.widget.ItemTouchHelper;
-import androidx.recyclerview.widget.RecyclerView;
-
 public class ConditionAdapter extends RecyclerView.Adapter<DashboardItemHolder> {
     public static final String TAG = "ConditionAdapter";
 
diff --git a/src/com/android/settings/homepage/conditional/ConditionListener.java b/src/com/android/settings/homepage/conditional/ConditionListener.java
new file mode 100644
index 0000000..1e5ec1f
--- /dev/null
+++ b/src/com/android/settings/homepage/conditional/ConditionListener.java
@@ -0,0 +1,21 @@
+/*
+ * 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.homepage.conditional;
+
+public interface ConditionListener {
+    void onConditionsChanged();
+}
diff --git a/src/com/android/settings/dashboard/conditional/ConditionManager.java b/src/com/android/settings/homepage/conditional/ConditionManager.java
similarity index 94%
rename from src/com/android/settings/dashboard/conditional/ConditionManager.java
rename to src/com/android/settings/homepage/conditional/ConditionManager.java
index 2754d8a..dbb04ae 100644
--- a/src/com/android/settings/dashboard/conditional/ConditionManager.java
+++ b/src/com/android/settings/homepage/conditional/ConditionManager.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import android.content.Context;
 import android.os.AsyncTask;
@@ -44,7 +44,7 @@
 
     private static final boolean DEBUG = false;
 
-    private static final String PKG = "com.android.settings.dashboard.conditional.";
+    private static final String PKG = "com.android.settings.homepage.conditional.";
 
     private static final String FILE_NAME = "condition_state.xml";
     private static final String TAG_CONDITIONS = "cs";
@@ -217,17 +217,6 @@
         return mConditions;
     }
 
-    public List<Condition> getVisibleConditions() {
-        List<Condition> conditions = new ArrayList<>();
-        final int N = mConditions.size();
-        for (int i = 0; i < N; i++) {
-            if (mConditions.get(i).shouldShow()) {
-                conditions.add(mConditions.get(i));
-            }
-        }
-        return conditions;
-    }
-
     public void notifyChanged(Condition condition) {
         saveToXml();
         Collections.sort(mConditions, CONDITION_COMPARATOR);
@@ -293,10 +282,6 @@
         return sInstance;
     }
 
-    public interface ConditionListener {
-        void onConditionsChanged();
-    }
-
     private static final Comparator<Condition> CONDITION_COMPARATOR = new Comparator<Condition>() {
         @Override
         public int compare(Condition lhs, Condition rhs) {
diff --git a/src/com/android/settings/dashboard/conditional/DndCondition.java b/src/com/android/settings/homepage/conditional/DndCondition.java
similarity index 98%
rename from src/com/android/settings/dashboard/conditional/DndCondition.java
rename to src/com/android/settings/homepage/conditional/DndCondition.java
index 32184e1..3e8052b 100644
--- a/src/com/android/settings/dashboard/conditional/DndCondition.java
+++ b/src/com/android/settings/homepage/conditional/DndCondition.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import android.app.NotificationManager;
 import android.content.BroadcastReceiver;
@@ -26,13 +26,13 @@
 import android.provider.Settings.Global;
 import android.service.notification.ZenModeConfig;
 
+import androidx.annotation.VisibleForTesting;
+
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.core.SubSettingLauncher;
 import com.android.settings.notification.ZenModeSettings;
 
-import androidx.annotation.VisibleForTesting;
-
 public class DndCondition extends Condition {
 
     private static final String TAG = "DndCondition";
diff --git a/src/com/android/settings/dashboard/conditional/FocusRecyclerView.java b/src/com/android/settings/homepage/conditional/FocusRecyclerView.java
similarity index 96%
rename from src/com/android/settings/dashboard/conditional/FocusRecyclerView.java
rename to src/com/android/settings/homepage/conditional/FocusRecyclerView.java
index abe4743..78b9eed 100644
--- a/src/com/android/settings/dashboard/conditional/FocusRecyclerView.java
+++ b/src/com/android/settings/homepage/conditional/FocusRecyclerView.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import android.content.Context;
 import android.util.AttributeSet;
diff --git a/src/com/android/settings/dashboard/conditional/HotspotCondition.java b/src/com/android/settings/homepage/conditional/HotspotCondition.java
similarity index 98%
rename from src/com/android/settings/dashboard/conditional/HotspotCondition.java
rename to src/com/android/settings/homepage/conditional/HotspotCondition.java
index 68f2382..7212e84 100644
--- a/src/com/android/settings/dashboard/conditional/HotspotCondition.java
+++ b/src/com/android/settings/homepage/conditional/HotspotCondition.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import android.content.BroadcastReceiver;
 import android.content.Context;
diff --git a/src/com/android/settings/dashboard/conditional/NightDisplayCondition.java b/src/com/android/settings/homepage/conditional/NightDisplayCondition.java
similarity index 97%
rename from src/com/android/settings/dashboard/conditional/NightDisplayCondition.java
rename to src/com/android/settings/homepage/conditional/NightDisplayCondition.java
index c3ba534..9576973 100644
--- a/src/com/android/settings/dashboard/conditional/NightDisplayCondition.java
+++ b/src/com/android/settings/homepage/conditional/NightDisplayCondition.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import android.content.Intent;
 import android.graphics.drawable.Drawable;
diff --git a/src/com/android/settings/dashboard/conditional/RingerMutedCondition.java b/src/com/android/settings/homepage/conditional/RingerMutedCondition.java
similarity index 97%
rename from src/com/android/settings/dashboard/conditional/RingerMutedCondition.java
rename to src/com/android/settings/homepage/conditional/RingerMutedCondition.java
index 7f7bc2b..740e6e4 100644
--- a/src/com/android/settings/dashboard/conditional/RingerMutedCondition.java
+++ b/src/com/android/settings/homepage/conditional/RingerMutedCondition.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import static android.content.Context.NOTIFICATION_SERVICE;
 
diff --git a/src/com/android/settings/dashboard/conditional/RingerVibrateCondition.java b/src/com/android/settings/homepage/conditional/RingerVibrateCondition.java
similarity index 96%
rename from src/com/android/settings/dashboard/conditional/RingerVibrateCondition.java
rename to src/com/android/settings/homepage/conditional/RingerVibrateCondition.java
index 6af05c1..ea91c0e 100644
--- a/src/com/android/settings/dashboard/conditional/RingerVibrateCondition.java
+++ b/src/com/android/settings/homepage/conditional/RingerVibrateCondition.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import android.graphics.drawable.Drawable;
 import android.media.AudioManager;
diff --git a/src/com/android/settings/dashboard/conditional/WorkModeCondition.java b/src/com/android/settings/homepage/conditional/WorkModeCondition.java
similarity index 98%
rename from src/com/android/settings/dashboard/conditional/WorkModeCondition.java
rename to src/com/android/settings/homepage/conditional/WorkModeCondition.java
index 941d5b0..9e467fa 100644
--- a/src/com/android/settings/dashboard/conditional/WorkModeCondition.java
+++ b/src/com/android/settings/homepage/conditional/WorkModeCondition.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import android.content.Context;
 import android.content.Intent;
diff --git a/src/com/android/settings/language/LanguageAndInputSettings.java b/src/com/android/settings/language/LanguageAndInputSettings.java
index c983c07..6c7c0d3 100644
--- a/src/com/android/settings/language/LanguageAndInputSettings.java
+++ b/src/com/android/settings/language/LanguageAndInputSettings.java
@@ -27,10 +27,10 @@
 import android.text.TextUtils;
 import android.view.inputmethod.InputMethodInfo;
 import android.view.inputmethod.InputMethodManager;
-
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
 import com.android.internal.logging.nano.MetricsProto;
 import com.android.settings.R;
-import com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.dashboard.SummaryLoader;
 import com.android.settings.inputmethod.PhysicalKeyboardPreferenceController;
@@ -41,14 +41,10 @@
 import com.android.settingslib.core.AbstractPreferenceController;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.search.SearchIndexable;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
 @SearchIndexable
 public class LanguageAndInputSettings extends DashboardFragment {
 
@@ -122,7 +118,6 @@
 
         // Input Assistance
         controllers.add(new SpellCheckerPreferenceController(context));
-        controllers.add(new DefaultAutofillPreferenceController(context));
 
         return controllers;
     }
diff --git a/src/com/android/settings/location/LocationSliceBuilder.java b/src/com/android/settings/location/LocationSliceBuilder.java
index cbdf7f0..4883ee8 100644
--- a/src/com/android/settings/location/LocationSliceBuilder.java
+++ b/src/com/android/settings/location/LocationSliceBuilder.java
@@ -37,6 +37,7 @@
 import androidx.core.graphics.drawable.IconCompat;
 import androidx.slice.Slice;
 import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.ListBuilder.RowBuilder;
 import androidx.slice.builders.SliceAction;
 
 /**
@@ -70,7 +71,7 @@
 
         return new ListBuilder(context, LOCATION_URI, ListBuilder.INFINITY)
                 .setAccentColor(color)
-                .addRow(b -> b
+                .addRow(new RowBuilder()
                         .setTitle(title)
                         .setTitleItem(icon, ICON_IMAGE)
                         .setPrimaryAction(primarySliceAction))
diff --git a/src/com/android/settings/mobilenetwork/Enhanced4gLteSliceHelper.java b/src/com/android/settings/mobilenetwork/Enhanced4gLteSliceHelper.java
index f8f1447..960a082 100644
--- a/src/com/android/settings/mobilenetwork/Enhanced4gLteSliceHelper.java
+++ b/src/com/android/settings/mobilenetwork/Enhanced4gLteSliceHelper.java
@@ -49,6 +49,7 @@
 import androidx.core.graphics.drawable.IconCompat;
 import androidx.slice.Slice;
 import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.ListBuilder.RowBuilder;
 import androidx.slice.builders.SliceAction;
 
 /**
@@ -183,7 +184,7 @@
 
         return new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
                 .setAccentColor(Utils.getColorAccentDefaultColor(mContext))
-                .addRow(b -> b
+                .addRow(new RowBuilder()
                         .setTitle(getEnhanced4glteModeTitle(subId))
                         .addEndItem(
                                 new SliceAction(
diff --git a/src/com/android/settings/notification/ZenModeSliceBuilder.java b/src/com/android/settings/notification/ZenModeSliceBuilder.java
index ad39d71..dcdf6ef 100644
--- a/src/com/android/settings/notification/ZenModeSliceBuilder.java
+++ b/src/com/android/settings/notification/ZenModeSliceBuilder.java
@@ -40,6 +40,7 @@
 import androidx.core.graphics.drawable.IconCompat;
 import androidx.slice.Slice;
 import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.ListBuilder.RowBuilder;
 import androidx.slice.builders.SliceAction;
 
 public class ZenModeSliceBuilder {
@@ -94,7 +95,7 @@
 
         return new ListBuilder(context, ZEN_MODE_URI, ListBuilder.INFINITY)
                 .setAccentColor(color)
-                .addRow(b -> b
+                .addRow(new RowBuilder()
                         .setTitle(title)
                         .addEndItem(toggleSliceAction)
                         .setPrimaryAction(primarySliceAction))
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index 65d72f1..f5b3b05 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -23,6 +23,7 @@
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
+import android.os.UserHandle;
 import android.os.UserManager;
 import android.util.Log;
 
@@ -70,7 +71,7 @@
                 KeyguardManager.EXTRA_ALTERNATE_BUTTON_LABEL);
         boolean frp = KeyguardManager.ACTION_CONFIRM_FRP_CREDENTIAL.equals(intent.getAction());
 
-        int userId = Utils.getCredentialOwnerUserId(this);
+        int userId = UserHandle.myUserId();
         if (isInternalActivity()) {
             try {
                 userId = Utils.getUserIdFromBundle(this, intent.getExtras());
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
index 0f6eeb3..23bc26f 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
@@ -125,8 +125,7 @@
         mCancelButton = (Button) view.findViewById(R.id.cancelButton);
         mFingerprintIcon = (ImageView) view.findViewById(R.id.fingerprintIcon);
         mFingerprintHelper = new FingerprintUiHelper(
-                mFingerprintIcon,
-                (TextView) view.findViewById(R.id.errorText), this, mEffectiveUserId);
+                mFingerprintIcon, view.findViewById(R.id.errorText), this, mUserId);
         boolean showCancelButton = getActivity().getIntent().getBooleanExtra(
                 SHOW_CANCEL_BUTTON, false);
         boolean hasAlternateButton = mFrp && !TextUtils.isEmpty(mFrpAlternateButtonText);
diff --git a/src/com/android/settings/security/TopLevelSecurityEntryPreferenceController.java b/src/com/android/settings/security/TopLevelSecurityEntryPreferenceController.java
new file mode 100644
index 0000000..4b00424
--- /dev/null
+++ b/src/com/android/settings/security/TopLevelSecurityEntryPreferenceController.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.security;
+
+import android.content.Context;
+import android.hardware.face.FaceManager;
+import android.hardware.fingerprint.FingerprintManager;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.core.BasePreferenceController;
+
+public class TopLevelSecurityEntryPreferenceController extends BasePreferenceController {
+
+    public TopLevelSecurityEntryPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE_UNSEARCHABLE;
+    }
+
+    @Override
+    public CharSequence getSummary() {
+        final FingerprintManager fpm =
+                Utils.getFingerprintManagerOrNull(mContext);
+        final FaceManager faceManager =
+                Utils.getFaceManagerOrNull(mContext);
+        if (faceManager != null && faceManager.isHardwareDetected()) {
+            return mContext.getText(R.string.security_dashboard_summary_face);
+        } else if (fpm != null && fpm.isHardwareDetected()) {
+            return mContext.getText(R.string.security_dashboard_summary);
+        } else {
+            return mContext.getText(R.string.security_dashboard_summary_no_fingerprint);
+        }
+    }
+}
diff --git a/src/com/android/settings/slices/SliceBuilderUtils.java b/src/com/android/settings/slices/SliceBuilderUtils.java
index c1c3b8e8..b613ca4 100644
--- a/src/com/android/settings/slices/SliceBuilderUtils.java
+++ b/src/com/android/settings/slices/SliceBuilderUtils.java
@@ -29,6 +29,7 @@
 import android.os.Bundle;
 import android.provider.SettingsSlicesContract;
 import android.text.TextUtils;
+import android.util.ArraySet;
 import android.util.Log;
 import android.util.Pair;
 
@@ -47,12 +48,15 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.core.graphics.drawable.IconCompat;
 import androidx.slice.Slice;
 import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.ListBuilder.InputRangeBuilder;
+import androidx.slice.builders.ListBuilder.RowBuilder;
 import androidx.slice.builders.SliceAction;
 
 
@@ -250,11 +254,11 @@
                 (TogglePreferenceController) controller;
         final SliceAction sliceAction = getToggleAction(context, sliceData,
                 toggleController.isChecked());
-        final List<String> keywords = buildSliceKeywords(sliceData);
+        final Set<String> keywords = buildSliceKeywords(sliceData);
 
         return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY)
                 .setAccentColor(color)
-                .addRow(rowBuilder -> rowBuilder
+                .addRow(new RowBuilder()
                         .setTitle(sliceData.getTitle())
                         .setSubtitle(subtitleText)
                         .setPrimaryAction(
@@ -270,11 +274,11 @@
         final IconCompat icon = getSafeIcon(context, sliceData);
         final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
         @ColorInt final int color = Utils.getColorAccentDefaultColor(context);
-        final List<String> keywords = buildSliceKeywords(sliceData);
+        final Set<String> keywords = buildSliceKeywords(sliceData);
 
         return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY)
                 .setAccentColor(color)
-                .addRow(rowBuilder -> rowBuilder
+                .addRow(new RowBuilder()
                         .setTitle(sliceData.getTitle())
                         .setSubtitle(subtitleText)
                         .setPrimaryAction(
@@ -293,11 +297,11 @@
         final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
         final SliceAction primaryAction = new SliceAction(contentIntent, icon,
                 sliceData.getTitle());
-        final List<String> keywords = buildSliceKeywords(sliceData);
+        final Set<String> keywords = buildSliceKeywords(sliceData);
 
         return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY)
                 .setAccentColor(color)
-                .addInputRange(builder -> builder
+                .addInputRange(new InputRangeBuilder()
                         .setTitle(sliceData.getTitle())
                         .setSubtitle(subtitleText)
                         .setPrimaryAction(primaryAction)
@@ -343,8 +347,8 @@
                 || TextUtils.equals(summary, doublePlaceHolder));
     }
 
-    private static List<String> buildSliceKeywords(SliceData data) {
-        final List<String> keywords = new ArrayList<>();
+    private static Set<String> buildSliceKeywords(SliceData data) {
+        final Set<String> keywords = new ArraySet<>();
 
         keywords.add(data.getTitle());
 
@@ -366,7 +370,7 @@
 
     private static Slice buildUnavailableSlice(Context context, SliceData data) {
         final String title = data.getTitle();
-        final List<String> keywords = buildSliceKeywords(data);
+        final Set<String> keywords = buildSliceKeywords(data);
         @ColorInt final int color = Utils.getColorAccentDefaultColor(context);
         final CharSequence summary = context.getText(R.string.disabled_dependent_setting_summary);
         final IconCompat icon = IconCompat.createWithResource(context, data.getIconResource());
@@ -375,9 +379,9 @@
 
         return new ListBuilder(context, data.getUri(), ListBuilder.INFINITY)
                 .setAccentColor(color)
-                .addRow(builder -> builder
+                .addRow(new RowBuilder()
                         .setTitle(title)
-                        .setTitleItem(icon)
+                        .setTitleItem(icon, ListBuilder.SMALL_IMAGE)
                         .setSubtitle(summary)
                         .setPrimaryAction(primaryAction))
                 .setKeywords(keywords)
diff --git a/src/com/android/settings/widget/RoundedHomepageIcon.java b/src/com/android/settings/widget/RoundedHomepageIcon.java
new file mode 100644
index 0000000..f7927e7
--- /dev/null
+++ b/src/com/android/settings/widget/RoundedHomepageIcon.java
@@ -0,0 +1,86 @@
+/*
+ * 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 androidx.annotation.VisibleForTesting.NONE;
+
+import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_ICON_BACKGROUND_ARGB;
+import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_ICON_BACKGROUND_HINT;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.LayerDrawable;
+import android.os.Bundle;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+
+import com.android.settings.R;
+import com.android.settingslib.drawer.Tile;
+
+public class RoundedHomepageIcon extends LayerDrawable {
+
+    private static final String TAG = "RoundedHomepageIcon";
+
+    @VisibleForTesting(otherwise = NONE)
+    int mBackgroundColor = -1;
+
+    public RoundedHomepageIcon(Context context, Drawable foreground) {
+        super(new Drawable[]{
+                context.getDrawable(R.drawable.ic_homepage_generic_background),
+                foreground
+        });
+        final int insetPx = context.getResources()
+                .getDimensionPixelSize(R.dimen.dashboard_tile_foreground_image_inset);
+        setLayerInset(1 /* index */, insetPx, insetPx, insetPx, insetPx);
+    }
+
+    public void setBackgroundColor(Context context, Tile tile) {
+        final Bundle metaData = tile.getMetaData();
+        try {
+            if (metaData != null) {
+                // Load from bg.argb first
+                int bgColor = metaData.getInt(META_DATA_PREFERENCE_ICON_BACKGROUND_ARGB,
+                        0 /* default */);
+                // Not found, load from bg.hint
+                if (bgColor == 0) {
+                    final int colorRes = metaData.getInt(META_DATA_PREFERENCE_ICON_BACKGROUND_HINT,
+                            0 /* default */);
+                    if (colorRes != 0) {
+                        bgColor = context.getPackageManager()
+                                .getResourcesForApplication(tile.getPackageName())
+                                .getColor(colorRes, null /* theme */);
+                    }
+                }
+                // If found anything, use it.
+                if (bgColor != 0) {
+                    setBackgroundColor(bgColor);
+                }
+            }
+        } catch (PackageManager.NameNotFoundException e) {
+            Log.e(TAG, "Failed to set background color for " + tile.getPackageName());
+        }
+    }
+
+    public void setBackgroundColor(int color) {
+        mBackgroundColor = color;
+        getDrawable(0).setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
+        Log.d(TAG, "Setting background color " + mBackgroundColor);
+    }
+}
diff --git a/src/com/android/settings/widget/SettingsAppWidgetProvider.java b/src/com/android/settings/widget/SettingsAppWidgetProvider.java
deleted file mode 100644
index b8730b9..0000000
--- a/src/com/android/settings/widget/SettingsAppWidgetProvider.java
+++ /dev/null
@@ -1,946 +0,0 @@
-/*
- * Copyright (C) 2009 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.app.PendingIntent;
-import android.appwidget.AppWidgetManager;
-import android.appwidget.AppWidgetProvider;
-import android.bluetooth.BluetoothAdapter;
-import android.content.ComponentName;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.Intent;
-import android.database.ContentObserver;
-import android.hardware.display.DisplayManager;
-import android.location.LocationManager;
-import android.net.ConnectivityManager;
-import android.net.Uri;
-import android.net.wifi.WifiManager;
-import android.os.AsyncTask;
-import android.os.Handler;
-import android.os.PowerManager;
-import android.os.Process;
-import android.os.UserManager;
-import android.provider.Settings;
-import android.util.Log;
-import android.widget.RemoteViews;
-
-import com.android.settings.R;
-
-/**
- * Provides control of power-related settings from a widget.
- */
-public class SettingsAppWidgetProvider extends AppWidgetProvider {
-    static final String TAG = "SettingsAppWidgetProvider";
-
-    static final ComponentName THIS_APPWIDGET =
-            new ComponentName("com.android.settings",
-                    "com.android.settings.widget.SettingsAppWidgetProvider");
-
-    private static BluetoothAdapter sBluetoothAdapter = null;
-
-    private static final int BUTTON_WIFI = 0;
-    private static final int BUTTON_BRIGHTNESS = 1;
-    private static final int BUTTON_SYNC = 2;
-    private static final int BUTTON_LOCATION = 3;
-    private static final int BUTTON_BLUETOOTH = 4;
-
-    // This widget keeps track of two sets of states:
-    // "3-state": STATE_DISABLED, STATE_ENABLED, STATE_INTERMEDIATE
-    // "5-state": STATE_DISABLED, STATE_ENABLED, STATE_TURNING_ON, STATE_TURNING_OFF, STATE_UNKNOWN
-    private static final int STATE_DISABLED = 0;
-    private static final int STATE_ENABLED = 1;
-    private static final int STATE_TURNING_ON = 2;
-    private static final int STATE_TURNING_OFF = 3;
-    private static final int STATE_UNKNOWN = 4;
-    private static final int STATE_INTERMEDIATE = 5;
-
-    // Position in the widget bar, to enable different graphics for left, center and right buttons
-    private static final int POS_LEFT = 0;
-    private static final int POS_CENTER = 1;
-    private static final int POS_RIGHT = 2;
-
-    private static final int[] IND_DRAWABLE_OFF = {
-        R.drawable.appwidget_settings_ind_off_l_holo,
-        R.drawable.appwidget_settings_ind_off_c_holo,
-        R.drawable.appwidget_settings_ind_off_r_holo
-    };
-
-    private static final int[] IND_DRAWABLE_MID = {
-        R.drawable.appwidget_settings_ind_mid_l_holo,
-        R.drawable.appwidget_settings_ind_mid_c_holo,
-        R.drawable.appwidget_settings_ind_mid_r_holo
-    };
-
-    private static final int[] IND_DRAWABLE_ON = {
-        R.drawable.appwidget_settings_ind_on_l_holo,
-        R.drawable.appwidget_settings_ind_on_c_holo,
-        R.drawable.appwidget_settings_ind_on_r_holo
-    };
-
-    /** Minimum brightness at which the indicator is shown at half-full and ON */
-    private static final float HALF_BRIGHTNESS_THRESHOLD = 0.3f;
-    /** Minimum brightness at which the indicator is shown at full */
-    private static final float FULL_BRIGHTNESS_THRESHOLD = 0.8f;
-
-    private static final StateTracker sWifiState = new WifiStateTracker();
-    private static final StateTracker sBluetoothState = new BluetoothStateTracker();
-    private static final StateTracker sLocationState = new LocationStateTracker();
-    private static final StateTracker sSyncState = new SyncStateTracker();
-    private static SettingsObserver sSettingsObserver;
-
-    /**
-     * The state machine for a setting's toggling, tracking reality
-     * versus the user's intent.
-     *
-     * This is necessary because reality moves relatively slowly
-     * (turning on &amp; off radio drivers), compared to user's
-     * expectations.
-     */
-    private abstract static class StateTracker {
-        // Is the state in the process of changing?
-        private boolean mInTransition = false;
-        private Boolean mActualState = null;  // initially not set
-        private Boolean mIntendedState = null;  // initially not set
-
-        // Did a toggle request arrive while a state update was
-        // already in-flight?  If so, the mIntendedState needs to be
-        // requested when the other one is done, unless we happened to
-        // arrive at that state already.
-        private boolean mDeferredStateChangeRequestNeeded = false;
-
-        /**
-         * User pressed a button to change the state.  Something
-         * should immediately appear to the user afterwards, even if
-         * we effectively do nothing.  Their press must be heard.
-         */
-        public final void toggleState(Context context) {
-            int currentState = getTriState(context);
-            boolean newState = false;
-            switch (currentState) {
-                case STATE_ENABLED:
-                    newState = false;
-                    break;
-                case STATE_DISABLED:
-                    newState = true;
-                    break;
-                case STATE_INTERMEDIATE:
-                    if (mIntendedState != null) {
-                        newState = !mIntendedState;
-                    }
-                    break;
-            }
-            mIntendedState = newState;
-            if (mInTransition) {
-                // We don't send off a transition request if we're
-                // already transitioning.  Makes our state tracking
-                // easier, and is probably nicer on lower levels.
-                // (even though they should be able to take it...)
-                mDeferredStateChangeRequestNeeded = true;
-            } else {
-                mInTransition = true;
-                requestStateChange(context, newState);
-            }
-        }
-
-        /**
-         * Return the ID of the clickable container for the setting.
-         */
-        public abstract int getContainerId();
-
-        /**
-         * Return the ID of the main large image button for the setting.
-         */
-        public abstract int getButtonId();
-
-        /**
-         * Returns the small indicator image ID underneath the setting.
-         */
-        public abstract int getIndicatorId();
-
-        /**
-         * Returns the resource ID of the setting's content description.
-         */
-        public abstract int getButtonDescription();
-
-        /**
-         * Returns the resource ID of the image to show as a function of
-         * the on-vs-off state.
-         */
-        public abstract int getButtonImageId(boolean on);
-
-        /**
-         * Returns the position in the button bar - either POS_LEFT, POS_RIGHT or POS_CENTER.
-         */
-        public int getPosition() { return POS_CENTER; }
-
-        /**
-         * Updates the remote views depending on the state (off, on,
-         * turning off, turning on) of the setting.
-         */
-        public final void setImageViewResources(Context context, RemoteViews views) {
-            int containerId = getContainerId();
-            int buttonId = getButtonId();
-            int indicatorId = getIndicatorId();
-            int pos = getPosition();
-            switch (getTriState(context)) {
-                case STATE_DISABLED:
-                    views.setContentDescription(containerId,
-                        getContentDescription(context, R.string.gadget_state_off));
-                    views.setImageViewResource(buttonId, getButtonImageId(false));
-                    views.setImageViewResource(
-                        indicatorId, IND_DRAWABLE_OFF[pos]);
-                    break;
-                case STATE_ENABLED:
-                    views.setContentDescription(containerId,
-                        getContentDescription(context, R.string.gadget_state_on));
-                    views.setImageViewResource(buttonId, getButtonImageId(true));
-                    views.setImageViewResource(
-                        indicatorId, IND_DRAWABLE_ON[pos]);
-                    break;
-                case STATE_INTERMEDIATE:
-                    // In the transitional state, the bottom green bar
-                    // shows the tri-state (on, off, transitioning), but
-                    // the top dark-gray-or-bright-white logo shows the
-                    // user's intent.  This is much easier to see in
-                    // sunlight.
-                    if (isTurningOn()) {
-                        views.setContentDescription(containerId,
-                            getContentDescription(context, R.string.gadget_state_turning_on));
-                        views.setImageViewResource(buttonId, getButtonImageId(true));
-                        views.setImageViewResource(
-                            indicatorId, IND_DRAWABLE_MID[pos]);
-                    } else {
-                        views.setContentDescription(containerId,
-                            getContentDescription(context, R.string.gadget_state_turning_off));
-                        views.setImageViewResource(buttonId, getButtonImageId(false));
-                        views.setImageViewResource(
-                            indicatorId, IND_DRAWABLE_OFF[pos]);
-                    }
-                    break;
-            }
-        }
-
-        /**
-         * Returns the gadget state template populated with the gadget
-         * description and state.
-         */
-        private final String getContentDescription(Context context, int stateResId) {
-            final String gadget = context.getString(getButtonDescription());
-            final String state = context.getString(stateResId);
-            return context.getString(R.string.gadget_state_template, gadget, state);
-        }
-
-        /**
-         * Update internal state from a broadcast state change.
-         */
-        public abstract void onActualStateChange(Context context, Intent intent);
-
-        /**
-         * Sets the value that we're now in.  To be called from onActualStateChange.
-         *
-         * @param newState one of STATE_DISABLED, STATE_ENABLED, STATE_TURNING_ON,
-         *                 STATE_TURNING_OFF, STATE_UNKNOWN
-         */
-        protected final void setCurrentState(Context context, int newState) {
-            final boolean wasInTransition = mInTransition;
-            switch (newState) {
-                case STATE_DISABLED:
-                    mInTransition = false;
-                    mActualState = false;
-                    break;
-                case STATE_ENABLED:
-                    mInTransition = false;
-                    mActualState = true;
-                    break;
-                case STATE_TURNING_ON:
-                    mInTransition = true;
-                    mActualState = false;
-                    break;
-                case STATE_TURNING_OFF:
-                    mInTransition = true;
-                    mActualState = true;
-                    break;
-            }
-
-            if (wasInTransition && !mInTransition) {
-                if (mDeferredStateChangeRequestNeeded) {
-                    Log.v(TAG, "processing deferred state change");
-                    if (mActualState != null && mIntendedState != null &&
-                        mIntendedState.equals(mActualState)) {
-                        Log.v(TAG, "... but intended state matches, so no changes.");
-                    } else if (mIntendedState != null) {
-                        mInTransition = true;
-                        requestStateChange(context, mIntendedState);
-                    }
-                    mDeferredStateChangeRequestNeeded = false;
-                }
-            }
-        }
-
-
-        /**
-         * If we're in a transition mode, this returns true if we're
-         * transitioning towards being enabled.
-         */
-        public final boolean isTurningOn() {
-            return mIntendedState != null && mIntendedState;
-        }
-
-        /**
-         * Returns simplified 3-state value from underlying 5-state.
-         *
-         * @param context
-         * @return STATE_ENABLED, STATE_DISABLED, or STATE_INTERMEDIATE
-         */
-        public final int getTriState(Context context) {
-            if (mInTransition) {
-                // If we know we just got a toggle request recently
-                // (which set mInTransition), don't even ask the
-                // underlying interface for its state.  We know we're
-                // changing.  This avoids blocking the UI thread
-                // during UI refresh post-toggle if the underlying
-                // service state accessor has coarse locking on its
-                // state (to be fixed separately).
-                return STATE_INTERMEDIATE;
-            }
-            switch (getActualState(context)) {
-                case STATE_DISABLED:
-                    return STATE_DISABLED;
-                case STATE_ENABLED:
-                    return STATE_ENABLED;
-                default:
-                    return STATE_INTERMEDIATE;
-            }
-        }
-
-        /**
-         * Gets underlying actual state.
-         *
-         * @param context
-         * @return STATE_ENABLED, STATE_DISABLED, STATE_ENABLING, STATE_DISABLING,
-         *         or or STATE_UNKNOWN.
-         */
-        public abstract int getActualState(Context context);
-
-        /**
-         * Actually make the desired change to the underlying radio
-         * API.
-         */
-        protected abstract void requestStateChange(Context context, boolean desiredState);
-    }
-
-    /**
-     * Subclass of StateTracker to get/set Wifi state.
-     */
-    private static final class WifiStateTracker extends StateTracker {
-        public int getContainerId() { return R.id.btn_wifi; }
-        public int getButtonId() { return R.id.img_wifi; }
-        public int getIndicatorId() { return R.id.ind_wifi; }
-        public int getButtonDescription() { return R.string.gadget_wifi; }
-        public int getButtonImageId(boolean on) {
-            return on ? R.drawable.ic_appwidget_settings_wifi_on_holo
-                    : R.drawable.ic_appwidget_settings_wifi_off_holo;
-        }
-
-        @Override
-        public int getPosition() { return POS_LEFT; }
-
-        @Override
-        public int getActualState(Context context) {
-            WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
-            if (wifiManager != null) {
-                return wifiStateToFiveState(wifiManager.getWifiState());
-            }
-            return STATE_UNKNOWN;
-        }
-
-        @Override
-        protected void requestStateChange(Context context, final boolean desiredState) {
-            final WifiManager wifiManager =
-                    (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
-            if (wifiManager == null) {
-                Log.d(TAG, "No wifiManager.");
-                return;
-            }
-
-            // Actually request the wifi change and persistent
-            // settings write off the UI thread, as it can take a
-            // user-noticeable amount of time, especially if there's
-            // disk contention.
-            new AsyncTask<Void, Void, Void>() {
-                @Override
-                protected Void doInBackground(Void... args) {
-                    /**
-                     * Disable tethering if enabling Wifi
-                     */
-                    int wifiApState = wifiManager.getWifiApState();
-                    if (desiredState && ((wifiApState == WifiManager.WIFI_AP_STATE_ENABLING) ||
-                                         (wifiApState == WifiManager.WIFI_AP_STATE_ENABLED))) {
-                        final ConnectivityManager connectivityManager =
-                                (ConnectivityManager) context.getSystemService(
-                                        Context.CONNECTIVITY_SERVICE);
-                        connectivityManager.stopTethering(ConnectivityManager.TETHERING_WIFI);
-                    }
-
-                    wifiManager.setWifiEnabled(desiredState);
-                    return null;
-                }
-            }.execute();
-        }
-
-        @Override
-        public void onActualStateChange(Context context, Intent intent) {
-            if (!WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
-                return;
-            }
-            int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, -1);
-            setCurrentState(context, wifiStateToFiveState(wifiState));
-        }
-
-        /**
-         * Converts WifiManager's state values into our
-         * Wifi/Bluetooth-common state values.
-         */
-        private static int wifiStateToFiveState(int wifiState) {
-            switch (wifiState) {
-                case WifiManager.WIFI_STATE_DISABLED:
-                    return STATE_DISABLED;
-                case WifiManager.WIFI_STATE_ENABLED:
-                    return STATE_ENABLED;
-                case WifiManager.WIFI_STATE_DISABLING:
-                    return STATE_TURNING_OFF;
-                case WifiManager.WIFI_STATE_ENABLING:
-                    return STATE_TURNING_ON;
-                default:
-                    return STATE_UNKNOWN;
-            }
-        }
-    }
-
-    /**
-     * Subclass of StateTracker to get/set Bluetooth state.
-     */
-    private static final class BluetoothStateTracker extends StateTracker {
-        public int getContainerId() { return R.id.btn_bluetooth; }
-        public int getButtonId() { return R.id.img_bluetooth; }
-        public int getIndicatorId() { return R.id.ind_bluetooth; }
-        public int getButtonDescription() { return R.string.gadget_bluetooth; }
-        public int getButtonImageId(boolean on) {
-            return on ? R.drawable.ic_appwidget_settings_bluetooth_on_holo
-                    : R.drawable.ic_appwidget_settings_bluetooth_off_holo;
-        }
-
-        @Override
-        public int getActualState(Context context) {
-            if (sBluetoothAdapter == null) {
-                sBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
-                if (sBluetoothAdapter == null) {
-                    return STATE_UNKNOWN;  // On emulator?
-                }
-            }
-            return bluetoothStateToFiveState(sBluetoothAdapter.getState());
-        }
-
-        @Override
-        protected void requestStateChange(Context context, final boolean desiredState) {
-            if (sBluetoothAdapter == null) {
-                Log.d(TAG, "No BluetoothAdapter");
-                return;
-            }
-            // Actually request the Bluetooth change and persistent
-            // settings write off the UI thread, as it can take a
-            // user-noticeable amount of time, especially if there's
-            // disk contention.
-            new AsyncTask<Void, Void, Void>() {
-                @Override
-                protected Void doInBackground(Void... args) {
-                    if (desiredState) {
-                        sBluetoothAdapter.enable();
-                    } else {
-                        sBluetoothAdapter.disable();
-                    }
-                    return null;
-                }
-            }.execute();
-        }
-
-        @Override
-        public void onActualStateChange(Context context, Intent intent) {
-            if (!BluetoothAdapter.ACTION_STATE_CHANGED.equals(intent.getAction())) {
-                return;
-            }
-            int bluetoothState = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1);
-            setCurrentState(context, bluetoothStateToFiveState(bluetoothState));
-        }
-
-        /**
-         * Converts BluetoothAdapter's state values into our
-         * Wifi/Bluetooth-common state values.
-         */
-        private static int bluetoothStateToFiveState(int bluetoothState) {
-            switch (bluetoothState) {
-                case BluetoothAdapter.STATE_OFF:
-                    return STATE_DISABLED;
-                case BluetoothAdapter.STATE_ON:
-                    return STATE_ENABLED;
-                case BluetoothAdapter.STATE_TURNING_ON:
-                    return STATE_TURNING_ON;
-                case BluetoothAdapter.STATE_TURNING_OFF:
-                    return STATE_TURNING_OFF;
-                default:
-                    return STATE_UNKNOWN;
-            }
-        }
-    }
-
-    /**
-     * Subclass of StateTracker for location state.
-     */
-    private static final class LocationStateTracker extends StateTracker {
-        private int mCurrentLocationMode = Settings.Secure.LOCATION_MODE_OFF;
-
-        public int getContainerId() { return R.id.btn_location; }
-        public int getButtonId() { return R.id.img_location; }
-        public int getIndicatorId() { return R.id.ind_location; }
-        public int getButtonDescription() { return R.string.gadget_location; }
-        public int getButtonImageId(boolean on) {
-            if (on) {
-                switch (mCurrentLocationMode) {
-                    case Settings.Secure.LOCATION_MODE_HIGH_ACCURACY:
-                    case Settings.Secure.LOCATION_MODE_SENSORS_ONLY:
-                        return R.drawable.ic_appwidget_settings_location_on_holo;
-                    default:
-                        return R.drawable.ic_appwidget_settings_location_saving_holo;
-                }
-            }
-
-            return R.drawable.ic_appwidget_settings_location_off_holo;
-        }
-
-        @Override
-        public int getActualState(Context context) {
-            ContentResolver resolver = context.getContentResolver();
-            mCurrentLocationMode = Settings.Secure.getInt(resolver,
-                    Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
-            return (mCurrentLocationMode == Settings.Secure.LOCATION_MODE_OFF)
-                    ? STATE_DISABLED : STATE_ENABLED;
-        }
-
-        @Override
-        public void onActualStateChange(Context context, Intent unused) {
-            // Note: the broadcast location providers changed intent
-            // doesn't include an extras bundles saying what the new value is.
-            setCurrentState(context, getActualState(context));
-        }
-
-        @Override
-        public void requestStateChange(final Context context, final boolean desiredState) {
-            final ContentResolver resolver = context.getContentResolver();
-            new AsyncTask<Void, Void, Boolean>() {
-                @Override
-                protected Boolean doInBackground(Void... args) {
-                    final UserManager um =
-                            (UserManager) context.getSystemService(Context.USER_SERVICE);
-                    if (!um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
-                        LocationManager lm =
-                                (LocationManager) context.getSystemService(
-                                        Context.LOCATION_SERVICE);
-                        boolean currentLocationEnabled = lm.isLocationEnabled();
-                        lm.setLocationEnabledForUser(
-                                !currentLocationEnabled, Process.myUserHandle());
-                        return lm.isLocationEnabled();
-                    }
-                    return getActualState(context) == STATE_ENABLED;
-                }
-
-                @Override
-                protected void onPostExecute(Boolean result) {
-                    setCurrentState(
-                        context,
-                        result ? STATE_ENABLED : STATE_DISABLED);
-                    updateWidget(context);
-                }
-            }.execute();
-        }
-    }
-
-    /**
-     * Subclass of StateTracker for sync state.
-     */
-    private static final class SyncStateTracker extends StateTracker {
-        public int getContainerId() { return R.id.btn_sync; }
-        public int getButtonId() { return R.id.img_sync; }
-        public int getIndicatorId() { return R.id.ind_sync; }
-        public int getButtonDescription() { return R.string.gadget_sync; }
-        public int getButtonImageId(boolean on) {
-            return on ? R.drawable.ic_appwidget_settings_sync_on_holo
-                    : R.drawable.ic_appwidget_settings_sync_off_holo;
-        }
-
-        @Override
-        public int getActualState(Context context) {
-            boolean on = ContentResolver.getMasterSyncAutomatically();
-            return on ? STATE_ENABLED : STATE_DISABLED;
-        }
-
-        @Override
-        public void onActualStateChange(Context context, Intent unused) {
-            setCurrentState(context, getActualState(context));
-        }
-
-        @Override
-        public void requestStateChange(final Context context, final boolean desiredState) {
-            final ConnectivityManager connManager =
-                    (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
-            final boolean sync = ContentResolver.getMasterSyncAutomatically();
-
-            new AsyncTask<Void, Void, Boolean>() {
-                @Override
-                protected Boolean doInBackground(Void... args) {
-                    // Turning sync on.
-                    if (desiredState) {
-                        if (!sync) {
-                            ContentResolver.setMasterSyncAutomatically(true);
-                        }
-                        return true;
-                    }
-
-                    // Turning sync off
-                    if (sync) {
-                        ContentResolver.setMasterSyncAutomatically(false);
-                    }
-                    return false;
-                }
-
-                @Override
-                protected void onPostExecute(Boolean result) {
-                    setCurrentState(
-                        context,
-                        result ? STATE_ENABLED : STATE_DISABLED);
-                    updateWidget(context);
-                }
-            }.execute();
-        }
-    }
-
-    private static void checkObserver(Context context) {
-        if (sSettingsObserver == null) {
-            sSettingsObserver = new SettingsObserver(new Handler(),
-                    context.getApplicationContext());
-            sSettingsObserver.startObserving();
-        }
-    }
-
-    @Override
-    public void onUpdate(Context context, AppWidgetManager appWidgetManager,
-            int[] appWidgetIds) {
-        // Update each requested appWidgetId
-        RemoteViews view = buildUpdate(context);
-
-        for (int i = 0; i < appWidgetIds.length; i++) {
-            appWidgetManager.updateAppWidget(appWidgetIds[i], view);
-        }
-    }
-
-    @Override
-    public void onEnabled(Context context) {
-        checkObserver(context);
-    }
-
-    @Override
-    public void onDisabled(Context context) {
-        if (sSettingsObserver != null) {
-            sSettingsObserver.stopObserving();
-            sSettingsObserver = null;
-        }
-    }
-
-    /**
-     * Load image for given widget and build {@link RemoteViews} for it.
-     */
-    static RemoteViews buildUpdate(Context context) {
-        RemoteViews views = new RemoteViews(context.getPackageName(),
-                R.layout.widget);
-        views.setOnClickPendingIntent(R.id.btn_wifi, getLaunchPendingIntent(context,
-                BUTTON_WIFI));
-        views.setOnClickPendingIntent(R.id.btn_brightness,
-                getLaunchPendingIntent(context,
-                        BUTTON_BRIGHTNESS));
-        views.setOnClickPendingIntent(R.id.btn_sync,
-                getLaunchPendingIntent(context,
-                        BUTTON_SYNC));
-        views.setOnClickPendingIntent(R.id.btn_location,
-                getLaunchPendingIntent(context, BUTTON_LOCATION));
-        views.setOnClickPendingIntent(R.id.btn_bluetooth,
-                getLaunchPendingIntent(context,
-                        BUTTON_BLUETOOTH));
-
-        updateButtons(views, context);
-        return views;
-    }
-
-    /**
-     * Updates the widget when something changes, or when a button is pushed.
-     *
-     * @param context
-     */
-    public static void updateWidget(Context context) {
-        RemoteViews views = buildUpdate(context);
-        // Update specific list of appWidgetIds if given, otherwise default to all
-        final AppWidgetManager gm = AppWidgetManager.getInstance(context);
-        gm.updateAppWidget(THIS_APPWIDGET, views);
-        checkObserver(context);
-    }
-
-    /**
-     * Updates the buttons based on the underlying states of wifi, etc.
-     *
-     * @param views   The RemoteViews to update.
-     * @param context
-     */
-    private static void updateButtons(RemoteViews views, Context context) {
-        sWifiState.setImageViewResources(context, views);
-        sBluetoothState.setImageViewResources(context, views);
-        sLocationState.setImageViewResources(context, views);
-        sSyncState.setImageViewResources(context, views);
-
-        if (getBrightnessMode(context)) {
-            views.setContentDescription(R.id.btn_brightness,
-                    context.getString(R.string.gadget_brightness_template,
-                            context.getString(R.string.gadget_brightness_state_auto)));
-            views.setImageViewResource(R.id.img_brightness,
-                    R.drawable.ic_appwidget_settings_brightness_auto_holo);
-            views.setImageViewResource(R.id.ind_brightness,
-                    R.drawable.appwidget_settings_ind_on_r_holo);
-        } else {
-            final int brightness = getBrightness(context);
-            final PowerManager pm = context.getSystemService(PowerManager.class);
-            // Set the icon
-            final int full = (int)(pm.getMaximumScreenBrightnessSetting()
-                    * FULL_BRIGHTNESS_THRESHOLD);
-            final int half = (int)(pm.getMaximumScreenBrightnessSetting()
-                    * HALF_BRIGHTNESS_THRESHOLD);
-            if (brightness > full) {
-                views.setContentDescription(R.id.btn_brightness,
-                        context.getString(R.string.gadget_brightness_template,
-                                context.getString(R.string.gadget_brightness_state_full)));
-                views.setImageViewResource(R.id.img_brightness,
-                        R.drawable.ic_appwidget_settings_brightness_full_holo);
-            } else if (brightness > half) {
-                views.setContentDescription(R.id.btn_brightness,
-                        context.getString(R.string.gadget_brightness_template,
-                                context.getString(R.string.gadget_brightness_state_half)));
-                views.setImageViewResource(R.id.img_brightness,
-                        R.drawable.ic_appwidget_settings_brightness_half_holo);
-            } else {
-                views.setContentDescription(R.id.btn_brightness,
-                        context.getString(R.string.gadget_brightness_template,
-                                context.getString(R.string.gadget_brightness_state_off)));
-                views.setImageViewResource(R.id.img_brightness,
-                        R.drawable.ic_appwidget_settings_brightness_off_holo);
-            }
-            // Set the ON state
-            if (brightness > half) {
-                views.setImageViewResource(R.id.ind_brightness,
-                        R.drawable.appwidget_settings_ind_on_r_holo);
-            } else {
-                views.setImageViewResource(R.id.ind_brightness,
-                        R.drawable.appwidget_settings_ind_off_r_holo);
-            }
-        }
-    }
-
-    /**
-     * Creates PendingIntent to notify the widget of a button click.
-     *
-     * @param context
-     * @return
-     */
-    private static PendingIntent getLaunchPendingIntent(Context context,
-            int buttonId) {
-        Intent launchIntent = new Intent();
-        launchIntent.setClass(context, SettingsAppWidgetProvider.class);
-        launchIntent.addCategory(Intent.CATEGORY_ALTERNATIVE);
-        launchIntent.setData(Uri.parse("custom:" + buttonId));
-        PendingIntent pi = PendingIntent.getBroadcast(context, 0 /* no requestCode */,
-                launchIntent, 0 /* no flags */);
-        return pi;
-    }
-
-    /**
-     * Receives and processes a button pressed intent or state change.
-     *
-     * @param context
-     * @param intent  Indicates the pressed button.
-     */
-    @Override
-    public void onReceive(Context context, Intent intent) {
-        super.onReceive(context, intent);
-        String action = intent.getAction();
-        if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
-            sWifiState.onActualStateChange(context, intent);
-        } else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
-            sBluetoothState.onActualStateChange(context, intent);
-        } else if (LocationManager.MODE_CHANGED_ACTION.equals(action)) {
-            sLocationState.onActualStateChange(context, intent);
-        } else if (ContentResolver.ACTION_SYNC_CONN_STATUS_CHANGED.equals(action)) {
-            sSyncState.onActualStateChange(context, intent);
-        } else if (intent.hasCategory(Intent.CATEGORY_ALTERNATIVE)) {
-            Uri data = intent.getData();
-            int buttonId = Integer.parseInt(data.getSchemeSpecificPart());
-            if (buttonId == BUTTON_WIFI) {
-                sWifiState.toggleState(context);
-            } else if (buttonId == BUTTON_BRIGHTNESS) {
-                toggleBrightness(context);
-            } else if (buttonId == BUTTON_SYNC) {
-                sSyncState.toggleState(context);
-            } else if (buttonId == BUTTON_LOCATION) {
-                sLocationState.toggleState(context);
-            } else if (buttonId == BUTTON_BLUETOOTH) {
-                sBluetoothState.toggleState(context);
-            }
-        } else {
-            // Don't fall-through to updating the widget.  The Intent
-            // was something unrelated or that our super class took
-            // care of.
-            return;
-        }
-
-        // State changes fall through
-        updateWidget(context);
-    }
-
-    /**
-     * Gets brightness level.
-     *
-     * @param context
-     * @return brightness level between 0 and 255.
-     */
-    private static int getBrightness(Context context) {
-        try {
-            int brightness = Settings.System.getInt(context.getContentResolver(),
-                    Settings.System.SCREEN_BRIGHTNESS);
-            return brightness;
-        } catch (Exception e) {
-        }
-        return 0;
-    }
-
-    /**
-     * Gets state of brightness mode.
-     *
-     * @param context
-     * @return true if auto brightness is on.
-     */
-    private static boolean getBrightnessMode(Context context) {
-        try {
-            int brightnessMode = Settings.System.getInt(context.getContentResolver(),
-                    Settings.System.SCREEN_BRIGHTNESS_MODE);
-            return brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
-        } catch (Exception e) {
-            Log.d(TAG, "getBrightnessMode: " + e);
-        }
-        return false;
-    }
-
-    /**
-     * Increases or decreases the brightness.
-     *
-     * @param context
-     */
-    private void toggleBrightness(Context context) {
-        try {
-            DisplayManager dm = context.getSystemService(DisplayManager.class);
-            PowerManager pm = context.getSystemService(PowerManager.class);
-
-            ContentResolver cr = context.getContentResolver();
-            int brightness = Settings.System.getInt(cr,
-                    Settings.System.SCREEN_BRIGHTNESS);
-            int brightnessMode = Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
-            //Only get brightness setting if available
-            if (context.getResources().getBoolean(
-                    com.android.internal.R.bool.config_automatic_brightness_available)) {
-                brightnessMode = Settings.System.getInt(cr,
-                        Settings.System.SCREEN_BRIGHTNESS_MODE);
-            }
-
-            // Rotate AUTO -> MINIMUM -> DEFAULT -> MAXIMUM
-            // Technically, not a toggle...
-            if (brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
-                brightness = pm.getMinimumScreenBrightnessSetting();
-                brightnessMode = Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
-            } else if (brightness < pm.getDefaultScreenBrightnessSetting()) {
-                brightness = pm.getDefaultScreenBrightnessSetting();
-            } else if (brightness < pm.getMaximumScreenBrightnessSetting()) {
-                brightness = pm.getMaximumScreenBrightnessSetting();
-            } else {
-                brightnessMode = Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
-                brightness = pm.getMinimumScreenBrightnessSetting();
-            }
-
-            if (context.getResources().getBoolean(
-                    com.android.internal.R.bool.config_automatic_brightness_available)) {
-                // Set screen brightness mode (automatic or manual)
-                Settings.System.putInt(context.getContentResolver(),
-                        Settings.System.SCREEN_BRIGHTNESS_MODE,
-                        brightnessMode);
-            } else {
-                // Make sure we set the brightness if automatic mode isn't available
-                brightnessMode = Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
-            }
-            if (brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL) {
-                dm.setTemporaryBrightness(brightness);
-                Settings.System.putInt(cr, Settings.System.SCREEN_BRIGHTNESS, brightness);
-            }
-        } catch (Settings.SettingNotFoundException e) {
-            Log.d(TAG, "toggleBrightness: " + e);
-        }
-    }
-
-    /** Observer to watch for changes to the BRIGHTNESS setting */
-    private static class SettingsObserver extends ContentObserver {
-
-        private Context mContext;
-
-        SettingsObserver(Handler handler, Context context) {
-            super(handler);
-            mContext = context;
-        }
-
-        void startObserving() {
-            ContentResolver resolver = mContext.getContentResolver();
-            // Listen to brightness and brightness mode
-            resolver.registerContentObserver(Settings.System
-                    .getUriFor(Settings.System.SCREEN_BRIGHTNESS), false, this);
-            resolver.registerContentObserver(Settings.System
-                    .getUriFor(Settings.System.SCREEN_BRIGHTNESS_MODE), false, this);
-            resolver.registerContentObserver(Settings.System
-                    .getUriFor(Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ), false, this);
-        }
-
-        void stopObserving() {
-            mContext.getContentResolver().unregisterContentObserver(this);
-        }
-
-        @Override
-        public void onChange(boolean selfChange) {
-            updateWidget(mContext);
-        }
-    }
-
-}
diff --git a/src/com/android/settings/wifi/WifiSliceBuilder.java b/src/com/android/settings/wifi/WifiSliceBuilder.java
index a7bf16a..f6628a0 100644
--- a/src/com/android/settings/wifi/WifiSliceBuilder.java
+++ b/src/com/android/settings/wifi/WifiSliceBuilder.java
@@ -42,6 +42,7 @@
 import androidx.core.graphics.drawable.IconCompat;
 import androidx.slice.Slice;
 import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.ListBuilder.RowBuilder;
 import androidx.slice.builders.SliceAction;
 
 /**
@@ -95,7 +96,7 @@
 
         return new ListBuilder(context, WIFI_URI, ListBuilder.INFINITY)
                 .setAccentColor(color)
-                .addRow(b -> b
+                .addRow(new RowBuilder()
                         .setTitle(title)
                         .setSubtitle(summary)
                         .addEndItem(toggleSliceAction)
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
index f9014b7..baf2a97 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
@@ -209,7 +209,7 @@
 
         return new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
                 .setAccentColor(Utils.getColorAccentDefaultColor(mContext))
-                .addRow(b -> b
+                .addRow(new RowBuilder()
                         .setTitle(mContext.getText(R.string.wifi_calling_settings_title))
                         .addEndItem(
                                 new SliceAction(
@@ -298,7 +298,7 @@
         // Top row shows information on current preference state
         ListBuilder listBuilder = new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
                 .setAccentColor(Utils.getColorAccentDefaultColor(mContext));
-        listBuilder.setHeader(new ListBuilder.HeaderBuilder(listBuilder)
+        listBuilder.setHeader(new ListBuilder.HeaderBuilder()
                         .setTitle(mContext.getText(R.string.wifi_calling_mode_title))
                         .setSubtitle(getWifiCallingPreferenceSummary(currentWfcPref))
                         .setPrimaryAction(new SliceAction(
@@ -338,7 +338,7 @@
             int preferenceTitleResId, String action, boolean checked) {
         final IconCompat icon =
                 IconCompat.createWithResource(mContext, R.drawable.radio_button_check);
-        return new RowBuilder(listBuilder)
+        return new RowBuilder()
                 .setTitle(mContext.getText(preferenceTitleResId))
                 .setTitleItem(new SliceAction(getBroadcastIntent(action),
                         icon, mContext.getText(preferenceTitleResId), checked));
@@ -488,7 +488,7 @@
         final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
         return new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
                 .setAccentColor(Utils.getColorAccentDefaultColor(mContext))
-                .addRow(b -> b
+                .addRow(new RowBuilder()
                         .setTitle(title)
                         .setSubtitle(subtitle)
                         .setPrimaryAction(new SliceAction(
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index 37869e9..1a7b289 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -39,7 +39,6 @@
 com.android.settings.enterprise.ApplicationListFragment$EnterpriseInstalledPackages
 com.android.settings.enterprise.EnterpriseSetDefaultAppsListFragment
 com.android.settings.fuelgauge.AdvancedPowerUsageDetail
-com.android.settings.fuelgauge.BatteryHistoryDetail
 com.android.settings.fuelgauge.InactiveApps
 com.android.settings.fuelgauge.RestrictedAppDetails
 com.android.settings.IccLockSettings
diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml
index 676a8dd..bbbdcc2 100644
--- a/tests/robotests/res/values-mcc999/config.xml
+++ b/tests/robotests/res/values-mcc999/config.xml
@@ -15,7 +15,6 @@
   -->
 
 <resources>
-    <bool name="config_tintSettingIcon">false</bool>
     <bool name="config_enableColorTemperature">false</bool>
     <bool name="config_show_camera_laser_sensor">false</bool>
     <bool name="config_show_connectivity_monitor">false</bool>
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java
index 40dcf7a..41ac450 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java
@@ -15,40 +15,20 @@
  */
 package com.android.settings.accounts;
 
-import static com.android.settings.accounts.AccountDashboardFragmentTest
-        .ShadowAuthenticationHelper.LABELS;
-import static com.android.settings.accounts.AccountDashboardFragmentTest
-        .ShadowAuthenticationHelper.TYPES;
 import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
 
-import android.content.Context;
-import android.os.UserHandle;
 import android.provider.SearchIndexableResource;
-import android.text.TextUtils;
 
-import com.android.settings.R;
-import com.android.settings.dashboard.SummaryLoader;
-import com.android.settings.testutils.Robolectric;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.accounts.AuthenticatorHelper;
 import com.android.settingslib.drawer.CategoryKey;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
-import org.robolectric.annotation.Resetter;
 
 import java.util.List;
 
-import androidx.fragment.app.FragmentActivity;
-
 @RunWith(SettingsRobolectricTestRunner.class)
 public class AccountDashboardFragmentTest {
 
@@ -59,67 +39,12 @@
         mFragment = new AccountDashboardFragment();
     }
 
-    @After
-    public void tearDown() {
-        ShadowAuthenticationHelper.reset();
-    }
-
     @Test
     public void testCategory_isAccount() {
         assertThat(mFragment.getCategoryKey()).isEqualTo(CategoryKey.CATEGORY_ACCOUNT);
     }
 
     @Test
-    @Config(shadows = {
-            ShadowAuthenticationHelper.class
-    })
-    public void updateSummary_hasAccount_shouldDisplayUpTo3AccountTypes() {
-        final SummaryLoader loader = mock(SummaryLoader.class);
-        final FragmentActivity activity = Robolectric.buildActivity(
-                FragmentActivity.class).setup().get();
-
-        final SummaryLoader.SummaryProvider provider =
-                AccountDashboardFragment.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(activity,
-                        loader);
-        provider.setListening(true);
-
-        verify(loader).setSummary(provider, LABELS[0] + ", " + LABELS[1] + ", and " + LABELS[2]);
-    }
-
-    @Test
-    @Config(shadows = ShadowAuthenticationHelper.class)
-    public void updateSummary_noAccount_shouldDisplayDefaultSummary() {
-        ShadowAuthenticationHelper.setEnabledAccount(null);
-        final SummaryLoader loader = mock(SummaryLoader.class);
-        final FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.class).setup().get();
-
-        final SummaryLoader.SummaryProvider provider =
-                AccountDashboardFragment.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(activity,
-                        loader);
-        provider.setListening(true);
-
-        verify(loader).setSummary(provider,
-                activity.getString(R.string.account_dashboard_default_summary));
-    }
-
-    @Test
-    @Config(shadows = ShadowAuthenticationHelper.class)
-    public void updateSummary_noAccountTypeLabel_shouldNotDisplayNullEntry() {
-        final SummaryLoader loader = mock(SummaryLoader.class);
-        final FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.class).setup().get();
-        final String[] enabledAccounts = {TYPES[0], "unlabeled_account_type", TYPES[1]};
-        ShadowAuthenticationHelper.setEnabledAccount(enabledAccounts);
-
-        final SummaryLoader.SummaryProvider provider =
-                AccountDashboardFragment.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(activity,
-                        loader);
-        provider.setListening(true);
-
-        // should only show the 2 accounts with labels
-        verify(loader).setSummary(provider, LABELS[0] + " and " + LABELS[1]);
-    }
-
-    @Test
     public void testSearchIndexProvider_shouldIndexResource() {
         final List<SearchIndexableResource> indexRes =
                 AccountDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
@@ -129,43 +54,5 @@
         assertThat(indexRes.get(0).xmlResId).isEqualTo(mFragment.getPreferenceScreenResId());
     }
 
-    @Implements(AuthenticatorHelper.class)
-    public static class ShadowAuthenticationHelper {
 
-        static final String[] TYPES = {"type1", "type2", "type3", "type4"};
-        static final String[] LABELS = {"LABEL1", "LABEL2", "LABEL3", "LABEL4"};
-        private static String[] sEnabledAccount = TYPES;
-
-        public void __constructor__(Context context, UserHandle userHandle,
-                AuthenticatorHelper.OnAccountsUpdateListener listener) {
-        }
-
-        private static void setEnabledAccount(String[] enabledAccount) {
-            sEnabledAccount = enabledAccount;
-        }
-
-        @Resetter
-        public static void reset() {
-            sEnabledAccount = TYPES;
-        }
-
-        @Implementation
-        public String[] getEnabledAccountTypes() {
-            return sEnabledAccount;
-        }
-
-        @Implementation
-        public CharSequence getLabelForType(Context context, final String accountType) {
-            if (TextUtils.equals(accountType, TYPES[0])) {
-                return LABELS[0];
-            } else if (TextUtils.equals(accountType, TYPES[1])) {
-                return LABELS[1];
-            } else if (TextUtils.equals(accountType, TYPES[2])) {
-                return LABELS[2];
-            } else if (TextUtils.equals(accountType, TYPES[3])) {
-                return LABELS[3];
-            }
-            return null;
-        }
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountDetailDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/accounts/AccountDetailDashboardFragmentTest.java
index 6b19e59..eca9f86 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountDetailDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountDetailDashboardFragmentTest.java
@@ -130,7 +130,7 @@
 
         final FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
         final Preference preference = new Preference(mContext);
-        dashboardFeatureProvider.bindPreferenceToTile(activity,
+        dashboardFeatureProvider.bindPreferenceToTile(activity, false /* forceRoundedIcon */,
                 MetricsProto.MetricsEvent.DASHBOARD_SUMMARY, preference, tile, null /* key */,
                 Preference.DEFAULT_ORDER);
 
diff --git a/tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java
new file mode 100644
index 0000000..79e292d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java
@@ -0,0 +1,126 @@
+/*
+ * 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.android.settings.accounts.TopLevelAccountEntryPreferenceControllerTest
+        .ShadowAuthenticationHelper.LABELS;
+import static com.android.settings.accounts.TopLevelAccountEntryPreferenceControllerTest
+        .ShadowAuthenticationHelper.TYPES;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.os.UserHandle;
+import android.text.TextUtils;
+
+import com.android.settings.R;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.accounts.AuthenticatorHelper;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+import org.robolectric.annotation.Resetter;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {TopLevelAccountEntryPreferenceControllerTest.ShadowAuthenticationHelper.class})
+public class TopLevelAccountEntryPreferenceControllerTest {
+
+    private TopLevelAccountEntryPreferenceController mController;
+    private Context mContext;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mController = new TopLevelAccountEntryPreferenceController(mContext, "test_key");
+    }
+
+    @After
+    public void tearDown() {
+        ShadowAuthenticationHelper.reset();
+    }
+
+    @Test
+
+    public void updateSummary_hasAccount_shouldDisplayUpTo3AccountTypes() {
+        assertThat(mController.getSummary())
+                .isEqualTo(LABELS[0] + ", " + LABELS[1] + ", and " + LABELS[2]);
+    }
+
+    @Test
+    public void updateSummary_noAccount_shouldDisplayDefaultSummary() {
+        ShadowAuthenticationHelper.setEnabledAccount(null);
+
+        assertThat(mController.getSummary()).isEqualTo(
+                mContext.getText(R.string.account_dashboard_default_summary));
+    }
+
+    @Test
+    public void updateSummary_noAccountTypeLabel_shouldNotDisplayNullEntry() {
+        final String[] enabledAccounts = {TYPES[0], "unlabeled_account_type", TYPES[1]};
+        ShadowAuthenticationHelper.setEnabledAccount(enabledAccounts);
+
+
+        // should only show the 2 accounts with labels
+        assertThat(mController.getSummary()).isEqualTo(LABELS[0] + " and " + LABELS[1]);
+    }
+
+    @Implements(AuthenticatorHelper.class)
+    public static class ShadowAuthenticationHelper {
+
+        static final String[] TYPES = {"type1", "type2", "type3", "type4"};
+        static final String[] LABELS = {"LABEL1", "LABEL2", "LABEL3", "LABEL4"};
+        private static String[] sEnabledAccount = TYPES;
+
+        public void __constructor__(Context context, UserHandle userHandle,
+                AuthenticatorHelper.OnAccountsUpdateListener listener) {
+        }
+
+        private static void setEnabledAccount(String[] enabledAccount) {
+            sEnabledAccount = enabledAccount;
+        }
+
+        @Resetter
+        public static void reset() {
+            sEnabledAccount = TYPES;
+        }
+
+        @Implementation
+        public String[] getEnabledAccountTypes() {
+            return sEnabledAccount;
+        }
+
+        @Implementation
+        public CharSequence getLabelForType(Context context, final String accountType) {
+            if (TextUtils.equals(accountType, TYPES[0])) {
+                return LABELS[0];
+            } else if (TextUtils.equals(accountType, TYPES[1])) {
+                return LABELS[1];
+            } else if (TextUtils.equals(accountType, TYPES[2])) {
+                return LABELS[2];
+            } else if (TextUtils.equals(accountType, TYPES[3])) {
+                return LABELS[3];
+            }
+            return null;
+        }
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java
index ed823c1..dd57315 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java
@@ -17,65 +17,196 @@
 package com.android.settings.applications.defaultapps;
 
 import static com.google.common.truth.Truth.assertThat;
+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 static org.robolectric.RuntimeEnvironment.application;
 
-import android.app.Activity;
+import android.app.AppOpsManager;
 import android.content.Context;
+import android.content.Intent;
 import android.content.pm.PackageManager;
+import android.content.pm.UserInfo;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.os.UserHandle;
 import android.os.UserManager;
-
+import androidx.fragment.app.FragmentActivity;
+import androidx.preference.PreferenceScreen;
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.ShadowProcess;
+import com.android.settings.testutils.shadow.ShadowSecureSettings;
 import com.android.settingslib.applications.DefaultAppInfo;
-
+import java.util.Arrays;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Answers;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
 import org.robolectric.util.ReflectionHelpers;
 
 @RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {
+            SettingsShadowResources.SettingsShadowTheme.class,
+            ShadowProcess.class,
+            ShadowSecureSettings.class
+        })
 public class DefaultAutofillPickerTest {
 
-    private static final String TEST_APP_KEY = "foo.bar/foo.bar.Baz";
+    private static final String MAIN_APP_KEY = "main.foo.bar/foo.bar.Baz";
+    private static final String MANAGED_APP_KEY = "managed.foo.bar/foo.bar.Baz";
+    private static final int MANAGED_PROFILE_UID = 10;
+    private static final int MAIN_PROFILE_UID = 0;
 
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private Activity mActivity;
+    private FragmentActivity mActivity;
     @Mock
     private UserManager mUserManager;
     @Mock
+    private AppOpsManager mAppOpsManager;
+    @Mock
     private PackageManager mPackageManager;
+    @Mock
+    private PreferenceScreen mScreen;
+
     private DefaultAutofillPicker mPicker;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         FakeFeatureFactory.setupForTest();
+
+        Resources res = application.getResources();
+
+        when(mActivity.getApplicationContext()).thenReturn(mActivity);
+        when(mActivity.getSystemService(Context.APP_OPS_SERVICE)).thenReturn(mAppOpsManager);
         when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+        when(mActivity.getTheme()).thenReturn(res.newTheme());
+        when(mActivity.getResources()).thenReturn(res);
+
         mPicker = spy(new DefaultAutofillPicker());
-        mPicker.onAttach((Context) mActivity);
+
+        doReturn(application.getApplicationContext()).when(mPicker).getContext();
+        doReturn(mActivity).when(mPicker).getActivity();
+        doReturn(res).when(mPicker).getResources();
+        doReturn(mScreen).when(mPicker).getPreferenceScreen();
+
+        doNothing().when(mPicker).onCreatePreferences(any(), any());
+        doNothing().when(mPicker).updateCandidates();
 
         ReflectionHelpers.setField(mPicker, "mPm", mPackageManager);
-
-        doReturn(RuntimeEnvironment.application).when(mPicker).getContext();
     }
 
     @Test
     public void setAndGetDefaultAppKey_shouldUpdateDefaultAutoFill() {
-        assertThat(mPicker.setDefaultKey(TEST_APP_KEY)).isTrue();
-        assertThat(mPicker.getDefaultKey()).isEqualTo(TEST_APP_KEY);
+        mPicker.onAttach((Context) mActivity);
+
+        ReflectionHelpers.setField(
+                mPicker, "mUserId", MAIN_PROFILE_UID * UserHandle.PER_USER_RANGE);
+        assertThat(mPicker.setDefaultKey(MAIN_APP_KEY)).isTrue();
+        ReflectionHelpers.setField(
+                mPicker, "mUserId", MANAGED_PROFILE_UID * UserHandle.PER_USER_RANGE);
+        assertThat(mPicker.setDefaultKey(MANAGED_APP_KEY)).isTrue();
+
+        ReflectionHelpers.setField(
+                mPicker, "mUserId", MAIN_PROFILE_UID * UserHandle.PER_USER_RANGE);
+        assertThat(mPicker.getDefaultKey()).isEqualTo(MAIN_APP_KEY);
+        ReflectionHelpers.setField(
+                mPicker, "mUserId", MANAGED_PROFILE_UID * UserHandle.PER_USER_RANGE);
+        assertThat(mPicker.getDefaultKey()).isEqualTo(MANAGED_APP_KEY);
     }
 
     @Test
     public void getConfirmationMessage_shouldNotBeNull() {
+        mPicker.onAttach((Context) mActivity);
+
         final DefaultAppInfo info = mock(DefaultAppInfo.class);
         when(info.loadLabel()).thenReturn("test_app_name");
         assertThat(mPicker.getConfirmationMessage(info)).isNotNull();
     }
+
+    @Test
+    public void mUserId_shouldDeriveUidFromManagedCaller() {
+        setupUserManager();
+        setupCaller();
+        ShadowProcess.setMyUid(MANAGED_PROFILE_UID * UserHandle.PER_USER_RANGE);
+
+        mPicker.onAttach((Context) mActivity);
+        mPicker.onCreate(null);
+
+        assertUserId(MANAGED_PROFILE_UID);
+    }
+
+    @Test
+    public void mUserId_shouldDeriveUidFromMainCaller() {
+        setupUserManager();
+        setupCaller();
+        ShadowProcess.setMyUid(MAIN_PROFILE_UID * UserHandle.PER_USER_RANGE);
+
+        mPicker.onAttach((Context) mActivity);
+        mPicker.onCreate(null);
+
+        assertUserId(MAIN_PROFILE_UID);
+    }
+
+    @Test
+    public void mUserId_shouldDeriveUidFromManagedClick() {
+        setupUserManager();
+        setupClick(/* forWork= */ true);
+        ShadowProcess.setMyUid(MAIN_PROFILE_UID * UserHandle.PER_USER_RANGE);
+
+        mPicker.onAttach((Context) mActivity);
+        mPicker.onCreate(null);
+
+        assertUserId(MANAGED_PROFILE_UID);
+    }
+
+    @Test
+    public void mUserId_shouldDeriveUidFromMainClick() {
+        setupUserManager();
+        setupClick(/* forWork= */ false);
+        ShadowProcess.setMyUid(MAIN_PROFILE_UID * UserHandle.PER_USER_RANGE);
+
+        mPicker.onAttach((Context) mActivity);
+        mPicker.onCreate(null);
+
+        assertUserId(MAIN_PROFILE_UID);
+    }
+
+    private void setupUserManager() {
+        UserHandle mainUserHandle = new UserHandle(MAIN_PROFILE_UID);
+        UserHandle managedUserHandle = new UserHandle(MANAGED_PROFILE_UID);
+        UserInfo managedUserInfo = new UserInfo(
+                MANAGED_PROFILE_UID, "managed", UserInfo.FLAG_MANAGED_PROFILE);
+        when(mUserManager.getUserProfiles())
+                .thenReturn(Arrays.asList(mainUserHandle, managedUserHandle));
+        when(mUserManager.getUserInfo(MANAGED_PROFILE_UID))
+                .thenReturn(managedUserInfo);
+        when(mUserManager.getUserHandle()).thenReturn(MAIN_PROFILE_UID);
+    }
+
+    private void setupCaller() {
+        Intent intent = new Intent();
+        intent.putExtra("package_name", "any package name");
+        when(mActivity.getIntent()).thenReturn(intent);
+    }
+
+    private void setupClick(boolean forWork) {
+        Bundle bundle = new Bundle();
+        bundle.putBoolean("for_work", forWork);
+        doReturn(bundle).when(mPicker).getArguments();
+    }
+
+    private void assertUserId(int userId) {
+        assertThat((Integer) ReflectionHelpers.getField(mPicker, "mUserId"))
+                .isEqualTo(userId);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
index cf73d41e..e676cf4 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
@@ -22,6 +22,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothProfile;
 import android.content.Context;
@@ -31,6 +32,7 @@
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.ShadowAudioManager;
+import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
 import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
 import com.android.settingslib.bluetooth.HeadsetProfile;
@@ -44,12 +46,13 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
 
 import java.util.ArrayList;
 import java.util.Collection;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = {ShadowAudioManager.class})
+@Config(shadows = {ShadowAudioManager.class, ShadowBluetoothAdapter.class})
 public class AvailableMediaBluetoothDeviceUpdaterTest {
     @Mock
     private DashboardFragment mDashboardFragment;
@@ -73,12 +76,15 @@
     private Collection<CachedBluetoothDevice> cachedDevices;
     private ShadowAudioManager mShadowAudioManager;
     private BluetoothDevicePreference mPreference;
+    private ShadowBluetoothAdapter mShadowBluetoothAdapter;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
         mShadowAudioManager = ShadowAudioManager.getShadow();
+        mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
+        mShadowBluetoothAdapter.setEnabled(true);
         mContext = RuntimeEnvironment.application;
         doReturn(mContext).when(mDashboardFragment).getContext();
         cachedDevices =
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
index 9f81711..f338e36 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
@@ -22,15 +22,19 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothDevice;
 import android.content.Context;
 import android.content.Intent;
+import androidx.preference.Preference;
 
 import com.android.settings.SettingsActivity;
 import com.android.settings.connecteddevice.DevicePreferenceCallback;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
 
 import org.junit.Before;
@@ -40,10 +44,14 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
 
-import androidx.preference.Preference;
+import java.util.ArrayList;
+import java.util.List;
 
 @RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowBluetoothAdapter.class})
 public class BluetoothDeviceUpdaterTest {
 
     @Mock
@@ -58,18 +66,26 @@
     private SettingsActivity mSettingsActivity;
     @Mock
     private LocalBluetoothManager mLocalManager;
+    @Mock
+    private CachedBluetoothDeviceManager mCachedDeviceManager;
 
     private Context mContext;
     private BluetoothDeviceUpdater mBluetoothDeviceUpdater;
     private BluetoothDevicePreference mPreference;
+    private ShadowBluetoothAdapter mShadowBluetoothAdapter;
+    private List<CachedBluetoothDevice> mCachedDevices = new ArrayList<CachedBluetoothDevice>();
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
         mContext = RuntimeEnvironment.application;
+        mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
+        mCachedDevices.add(mCachedBluetoothDevice);
         doReturn(mContext).when(mDashboardFragment).getContext();
         when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
+        when(mLocalManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
+        when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
 
         mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice, false);
         mBluetoothDeviceUpdater =
@@ -171,4 +187,38 @@
         // Shouldn't crash
         mBluetoothDeviceUpdater.unregisterCallback();
     }
+
+    @Test
+    public void forceUpdate_bluetoothDisabled_doNothing() {
+        mShadowBluetoothAdapter.setEnabled(false);
+        mBluetoothDeviceUpdater.forceUpdate();
+
+        verify(mDevicePreferenceCallback, never()).onDeviceAdded(any(Preference.class));
+    }
+
+    @Test
+    public void forceUpdate_bluetoothEnabled_addPreference() {
+        mShadowBluetoothAdapter.setEnabled(true);
+        mBluetoothDeviceUpdater.forceUpdate();
+
+        verify(mDevicePreferenceCallback).onDeviceAdded(any(Preference.class));
+    }
+
+    @Test
+    public void onBluetoothStateChanged_bluetoothStateIsOn_forceUpdate() {
+        mShadowBluetoothAdapter.setEnabled(true);
+        mBluetoothDeviceUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_ON);
+
+        verify(mDevicePreferenceCallback).onDeviceAdded(any(Preference.class));
+    }
+
+    @Test
+    public void onBluetoothStateChanged_bluetoothStateIsOff_removeAllDevicesFromPreference() {
+        mBluetoothDeviceUpdater.mPreferenceMap.put(mBluetoothDevice, mPreference);
+
+        mBluetoothDeviceUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_OFF);
+
+        verify(mDevicePreferenceCallback).onDeviceRemoved(mPreference);
+        assertThat(mBluetoothDeviceUpdater.mPreferenceMap.containsKey(mBluetoothDevice)).isFalse();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
index d94a8a7..ece71d7 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
@@ -23,6 +23,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothProfile;
 import android.content.Context;
@@ -32,6 +33,7 @@
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.ShadowAudioManager;
+import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
 import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -43,12 +45,13 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
 
 import java.util.ArrayList;
 import java.util.Collection;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = {ShadowAudioManager.class})
+@Config(shadows = {ShadowAudioManager.class, ShadowBluetoothAdapter.class})
 public class ConnectedBluetoothDeviceUpdaterTest {
     @Mock
     private DashboardFragment mDashboardFragment;
@@ -67,12 +70,15 @@
     private ConnectedBluetoothDeviceUpdater mBluetoothDeviceUpdater;
     private Collection<CachedBluetoothDevice> cachedDevices;
     private ShadowAudioManager mShadowAudioManager;
+    private ShadowBluetoothAdapter mShadowBluetoothAdapter;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
         mShadowAudioManager = ShadowAudioManager.getShadow();
+        mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
+        mShadowBluetoothAdapter.setEnabled(true);
         mContext = RuntimeEnvironment.application;
         doReturn(mContext).when(mDashboardFragment).getContext();
         cachedDevices =
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceControllerTest.java
new file mode 100644
index 0000000..8816bec
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceControllerTest.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.connecteddevice;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import com.android.settings.R;
+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.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class TopLevelConnectedDevicesPreferenceControllerTest {
+
+    private Context mContext;
+    private TopLevelConnectedDevicesPreferenceController mController;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mController = new TopLevelConnectedDevicesPreferenceController(mContext, "test_key");
+    }
+
+    @Test
+    @Config(shadows = ShadowAdvancedConnectedDeviceController.class)
+    public void getSummary_shouldCallAdvancedConnectedDeviceController() {
+        assertThat(mController.getSummary())
+                .isEqualTo(mContext.getText(R.string.settings_label_launcher));
+    }
+
+    @Implements(AdvancedConnectedDeviceController.class)
+    private static class ShadowAdvancedConnectedDeviceController {
+
+        @Implementation
+        public static int getConnectedDevicesSummaryResourceId(Context context) {
+            return R.string.settings_label_launcher;
+        }
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
index 8f10af7..d3288b6 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
@@ -45,14 +45,14 @@
 
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
-import com.android.settings.dashboard.conditional.Condition;
+import com.android.settings.homepage.conditional.Condition;
 import com.android.settings.dashboard.suggestions.SuggestionAdapter;
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.widget.RoundedHomepageIcon;
 import com.android.settingslib.drawer.CategoryKey;
 import com.android.settingslib.drawer.Tile;
-import com.android.settingslib.drawer.TileUtils;
 import com.android.settingslib.utils.IconCache;
 
 import org.junit.Before;
@@ -95,7 +95,6 @@
         mActivityInfo.packageName = "pkg";
         mActivityInfo.name = "class";
         mActivityInfo.metaData = new Bundle();
-        when(mFactory.dashboardFeatureProvider.shouldTintIcon()).thenReturn(true);
 
         when(mContext.getSystemService(Context.WINDOW_SERVICE)).thenReturn(mWindowManager);
         when(mContext.getResources()).thenReturn(mResources);
@@ -115,7 +114,7 @@
                 spy(new DashboardAdapter(mContext, null /* savedInstanceState */,
                         null /* conditions */, null /* suggestionControllerMixin */,
                         null /* lifecycle */));
-        final List<Suggestion> suggestions = makeSuggestionsV2("pkg1", "pkg2", "pkg3");
+        final List<Suggestion> suggestions = makeSuggestions("pkg1", "pkg2", "pkg3");
         adapter.setSuggestions(suggestions);
 
         final RecyclerView data = mock(RecyclerView.class);
@@ -147,7 +146,7 @@
                 spy(new DashboardAdapter(mContext, null /* savedInstanceState */,
                         null /* conditions */, null /* suggestionControllerMixin */,
                         null /* lifecycle */));
-        final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
+        final List<Suggestion> suggestions = makeSuggestions("pkg1");
         adapter.setSuggestions(suggestions);
         final DashboardData dashboardData = adapter.mDashboardData;
         reset(adapter); // clear interactions tracking
@@ -164,7 +163,7 @@
                 spy(new DashboardAdapter(mContext, null /* savedInstanceState */,
                         null /* conditions */, null /* suggestionControllerMixin */,
                         null /* lifecycle */));
-        final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
+        final List<Suggestion> suggestions = makeSuggestions("pkg1");
         adapter.setSuggestions(suggestions);
 
         reset(adapter); // clear interactions tracking
@@ -178,7 +177,7 @@
     public void onBindSuggestion_shouldSetSuggestionAdapterAndNoCrash() {
         mDashboardAdapter = new DashboardAdapter(mContext, null /* savedInstanceState */,
                 null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
-        final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
+        final List<Suggestion> suggestions = makeSuggestions("pkg1");
 
         mDashboardAdapter.setSuggestions(suggestions);
 
@@ -244,55 +243,6 @@
     }
 
     @Test
-    public void onBindTile_externalTileWithBackgroundColorRawValue_shouldUpdateIcon() {
-        final Context context = spy(RuntimeEnvironment.application);
-        final View view = LayoutInflater.from(context).inflate(R.layout.dashboard_tile, null);
-        final DashboardAdapter.DashboardItemHolder holder =
-                new DashboardAdapter.DashboardItemHolder(view);
-        final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
-        tile.getMetaData().putInt(DashboardAdapter.META_DATA_PREFERENCE_ICON_BACKGROUND_ARGB,
-                0xff0000);
-        doReturn(Icon.createWithResource(context, R.drawable.ic_settings))
-                .when(tile).getIcon(context);
-        final IconCache iconCache = new IconCache(context);
-        mDashboardAdapter = new DashboardAdapter(context, null /* savedInstanceState */,
-                null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
-        ReflectionHelpers.setField(mDashboardAdapter, "mCache", iconCache);
-
-        doReturn("another.package").when(context).getPackageName();
-        mDashboardAdapter.onBindTile(holder, tile);
-
-        final RoundedHomepageIcon homepageIcon = (RoundedHomepageIcon) iconCache.getIcon(
-                tile.getIcon(context));
-        assertThat(homepageIcon.mBackgroundColor).isEqualTo(0xff0000);
-    }
-
-    @Test
-    public void onBindTile_externalTileWithBackgroundColorHint_shouldUpdateIcon() {
-        final Context context = spy(RuntimeEnvironment.application);
-        final View view = LayoutInflater.from(context).inflate(R.layout.dashboard_tile, null);
-        final DashboardAdapter.DashboardItemHolder holder =
-                new DashboardAdapter.DashboardItemHolder(view);
-        final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
-        tile.getMetaData().putInt(TileUtils.META_DATA_PREFERENCE_ICON_BACKGROUND_HINT,
-                R.color.memory_critical);
-        doReturn(Icon.createWithResource(context, R.drawable.ic_settings))
-                .when(tile).getIcon(context);
-        final IconCache iconCache = new IconCache(context);
-        mDashboardAdapter = new DashboardAdapter(context, null /* savedInstanceState */,
-                null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
-        ReflectionHelpers.setField(mDashboardAdapter, "mCache", iconCache);
-
-        doReturn("another.package").when(context).getPackageName();
-        mDashboardAdapter.onBindTile(holder, tile);
-
-        final RoundedHomepageIcon homepageIcon = (RoundedHomepageIcon) iconCache.getIcon(
-                tile.getIcon(context));
-        assertThat(homepageIcon.mBackgroundColor)
-                .isEqualTo(RuntimeEnvironment.application.getColor(R.color.memory_critical));
-    }
-
-    @Test
     public void onBindTile_externalTile_usingRoundedHomepageIcon_shouldNotUpdateIcon() {
         final Context context = RuntimeEnvironment.application;
         final View view = LayoutInflater.from(context).inflate(R.layout.dashboard_tile, null);
@@ -315,7 +265,7 @@
                 any(RoundedHomepageIcon.class));
     }
 
-    private List<Suggestion> makeSuggestionsV2(String... pkgNames) {
+    private List<Suggestion> makeSuggestions(String... pkgNames) {
         final List<Suggestion> suggestions = new ArrayList<>();
         for (String pkgName : pkgNames) {
             final Suggestion suggestion = new Suggestion.Builder(pkgName)
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java
index dfa0494..d92cceb 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java
@@ -33,8 +33,8 @@
 import androidx.recyclerview.widget.DiffUtil;
 import androidx.recyclerview.widget.ListUpdateCallback;
 
-import com.android.settings.dashboard.conditional.AirplaneModeCondition;
-import com.android.settings.dashboard.conditional.Condition;
+import com.android.settings.homepage.conditional.AirplaneModeCondition;
+import com.android.settings.homepage.conditional.Condition;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settingslib.drawer.CategoryKey;
 import com.android.settingslib.drawer.DashboardCategory;
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
index adc1ac0..22c589c 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
@@ -49,7 +49,7 @@
 import androidx.fragment.app.FragmentActivity;
 import androidx.preference.Preference;
 
-import com.android.internal.logging.nano.MetricsProto;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
 import com.android.settings.testutils.FakeFeatureFactory;
@@ -59,7 +59,6 @@
 import com.android.settings.testutils.shadow.ShadowUserManager;
 import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
 import com.android.settingslib.drawer.CategoryKey;
-import com.android.settingslib.drawer.DashboardCategory;
 import com.android.settingslib.drawer.Tile;
 import com.android.settingslib.drawer.TileUtils;
 
@@ -88,19 +87,19 @@
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private UserManager mUserManager;
     @Mock
-    private CategoryManager mCategoryManager;
-    @Mock
     private PackageManager mPackageManager;
     private FakeFeatureFactory mFeatureFactory;
 
     private Context mContext;
     private ActivityInfo mActivityInfo;
     private DashboardFeatureProviderImpl mImpl;
+    private boolean mForceRoundedIcon;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application);
+        mForceRoundedIcon = false;
         mActivityInfo = new ActivityInfo();
         mActivityInfo.packageName = "pkg";
         mActivityInfo.name = "class";
@@ -127,7 +126,7 @@
         doReturn(Icon.createWithBitmap(Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565)))
                 .when(tile).getIcon(any(Context.class));
         mActivityInfo.metaData.putString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS, "HI");
-        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
+        mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES,
                 preference, tile, "123", Preference.DEFAULT_ORDER);
 
         assertThat(preference.getTitle()).isEqualTo(tile.title);
@@ -144,7 +143,7 @@
         mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, 10);
         final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
 
-        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
+        mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES,
                 preference, tile, "123", Preference.DEFAULT_ORDER);
 
         assertThat(preference.getFragment()).isNull();
@@ -163,7 +162,7 @@
         when(mActivity.getApplicationContext().getSystemService(Context.USER_SERVICE))
                 .thenReturn(mUserManager);
 
-        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
+        mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES,
                 preference, tile, "123", Preference.DEFAULT_ORDER);
         preference.getOnPreferenceClickListener().onPreferenceClick(null);
 
@@ -180,14 +179,14 @@
         when(mActivity.getSystemService(Context.USER_SERVICE))
                 .thenReturn(mUserManager);
 
-        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
+        mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES,
                 preference, tile, "123", Preference.DEFAULT_ORDER);
         preference.getOnPreferenceClickListener().onPreferenceClick(null);
 
         verify(mFeatureFactory.metricsFeatureProvider).logDashboardStartIntent(
                 any(Context.class),
                 any(Intent.class),
-                eq(MetricsProto.MetricsEvent.SETTINGS_GESTURES));
+                eq(MetricsEvent.SETTINGS_GESTURES));
         verify(mActivity)
                 .startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
     }
@@ -205,7 +204,7 @@
         when(mActivity.getApplicationContext().getPackageName())
                 .thenReturn(RuntimeEnvironment.application.getPackageName());
 
-        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
+        mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES,
                 preference, tile, "123", Preference.DEFAULT_ORDER);
         preference.getOnPreferenceClickListener().onPreferenceClick(null);
         verify(mFeatureFactory.metricsFeatureProvider).logDashboardStartIntent(
@@ -219,7 +218,7 @@
     @Test
     public void bindPreference_nullPreference_shouldIgnore() {
         final Tile tile = mock(Tile.class);
-        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+        mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
                 null, tile, "123", Preference.DEFAULT_ORDER);
 
         verifyZeroInteractions(tile);
@@ -229,7 +228,7 @@
     public void bindPreference_withNullKeyNullPriority_shouldGenerateKeyAndPriority() {
         final Preference preference = new Preference(RuntimeEnvironment.application);
         final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
-        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+        mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
                 preference, tile, null /*key */, Preference.DEFAULT_ORDER);
 
         assertThat(preference.getKey()).isNotNull();
@@ -240,7 +239,7 @@
     public void bindPreference_noSummary_shouldSetSummaryToPlaceholder() {
         final Preference preference = new Preference(RuntimeEnvironment.application);
         final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
-        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+        mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
                 preference, tile, null /*key */, Preference.DEFAULT_ORDER);
 
         assertThat(preference.getSummary())
@@ -252,7 +251,7 @@
         final Preference preference = new Preference(RuntimeEnvironment.application);
         final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
         tile.summary = "test";
-        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+        mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
                 preference, tile, null /*key */, Preference.DEFAULT_ORDER);
 
         assertThat(preference.getSummary()).isEqualTo(tile.summary);
@@ -266,7 +265,7 @@
         mActivityInfo.metaData.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI,
                 "content://com.android.settings/tile_summary");
 
-        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+        mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
                 preference, tile, null /*key */, Preference.DEFAULT_ORDER);
 
         assertThat(preference.getSummary()).isEqualTo(ShadowTileUtils.MOCK_SUMMARY);
@@ -277,7 +276,7 @@
         final Preference preference = new Preference(RuntimeEnvironment.application);
         mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
         final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
-        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+        mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
                 preference, tile, null /* key */, Preference.DEFAULT_ORDER);
 
         assertThat(preference.getKey()).isEqualTo(tile.getKey(mContext));
@@ -292,7 +291,7 @@
         mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
         mActivityInfo.metaData.putString(TileUtils.META_DATA_PREFERENCE_ICON_URI,
                 "content://com.android.settings/tile_icon");
-        mImpl.bindIcon(preference, tile);
+        mImpl.bindIcon(preference, tile, false /* forceRoundedIcon */);
 
         assertThat(preference.getIcon()).isNotNull();
     }
@@ -304,7 +303,7 @@
         mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, 10);
         final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
 
-        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+        mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
                 preference, tile, "123", baseOrder);
 
         assertThat(preference.getOrder()).isEqualTo(tile.getOrder() + baseOrder);
@@ -317,7 +316,7 @@
         mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, 10);
         final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
         mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, testOrder);
-        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+        mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
                 preference, tile, "123", Preference.DEFAULT_ORDER);
 
         assertThat(preference.getOrder()).isEqualTo(testOrder);
@@ -329,7 +328,7 @@
         final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
         mActivityInfo.metaData.putString(META_DATA_KEY_ORDER, "hello");
 
-        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+        mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
                 preference, tile, "123", Preference.DEFAULT_ORDER);
 
         assertThat(preference.getOrder()).isEqualTo(Preference.DEFAULT_ORDER);
@@ -343,7 +342,7 @@
         mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
         mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
         tile.userHandle = null;
-        mImpl.bindPreferenceToTile(activity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
+        mImpl.bindPreferenceToTile(activity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES,
                 preference, tile, "123", Preference.DEFAULT_ORDER);
         preference.performClick();
         ShadowActivity shadowActivity = Shadows.shadowOf(activity);
@@ -352,7 +351,7 @@
         assertThat(launchIntent.getAction())
                 .isEqualTo("TestAction");
         assertThat(launchIntent.getIntExtra(VisibilityLoggerMixin.EXTRA_SOURCE_METRICS_CATEGORY, 0))
-                .isEqualTo(MetricsProto.MetricsEvent.SETTINGS_GESTURES);
+                .isEqualTo(MetricsEvent.SETTINGS_GESTURES);
     }
 
     @Test
@@ -367,7 +366,7 @@
         mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
         tile.userHandle = null;
 
-        mImpl.bindPreferenceToTile(activity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
+        mImpl.bindPreferenceToTile(activity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES,
                 preference, tile, "123", Preference.DEFAULT_ORDER);
         preference.performClick();
 
@@ -378,63 +377,11 @@
     }
 
     @Test
-    public void getPreferences_noCategory_shouldReturnNull() {
-        mImpl = new DashboardFeatureProviderImpl(mActivity);
-        ReflectionHelpers.setField(mImpl, "mCategoryManager", mCategoryManager);
-        when(mCategoryManager.getTilesByCategory(mActivity, CategoryKey.CATEGORY_HOMEPAGE))
-                .thenReturn(null);
-
-        assertThat(mImpl.getPreferencesForCategory(null, null,
-                MetricsProto.MetricsEvent.SETTINGS_GESTURES, CategoryKey.CATEGORY_HOMEPAGE))
-                .isNull();
-    }
-
-    @Test
-    public void getPreferences_noTileForCategory_shouldReturnNull() {
-        mImpl = new DashboardFeatureProviderImpl(mActivity);
-        ReflectionHelpers.setField(mImpl, "mCategoryManager", mCategoryManager);
-        when(mCategoryManager.getTilesByCategory(mActivity, CategoryKey.CATEGORY_HOMEPAGE))
-                .thenReturn(new DashboardCategory(CategoryKey.CATEGORY_HOMEPAGE));
-
-        assertThat(mImpl.getPreferencesForCategory(null, null,
-                MetricsProto.MetricsEvent.SETTINGS_GESTURES, CategoryKey.CATEGORY_HOMEPAGE))
-                .isNull();
-    }
-
-    @Test
-    public void getPreferences_hasTileForCategory_shouldReturnPrefList() {
-        mImpl = new DashboardFeatureProviderImpl(mActivity);
-        ReflectionHelpers.setField(mImpl, "mCategoryManager", mCategoryManager);
-        final DashboardCategory category = new DashboardCategory(CategoryKey.CATEGORY_HOMEPAGE);
-        category.addTile(new Tile(mActivityInfo, category.key));
-        when(mCategoryManager
-                .getTilesByCategory(any(Context.class), eq(CategoryKey.CATEGORY_HOMEPAGE)))
-                .thenReturn(category);
-
-        assertThat(mImpl.getPreferencesForCategory(mActivity,
-                ShadowApplication.getInstance().getApplicationContext(),
-                MetricsProto.MetricsEvent.SETTINGS_GESTURES,
-                CategoryKey.CATEGORY_HOMEPAGE).isEmpty())
-                .isFalse();
-    }
-
-    @Test
     public void testGetExtraIntentAction_shouldReturnNull() {
         assertThat(mImpl.getExtraIntentAction()).isNull();
     }
 
     @Test
-    public void testShouldTintIcon_enabledInResources_shouldBeTrue() {
-        assertThat(mImpl.shouldTintIcon()).isTrue();
-    }
-
-    @Test
-    @Config(qualifiers = "mcc999")
-    public void testShouldTintIcon_disabledInResources_shouldBeFalse() {
-        assertThat(mImpl.shouldTintIcon()).isFalse();
-    }
-
-    @Test
     public void openTileIntent_profileSelectionDialog_shouldShow() {
         final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
         final ArrayList<UserHandle> handles = new ArrayList<>();
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentRegistryTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentRegistryTest.java
new file mode 100644
index 0000000..1f68e2f
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentRegistryTest.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.dashboard;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class DashboardFragmentRegistryTest {
+    @Test
+    public void pageAndKeyShouldHave1to1Mapping() {
+        assertThat(DashboardFragmentRegistry.CATEGORY_KEY_TO_PARENT_MAP.size())
+                .isEqualTo(DashboardFragmentRegistry.PARENT_TO_CATEGORY_KEY_MAP.size());
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java
index d93cd81..4eaeaf2 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java
@@ -30,8 +30,8 @@
 import android.app.Activity;
 import android.content.Context;
 
-import com.android.settings.dashboard.conditional.ConditionManager;
-import com.android.settings.dashboard.conditional.FocusRecyclerView;
+import com.android.settings.homepage.conditional.ConditionManager;
+import com.android.settings.homepage.conditional.FocusRecyclerView;
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settingslib.drawer.CategoryKey;
diff --git a/tests/robotests/src/com/android/settings/dashboard/RoundedHomepageIconTest.java b/tests/robotests/src/com/android/settings/dashboard/RoundedHomepageIconTest.java
deleted file mode 100644
index 0c90660..0000000
--- a/tests/robotests/src/com/android/settings/dashboard/RoundedHomepageIconTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.dashboard;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.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.graphics.Color;
-import android.graphics.PorterDuff;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.ShapeDrawable;
-
-import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class RoundedHomepageIconTest {
-
-    private Context mContext;
-
-    @Before
-    public void setUp() {
-        mContext = RuntimeEnvironment.application;
-    }
-
-    @Test
-    public void createIcon_shouldSetBackgroundAndInset() {
-        final RoundedHomepageIcon icon =
-                new RoundedHomepageIcon(mContext, new ColorDrawable(Color.BLACK));
-
-        assertThat(icon.getNumberOfLayers()).isEqualTo(2);
-        assertThat(icon.getDrawable(0))
-                .isEqualTo(mContext.getDrawable(R.drawable.ic_homepage_generic_background));
-    }
-
-    @Test
-    public void setBackgroundColor_shouldUpdateColorFilter() {
-        final RoundedHomepageIcon icon =
-                spy(new RoundedHomepageIcon(mContext, new ColorDrawable(Color.BLACK)));
-        final ShapeDrawable background = mock(ShapeDrawable.class);
-        when(icon.getDrawable(0)).thenReturn(background);
-
-        icon.setBackgroundColor(Color.BLUE);
-
-        verify(background).setColorFilter(Color.BLUE, PorterDuff.Mode.SRC_ATOP);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
index bd9db3d..6398361 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
@@ -355,7 +355,7 @@
                 mActivity, null, null, null);
 
         final SubscriptionInfo subInfo = new SubscriptionInfo(0, "123456", 0, "name", "carrier",
-                0, 0, "number", 0, null, "123", "456", "ZX");
+                0, 0, "number", 0, null, "123", "456", "ZX", false, null, null);
         when(mSubscriptionManager.getDefaultDataSubscriptionInfo()).thenReturn(subInfo);
         assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
     }
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java b/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java
index 943bd9d..cb02c76 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java
@@ -17,7 +17,6 @@
 package com.android.settings.deviceinfo;
 
 import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.nullable;
 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
@@ -25,14 +24,9 @@
 import static org.mockito.Mockito.when;
 
 import android.app.Activity;
-import android.app.usage.StorageStatsManager;
 import android.content.Intent;
-import android.icu.text.NumberFormat;
 import android.os.storage.VolumeInfo;
-import android.text.format.Formatter;
 
-import com.android.settings.R;
-import com.android.settings.dashboard.SummaryLoader;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settingslib.deviceinfo.StorageManagerVolumeProvider;
 
@@ -41,8 +35,6 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.util.ReflectionHelpers;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -66,34 +58,6 @@
     }
 
     @Test
-    public void updateSummary_shouldDisplayUsedPercentAndFreeSpace() throws Exception {
-        final SummaryLoader loader = mock(SummaryLoader.class);
-        final SummaryLoader.SummaryProvider provider =
-                StorageSettings.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(mActivity, loader);
-        final VolumeInfo volumeInfo = mVolumes.get(0);
-        when(volumeInfo.isMountedReadable()).thenReturn(true);
-        when(volumeInfo.getType()).thenReturn(VolumeInfo.TYPE_PRIVATE);
-        when(mStorageManagerVolumeProvider
-                .getTotalBytes(nullable(StorageStatsManager.class), nullable(VolumeInfo.class)))
-                .thenReturn(500L);
-        when(mStorageManagerVolumeProvider
-                .getFreeBytes(nullable(StorageStatsManager.class), nullable(VolumeInfo.class)))
-                .thenReturn(0L);
-
-        ReflectionHelpers
-                .setField(provider, "mStorageManagerVolumeProvider", mStorageManagerVolumeProvider);
-        ReflectionHelpers.setField(provider, "mContext", RuntimeEnvironment.application);
-
-        provider.setListening(true);
-
-        final String percentage = NumberFormat.getPercentInstance().format(1);
-        final String freeSpace = Formatter.formatFileSize(RuntimeEnvironment.application, 0);
-        verify(loader).setSummary(provider,
-                RuntimeEnvironment.application.getString(
-                        R.string.storage_summary, percentage, freeSpace));
-    }
-
-    @Test
     public void handlePublicVolumeClick_startsANonNullActivityWhenVolumeHasNoBrowse() {
         VolumeInfo volumeInfo = mock(VolumeInfo.class, RETURNS_DEEP_STUBS);
         when(volumeInfo.isMountedReadable()).thenReturn(true);
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceControllerTest.java
new file mode 100644
index 0000000..00484df
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceControllerTest.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.deviceinfo;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import android.app.usage.StorageStatsManager;
+import android.content.Context;
+import android.icu.text.NumberFormat;
+import android.os.storage.VolumeInfo;
+import android.text.format.Formatter;
+
+import com.android.settings.R;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.deviceinfo.StorageManagerVolumeProvider;
+
+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.util.ReflectionHelpers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class TopLevelStoragePreferenceControllerTest {
+
+    @Mock
+    private StorageManagerVolumeProvider mStorageManagerVolumeProvider;
+
+    private Context mContext;
+    private TopLevelStoragePreferenceController mController;
+    private List<VolumeInfo> mVolumes;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        mContext = RuntimeEnvironment.application;
+        mVolumes = new ArrayList<>();
+        mVolumes.add(mock(VolumeInfo.class, RETURNS_DEEP_STUBS));
+        when(mStorageManagerVolumeProvider.getVolumes()).thenReturn(mVolumes);
+
+        mController = new TopLevelStoragePreferenceController(mContext, "test_key");
+    }
+
+    @Test
+    public void updateSummary_shouldDisplayUsedPercentAndFreeSpace() throws Exception {
+        final VolumeInfo volumeInfo = mVolumes.get(0);
+        when(volumeInfo.isMountedReadable()).thenReturn(true);
+        when(volumeInfo.getType()).thenReturn(VolumeInfo.TYPE_PRIVATE);
+        when(mStorageManagerVolumeProvider
+                .getTotalBytes(nullable(StorageStatsManager.class), nullable(VolumeInfo.class)))
+                .thenReturn(500L);
+        when(mStorageManagerVolumeProvider
+                .getFreeBytes(nullable(StorageStatsManager.class), nullable(VolumeInfo.class)))
+                .thenReturn(0L);
+
+        ReflectionHelpers.setField(mController,
+                "mStorageManagerVolumeProvider", mStorageManagerVolumeProvider);
+
+        final String percentage = NumberFormat.getPercentInstance().format(1);
+        final String freeSpace = Formatter.formatFileSize(RuntimeEnvironment.application, 0);
+        assertThat(mController.getSummary()).isEqualTo(
+                RuntimeEnvironment.application.getString(
+                        R.string.storage_summary, percentage, freeSpace));
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java
index ad5537c..ac93941 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java
@@ -56,7 +56,6 @@
         mBatterySaverController = spy(new BatterySaverController(mContext));
         ReflectionHelpers.setField(mBatterySaverController, "mPowerManager", mPowerManager);
         ReflectionHelpers.setField(mBatterySaverController, "mBatterySaverPref", mBatterySaverPref);
-        doNothing().when(mBatterySaverController).refreshConditionManager();
 
         Settings.Global.putInt(mContext.getContentResolver(),
                 Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
index 68d9994..cf1a5f3 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
@@ -16,7 +16,9 @@
 package com.android.settings.fuelgauge;
 
 import static com.android.settings.fuelgauge.PowerUsageSummary.MENU_ADVANCED_BATTERY;
+
 import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyInt;
 import static org.mockito.Matchers.anyLong;
@@ -40,6 +42,8 @@
 import android.view.View;
 import android.widget.TextView;
 
+import androidx.loader.app.LoaderManager;
+
 import com.android.internal.os.BatterySipper;
 import com.android.internal.os.BatteryStatsHelper;
 import com.android.settings.R;
@@ -50,7 +54,6 @@
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.XmlTestUtils;
 import com.android.settings.testutils.shadow.SettingsShadowResources;
-import com.android.settingslib.core.AbstractPreferenceController;
 
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -69,8 +72,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import androidx.loader.app.LoaderManager;
-
 // TODO: Improve this test class so that it starts up the real activity and fragment.
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(shadows = {
@@ -343,18 +344,6 @@
         verify(mFragment).restartBatteryTipLoader();
     }
 
-    @Test
-    public void getDashboardLabel_returnsCorrectLabel() {
-        BatteryInfo info = new BatteryInfo();
-        info.batteryPercentString = "3%";
-        assertThat(PowerUsageSummary.getDashboardLabel(mRealContext, info))
-                .isEqualTo(info.batteryPercentString);
-
-        info.remainingLabel = "Phone will shut down soon";
-        assertThat(PowerUsageSummary.getDashboardLabel(mRealContext, info))
-                .isEqualTo("3% - Phone will shut down soon");
-    }
-
     public static class TestFragment extends PowerUsageSummary {
         private Context mContext;
 
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
new file mode 100644
index 0000000..b1bc074
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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;
+
+import static com.android.settings.fuelgauge.TopLevelBatteryPreferenceController.getDashboardLabel;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class TopLevelBatteryPreferenceControllerTest {
+
+    private Context mContext;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+    }
+
+    @Test
+    public void getDashboardLabel_returnsCorrectLabel() {
+        BatteryInfo info = new BatteryInfo();
+        info.batteryPercentString = "3%";
+        assertThat(getDashboardLabel(mContext, info))
+                .isEqualTo(info.batteryPercentString);
+
+        info.remainingLabel = "Phone will shut down soon";
+        assertThat(getDashboardLabel(mContext, info))
+                .isEqualTo("3% - Phone will shut down soon");
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
index a36dbf7..654d9b6 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
@@ -17,7 +17,6 @@
 package com.android.settings.gestures;
 
 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.UNSUPPORTED_ON_DEVICE;
 import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.Matchers.anyInt;
@@ -59,21 +58,21 @@
     @Test
     public void testIsChecked_configIsSet_shouldReturnTrue() {
         // Set the setting to be enabled.
-        when(mAmbientDisplayConfiguration.pulseOnDoubleTapEnabled(anyInt())).thenReturn(true);
+        when(mAmbientDisplayConfiguration.doubleTapGestureEnabled(anyInt())).thenReturn(true);
 
         assertThat(mController.isChecked()).isTrue();
     }
 
     @Test
     public void testIsChecked_configIsNotSet_shouldReturnFalse() {
-        when(mAmbientDisplayConfiguration.pulseOnDoubleTapEnabled(anyInt())).thenReturn(false);
+        when(mAmbientDisplayConfiguration.doubleTapGestureEnabled(anyInt())).thenReturn(false);
 
         assertThat(mController.isChecked()).isFalse();
     }
 
     @Test
     public void isSuggestionCompleted_ambientDisplay_falseWhenNotVisited() {
-        when(mAmbientDisplayConfiguration.pulseOnDoubleTapAvailable()).thenReturn(true);
+        when(mAmbientDisplayConfiguration.doubleTapSensorAvailable()).thenReturn(true);
         // No stored value in shared preferences if not visited yet.
         final Context context = RuntimeEnvironment.application;
         final SharedPreferences prefs =
@@ -85,7 +84,7 @@
 
     @Test
     public void isSuggestionCompleted_ambientDisplay_trueWhenVisited() {
-        when(mAmbientDisplayConfiguration.pulseOnDoubleTapAvailable()).thenReturn(false);
+        when(mAmbientDisplayConfiguration.doubleTapSensorAvailable()).thenReturn(false);
         final Context context = RuntimeEnvironment.application;
         final SharedPreferences prefs =
                 new SuggestionFeatureProviderImpl(context).getSharedPrefs(context);
@@ -98,18 +97,6 @@
     }
 
     @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();
-    }
-
-    @Test
     public void getAvailabilityStatus_aodNotSupported_UNSUPPORTED_ON_DEVICE() {
         when(mAmbientDisplayConfiguration.doubleTapSensorAvailable()).thenReturn(false);
         when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(false);
@@ -119,15 +106,6 @@
     }
 
     @Test
-    public void getAvailabilityStatus_aodOn_DISABLED_DEPENDENT_SETTING() {
-        when(mAmbientDisplayConfiguration.doubleTapSensorAvailable()).thenReturn(true);
-        when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(false);
-        final int availabilityStatus = mController.getAvailabilityStatus();
-
-        assertThat(availabilityStatus).isEqualTo(DISABLED_DEPENDENT_SETTING);
-    }
-
-    @Test
     public void getAvailabilityStatus_aodSupported_aodOff_AVAILABLE() {
         when(mAmbientDisplayConfiguration.doubleTapSensorAvailable()).thenReturn(true);
         when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(true);
diff --git a/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
index af0146b..17fa7cd 100644
--- a/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
@@ -17,7 +17,6 @@
 package com.android.settings.gestures;
 
 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.UNSUPPORTED_ON_DEVICE;
 import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.Matchers.anyInt;
@@ -62,7 +61,7 @@
     @Test
     public void testIsChecked_configIsSet_shouldReturnTrue() {
         // Set the setting to be enabled.
-        when(mAmbientDisplayConfiguration.pulseOnPickupEnabled(anyInt())).thenReturn(true);
+        when(mAmbientDisplayConfiguration.pickupGestureEnabled(anyInt())).thenReturn(true);
 
         assertThat(mController.isChecked()).isTrue();
     }
@@ -70,28 +69,12 @@
     @Test
     public void testIsChecked_configIsNotSet_shouldReturnFalse() {
         // Set the setting to be disabled.
-        when(mAmbientDisplayConfiguration.pulseOnPickupEnabled(anyInt())).thenReturn(false);
+        when(mAmbientDisplayConfiguration.pickupGestureEnabled(anyInt())).thenReturn(false);
 
         assertThat(mController.isChecked()).isFalse();
     }
 
     @Test
-    public void testCanHandleClicks_configIsSet_shouldReturnTrue() {
-        mController = spy(mController);
-        doReturn(true).when(mController).pulseOnPickupCanBeModified();
-
-        assertThat(mController.canHandleClicks()).isTrue();
-    }
-
-    @Test
-    public void testCanHandleClicks_configIsNotSet_shouldReturnFalse() {
-        mController = spy(mController);
-        doReturn(false).when(mController).pulseOnPickupCanBeModified();
-
-        assertThat(mController.canHandleClicks()).isFalse();
-    }
-
-    @Test
     public void isSuggestionCompleted_ambientDisplayPickup_trueWhenVisited() {
         when(mContext.getResources().getBoolean(anyInt())).thenReturn(true);
         when(mContext.getResources().getString(anyInt())).thenReturn("foo");
@@ -106,7 +89,7 @@
 
     @Test
     public void getAvailabilityStatus_aodNotSupported_UNSUPPORTED_ON_DEVICE() {
-        when(mAmbientDisplayConfiguration.dozePulsePickupSensorAvailable()).thenReturn(false);
+        when(mAmbientDisplayConfiguration.dozePickupSensorAvailable()).thenReturn(false);
         when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(false);
         final int availabilityStatus = mController.getAvailabilityStatus();
 
@@ -114,17 +97,8 @@
     }
 
     @Test
-    public void getAvailabilityStatus_aodOn_DISABLED_DEPENDENT_SETTING() {
-        when(mAmbientDisplayConfiguration.dozePulsePickupSensorAvailable()).thenReturn(true);
-        when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(false);
-        final int availabilityStatus = mController.getAvailabilityStatus();
-
-        assertThat(availabilityStatus).isEqualTo(DISABLED_DEPENDENT_SETTING);
-    }
-
-    @Test
     public void getAvailabilityStatus_aodSupported_aodOff_AVAILABLE() {
-        when(mAmbientDisplayConfiguration.dozePulsePickupSensorAvailable()).thenReturn(true);
+        when(mAmbientDisplayConfiguration.dozePickupSensorAvailable()).thenReturn(true);
         when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(true);
         final int availabilityStatus = mController.getAvailabilityStatus();
 
diff --git a/tests/robotests/src/com/android/settings/homepage/CardContentProviderTest.java b/tests/robotests/src/com/android/settings/homepage/CardContentProviderTest.java
new file mode 100644
index 0000000..bf1527a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/CardContentProviderTest.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.android.settings.homepage;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+
+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.robolectric.Robolectric;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class CardContentProviderTest {
+
+    private Context mContext;
+    private CardContentProvider mProvider;
+    private Uri mUri;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mProvider = Robolectric.setupContentProvider(CardContentProvider.class);
+        mUri = new Uri.Builder()
+                .scheme(ContentResolver.SCHEME_CONTENT)
+                .authority(CardContentProvider.CARD_AUTHORITY)
+                .path(CardDatabaseHelper.CARD_TABLE)
+                .build();
+    }
+
+    @After
+    public void cleanUp() {
+        CardDatabaseHelper.getInstance(mContext).close();
+        CardDatabaseHelper.sCardDatabaseHelper = null;
+    }
+
+    @Test
+    public void cardData_insert() {
+        final int cnt_before_instert = getRowCount();
+        mContext.getContentResolver().insert(mUri, insertOneRow());
+        final int cnt_after_instert = getRowCount();
+
+        assertThat(cnt_after_instert - cnt_before_instert).isEqualTo(1);
+    }
+
+    @Test
+    public void cardData_query() {
+        mContext.getContentResolver().insert(mUri, insertOneRow());
+        final int count = getRowCount();
+
+        assertThat(count).isGreaterThan(0);
+    }
+
+    @Test
+    public void cardData_delete() {
+        final ContentResolver contentResolver = mContext.getContentResolver();
+        contentResolver.insert(mUri, insertOneRow());
+        final int del_count = contentResolver.delete(mUri, null, null);
+
+        assertThat(del_count).isGreaterThan(0);
+    }
+
+    @Test
+    public void cardData_update() {
+        final ContentResolver contentResolver = mContext.getContentResolver();
+        contentResolver.insert(mUri, insertOneRow());
+
+        final double updatingScore= 0.87;
+        final ContentValues values = new ContentValues();
+        values.put(CardDatabaseHelper.CardColumns.SCORE, updatingScore);
+        final String strWhere = CardDatabaseHelper.CardColumns.NAME + "=?";
+        final String[] selectionArgs = {"auto_rotate"};
+        final int update_count = contentResolver.update(mUri, values, strWhere, selectionArgs);
+
+        assertThat(update_count).isGreaterThan(0);
+
+        final String[] columns = {CardDatabaseHelper.CardColumns.SCORE};
+        final Cursor cr = contentResolver.query(mUri, columns, strWhere, selectionArgs, null);
+        cr.moveToFirst();
+        final double qryScore = cr.getDouble(0);
+
+        cr.close();
+        assertThat(qryScore).isEqualTo(updatingScore);
+    }
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void getType_shouldCrash() {
+        mProvider.getType(null);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void invalid_Uri_shouldCrash() {
+        final Uri invalid_Uri = new Uri.Builder()
+                .scheme(ContentResolver.SCHEME_CONTENT)
+                .authority(CardContentProvider.CARD_AUTHORITY)
+                .path("Invalid_table")
+                .build();
+
+        mProvider.getTableFromMatch(invalid_Uri);
+    }
+
+    private ContentValues insertOneRow() {
+        final ContentValues values = new ContentValues();
+        values.put(CardDatabaseHelper.CardColumns.NAME, "auto_rotate");
+        values.put(CardDatabaseHelper.CardColumns.TYPE, 0);
+        values.put(CardDatabaseHelper.CardColumns.SCORE, 0.9);
+        values.put(CardDatabaseHelper.CardColumns.SLICE_URI,
+                "content://com.android.settings.slices/action/auto_rotate");
+        values.put(CardDatabaseHelper.CardColumns.CATEGORY, 2);
+        values.put(CardDatabaseHelper.CardColumns.PACKAGE_NAME, "com.android.settings");
+        values.put(CardDatabaseHelper.CardColumns.APP_VERSION, "1.0.0");
+
+        return values;
+    }
+
+    private int getRowCount() {
+        final ContentResolver contentResolver = mContext.getContentResolver();
+        final Cursor cr = contentResolver.query(mUri, null, null, null);
+        final int count = cr.getCount();
+        cr.close();
+        return count;
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/homepage/CardDatabaseHelperTest.java b/tests/robotests/src/com/android/settings/homepage/CardDatabaseHelperTest.java
new file mode 100644
index 0000000..b6ed358
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/CardDatabaseHelperTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.homepage;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+
+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.robolectric.RuntimeEnvironment;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class CardDatabaseHelperTest {
+
+    private Context mContext;
+    private CardDatabaseHelper mCardDatabaseHelper;
+    private SQLiteDatabase mDatabase;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mCardDatabaseHelper = CardDatabaseHelper.getInstance(mContext);
+        mDatabase = mCardDatabaseHelper.getWritableDatabase();
+    }
+
+    @After
+    public void cleanUp() {
+        CardDatabaseHelper.getInstance(mContext).close();
+        CardDatabaseHelper.sCardDatabaseHelper = null;
+    }
+
+    @Test
+    public void testDatabaseSchema() {
+        final Cursor cursor = mDatabase.rawQuery("SELECT * FROM " + CardDatabaseHelper.CARD_TABLE,
+                null);
+        final String[] columnNames = cursor.getColumnNames();
+
+        final String[] expectedNames = {
+                CardDatabaseHelper.CardColumns.NAME,
+                CardDatabaseHelper.CardColumns.TYPE,
+                CardDatabaseHelper.CardColumns.SCORE,
+                CardDatabaseHelper.CardColumns.SLICE_URI,
+                CardDatabaseHelper.CardColumns.CATEGORY,
+                CardDatabaseHelper.CardColumns.AVAILABILITY_URI,
+                CardDatabaseHelper.CardColumns.LOCALIZED_TO_LOCALE,
+                CardDatabaseHelper.CardColumns.PACKAGE_NAME,
+                CardDatabaseHelper.CardColumns.APP_VERSION,
+                CardDatabaseHelper.CardColumns.TITLE_RES_NAME,
+                CardDatabaseHelper.CardColumns.TITLE_TEXT,
+                CardDatabaseHelper.CardColumns.SUMMARY_RES_NAME,
+                CardDatabaseHelper.CardColumns.SUMMARY_TEXT,
+                CardDatabaseHelper.CardColumns.ICON_RES_NAME,
+                CardDatabaseHelper.CardColumns.ICON_RES_ID,
+                CardDatabaseHelper.CardColumns.CARD_ACTION,
+                CardDatabaseHelper.CardColumns.EXPIRE_TIME_MS,
+        };
+
+        assertThat(columnNames).isEqualTo(expectedNames);
+        cursor.close();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/homepage/TopLevelSettingsTest.java b/tests/robotests/src/com/android/settings/homepage/TopLevelSettingsTest.java
new file mode 100644
index 0000000..83ab948
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/TopLevelSettingsTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.homepage;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class TopLevelSettingsTest {
+    private Context mContext;
+    private TopLevelSettings mSettings;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mSettings = spy(new TopLevelSettings());
+        when(mSettings.getContext()).thenReturn(mContext);
+    }
+
+    @Test
+    public void shouldForceRoundedIcon_true() {
+        assertThat(mSettings.shouldForceRoundedIcon()).isTrue();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/dashboard/conditional/AbnormalRingerConditionBaseTest.java b/tests/robotests/src/com/android/settings/homepage/conditional/AbnormalRingerConditionBaseTest.java
similarity index 97%
rename from tests/robotests/src/com/android/settings/dashboard/conditional/AbnormalRingerConditionBaseTest.java
rename to tests/robotests/src/com/android/settings/homepage/conditional/AbnormalRingerConditionBaseTest.java
index c72131f..efc5cea 100644
--- a/tests/robotests/src/com/android/settings/dashboard/conditional/AbnormalRingerConditionBaseTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/conditional/AbnormalRingerConditionBaseTest.java
@@ -14,9 +14,10 @@
  * limitations under the License.
  */
 
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
diff --git a/tests/robotests/src/com/android/settings/dashboard/conditional/BackgroundDataConditionTest.java b/tests/robotests/src/com/android/settings/homepage/conditional/BackgroundDataConditionTest.java
similarity index 97%
rename from tests/robotests/src/com/android/settings/dashboard/conditional/BackgroundDataConditionTest.java
rename to tests/robotests/src/com/android/settings/homepage/conditional/BackgroundDataConditionTest.java
index 725be79..289fa7c 100644
--- a/tests/robotests/src/com/android/settings/dashboard/conditional/BackgroundDataConditionTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/conditional/BackgroundDataConditionTest.java
@@ -13,9 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
diff --git a/tests/robotests/src/com/android/settings/dashboard/conditional/BatterySaverConditionTest.java b/tests/robotests/src/com/android/settings/homepage/conditional/BatterySaverConditionTest.java
similarity index 98%
rename from tests/robotests/src/com/android/settings/dashboard/conditional/BatterySaverConditionTest.java
rename to tests/robotests/src/com/android/settings/homepage/conditional/BatterySaverConditionTest.java
index fa05ae0..323e6c5 100644
--- a/tests/robotests/src/com/android/settings/dashboard/conditional/BatterySaverConditionTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/conditional/BatterySaverConditionTest.java
@@ -14,9 +14,10 @@
  * limitations under the License.
  */
 
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
diff --git a/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionAdapterTest.java b/tests/robotests/src/com/android/settings/homepage/conditional/ConditionAdapterTest.java
similarity index 98%
rename from tests/robotests/src/com/android/settings/dashboard/conditional/ConditionAdapterTest.java
rename to tests/robotests/src/com/android/settings/homepage/conditional/ConditionAdapterTest.java
index 62d1dfa..663c630 100644
--- a/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/conditional/ConditionAdapterTest.java
@@ -13,9 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
@@ -24,6 +25,8 @@
 import android.view.View;
 import android.widget.LinearLayout;
 
+import androidx.recyclerview.widget.RecyclerView;
+
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardAdapter;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -38,8 +41,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import androidx.recyclerview.widget.RecyclerView;
-
 @RunWith(SettingsRobolectricTestRunner.class)
 public class ConditionAdapterTest {
 
diff --git a/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionTest.java b/tests/robotests/src/com/android/settings/homepage/conditional/ConditionTest.java
similarity index 98%
rename from tests/robotests/src/com/android/settings/dashboard/conditional/ConditionTest.java
rename to tests/robotests/src/com/android/settings/homepage/conditional/ConditionTest.java
index 6d56731..981ef66 100644
--- a/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/conditional/ConditionTest.java
@@ -13,9 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License
  */
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
diff --git a/tests/robotests/src/com/android/settings/dashboard/conditional/DndConditionTest.java b/tests/robotests/src/com/android/settings/homepage/conditional/DndConditionTest.java
similarity index 98%
rename from tests/robotests/src/com/android/settings/dashboard/conditional/DndConditionTest.java
rename to tests/robotests/src/com/android/settings/homepage/conditional/DndConditionTest.java
index 29ad60f..9da1f9c 100644
--- a/tests/robotests/src/com/android/settings/dashboard/conditional/DndConditionTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/conditional/DndConditionTest.java
@@ -13,9 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License
  */
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.never;
diff --git a/tests/robotests/src/com/android/settings/dashboard/conditional/RingerMutedConditionTest.java b/tests/robotests/src/com/android/settings/homepage/conditional/RingerMutedConditionTest.java
similarity index 98%
rename from tests/robotests/src/com/android/settings/dashboard/conditional/RingerMutedConditionTest.java
rename to tests/robotests/src/com/android/settings/homepage/conditional/RingerMutedConditionTest.java
index 66ef5a0..408aa13 100644
--- a/tests/robotests/src/com/android/settings/dashboard/conditional/RingerMutedConditionTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/conditional/RingerMutedConditionTest.java
@@ -14,10 +14,11 @@
  * limitations under the License.
  */
 
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 
 import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
diff --git a/tests/robotests/src/com/android/settings/dashboard/conditional/RingerVibrateConditionTest.java b/tests/robotests/src/com/android/settings/homepage/conditional/RingerVibrateConditionTest.java
similarity index 97%
rename from tests/robotests/src/com/android/settings/dashboard/conditional/RingerVibrateConditionTest.java
rename to tests/robotests/src/com/android/settings/homepage/conditional/RingerVibrateConditionTest.java
index a134fac..e886236 100644
--- a/tests/robotests/src/com/android/settings/dashboard/conditional/RingerVibrateConditionTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/conditional/RingerVibrateConditionTest.java
@@ -14,10 +14,11 @@
  * limitations under the License.
  */
 
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 
 import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
diff --git a/tests/robotests/src/com/android/settings/dashboard/conditional/WorkModeConditionTest.java b/tests/robotests/src/com/android/settings/homepage/conditional/WorkModeConditionTest.java
similarity index 97%
rename from tests/robotests/src/com/android/settings/dashboard/conditional/WorkModeConditionTest.java
rename to tests/robotests/src/com/android/settings/homepage/conditional/WorkModeConditionTest.java
index 8ba6ecc..c846be0 100644
--- a/tests/robotests/src/com/android/settings/dashboard/conditional/WorkModeConditionTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/conditional/WorkModeConditionTest.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License
  */
-package com.android.settings.dashboard.conditional;
+package com.android.settings.homepage.conditional;
 
 import static org.mockito.ArgumentMatchers.argThat;
 import static org.mockito.Mockito.spy;
diff --git a/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java b/tests/robotests/src/com/android/settings/security/TopLevelSecurityPreferenceControllerTest.java
similarity index 66%
rename from tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java
rename to tests/robotests/src/com/android/settings/security/TopLevelSecurityPreferenceControllerTest.java
index f3cc459..17ba6d5 100644
--- a/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/security/TopLevelSecurityPreferenceControllerTest.java
@@ -17,7 +17,6 @@
 package com.android.settings.security;
 
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
@@ -26,7 +25,6 @@
 import android.hardware.fingerprint.FingerprintManager;
 
 import com.android.settings.R;
-import com.android.settings.dashboard.SummaryLoader;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
 import org.junit.Before;
@@ -37,17 +35,15 @@
 import org.mockito.MockitoAnnotations;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-public class SecuritySettingsTest {
+public class TopLevelSecurityPreferenceControllerTest {
 
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private Context mContext;
     @Mock
-    private SummaryLoader mSummaryLoader;
-    @Mock
     private FingerprintManager mFingerprintManager;
     @Mock
     private FaceManager mFaceManager;
-    private SecuritySettings.SummaryProvider mSummaryProvider;
+    private TopLevelSecurityEntryPreferenceController mController;
 
     @Before
     public void setUp() {
@@ -56,87 +52,80 @@
                 .thenReturn(mFingerprintManager);
         when(mContext.getSystemService(Context.FACE_SERVICE))
                 .thenReturn(mFaceManager);
-        mSummaryProvider = new SecuritySettings.SummaryProvider(mContext, mSummaryLoader);
+        mController = new TopLevelSecurityEntryPreferenceController(mContext, "test_key");
     }
 
     @Test
-    public void testSummaryProvider_notListening() {
-        mSummaryProvider.setListening(false);
-
-        verifyNoMoreInteractions(mSummaryLoader);
-    }
-
-    @Test
-    public void testSummaryProvider_hasFace_hasStaticSummary() {
+    public void geSummary_hasFace_hasStaticSummary() {
         when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE))
                 .thenReturn(true);
         when(mFaceManager.isHardwareDetected()).thenReturn(true);
 
-        mSummaryProvider.setListening(true);
+        mController.getSummary();
 
-        verify(mContext).getString(R.string.security_dashboard_summary_face);
+        verify(mContext).getText(R.string.security_dashboard_summary_face);
     }
 
     @Test
-    public void testSummaryProvider_hasFingerPrint_hasStaticSummary() {
+    public void geSummary_hasFingerPrint_hasStaticSummary() {
         when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE))
                 .thenReturn(false);
         when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
                 .thenReturn(true);
         when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
 
-        mSummaryProvider.setListening(true);
+        mController.getSummary();
 
-        verify(mContext).getString(R.string.security_dashboard_summary);
+        verify(mContext).getText(R.string.security_dashboard_summary);
     }
 
     @Test
-    public void testSummaryProvider_noFpFeature_shouldSetSummaryWithNoBiometrics() {
+    public void geSummary_noFpFeature_shouldSetSummaryWithNoBiometrics() {
         when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
                 .thenReturn(false);
         when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE))
                 .thenReturn(false);
 
-        mSummaryProvider.setListening(true);
+        mController.getSummary();
 
-        verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
+        verify(mContext).getText(R.string.security_dashboard_summary_no_fingerprint);
     }
 
     @Test
-    public void testSummaryProvider_noFpHardware_shouldSetSummaryWithNoBiometrics() {
+    public void geSummary_noFpHardware_shouldSetSummaryWithNoBiometrics() {
         when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE))
                 .thenReturn(false);
         when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
                 .thenReturn(true);
         when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
 
-        mSummaryProvider.setListening(true);
+        mController.getSummary();
 
-        verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
+        verify(mContext).getText(R.string.security_dashboard_summary_no_fingerprint);
     }
 
     @Test
-    public void testSummaryProvider_noFaceFeature_shouldSetSummaryWithNoBiometrics() {
+    public void geSummary_noFaceFeature_shouldSetSummaryWithNoBiometrics() {
         when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
                 .thenReturn(false);
         when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE))
                 .thenReturn(false);
 
-        mSummaryProvider.setListening(true);
+        mController.getSummary();
 
-        verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
+        verify(mContext).getText(R.string.security_dashboard_summary_no_fingerprint);
     }
 
     @Test
-    public void testSummaryProvider_noFaceHardware_shouldSetSummaryWithNoBiometrics() {
+    public void geSummary_noFaceHardware_shouldSetSummaryWithNoBiometrics() {
         when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE))
                 .thenReturn(true);
         when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
                 .thenReturn(false);
         when(mFaceManager.isHardwareDetected()).thenReturn(false);
 
-        mSummaryProvider.setListening(true);
+        mController.getSummary();
 
-        verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
+        verify(mContext).getText(R.string.security_dashboard_summary_no_fingerprint);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
index ea2f2ca..3cb502e 100644
--- a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
@@ -66,6 +66,9 @@
 import java.util.Set;
 
 import androidx.slice.Slice;
+import androidx.slice.SliceProvider;
+import androidx.slice.widget.SliceLiveData;
+import com.android.settings.R;
 
 /**
  * TODO Investigate using ShadowContentResolver.registerProviderInternal(String, ContentProvider)
@@ -81,7 +84,7 @@
     private static final String SUMMARY = "summary";
     private static final String SCREEN_TITLE = "screen title";
     private static final String FRAGMENT_NAME = "fragment name";
-    private static final int ICON = 1234; // I declare a thumb war
+    private static final int ICON = R.drawable.ic_settings;
     private static final Uri URI = Uri.parse("content://com.android.settings.slices/test");
     private static final String PREF_CONTROLLER = FakeToggleController.class.getName();
 
@@ -117,6 +120,8 @@
         mManager = mock(SliceManager.class);
         when(mContext.getSystemService(SliceManager.class)).thenReturn(mManager);
         when(mManager.getPinnedSlices()).thenReturn(Collections.emptyList());
+
+        SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
     }
 
     @After
@@ -480,7 +485,7 @@
         values.put(SlicesDatabaseHelper.IndexColumns.TITLE, TITLE);
         values.put(SlicesDatabaseHelper.IndexColumns.SUMMARY, "s");
         values.put(SlicesDatabaseHelper.IndexColumns.SCREENTITLE, "s");
-        values.put(SlicesDatabaseHelper.IndexColumns.ICON_RESOURCE, 1234);
+        values.put(SlicesDatabaseHelper.IndexColumns.ICON_RESOURCE, R.drawable.ic_settings);
         values.put(SlicesDatabaseHelper.IndexColumns.FRAGMENT, "test");
         values.put(SlicesDatabaseHelper.IndexColumns.CONTROLLER, PREF_CONTROLLER);
         values.put(SlicesDatabaseHelper.IndexColumns.PLATFORM_SLICE, isPlatformSlice);
diff --git a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
index b96c128..48489f9 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
@@ -64,7 +64,7 @@
     private final String SCREEN_TITLE = "screen title";
     private final String KEYWORDS = "a, b, c";
     private final String FRAGMENT_NAME = "fragment name";
-    private final int ICON = 1234; // I declare a thumb war
+    private final int ICON = R.drawable.ic_settings;
     private final Uri URI = Uri.parse("content://com.android.settings.slices/test");
     private final Class TOGGLE_CONTROLLER = FakeToggleController.class;
     private final Class SLIDER_CONTROLLER = FakeSliderController.class;
diff --git a/tests/robotests/src/com/android/settings/widget/RoundedHomepageIconTest.java b/tests/robotests/src/com/android/settings/widget/RoundedHomepageIconTest.java
new file mode 100644
index 0000000..042341b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/RoundedHomepageIconTest.java
@@ -0,0 +1,115 @@
+/*
+ * 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.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_ICON_BACKGROUND_ARGB;
+import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_ICON_BACKGROUND_HINT;
+
+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;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.pm.ActivityInfo;
+import android.graphics.Color;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Icon;
+import android.graphics.drawable.ShapeDrawable;
+import android.os.Bundle;
+
+import com.android.settings.R;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.drawer.CategoryKey;
+import com.android.settingslib.drawer.Tile;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class RoundedHomepageIconTest {
+
+    private Context mContext;
+    private ActivityInfo mActivityInfo;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mActivityInfo = new ActivityInfo();
+        mActivityInfo.packageName = mContext.getPackageName();
+        mActivityInfo.name = "class";
+        mActivityInfo.metaData = new Bundle();
+    }
+
+    @Test
+    public void createIcon_shouldSetBackgroundAndInset() {
+        final RoundedHomepageIcon icon =
+                new RoundedHomepageIcon(mContext, new ColorDrawable(Color.BLACK));
+
+        assertThat(icon.getNumberOfLayers()).isEqualTo(2);
+        assertThat(icon.getDrawable(0))
+                .isEqualTo(mContext.getDrawable(R.drawable.ic_homepage_generic_background));
+    }
+
+    @Test
+    public void setBackgroundColor_shouldUpdateColorFilter() {
+        final RoundedHomepageIcon icon =
+                spy(new RoundedHomepageIcon(mContext, new ColorDrawable(Color.BLACK)));
+        final ShapeDrawable background = mock(ShapeDrawable.class);
+        when(icon.getDrawable(0)).thenReturn(background);
+
+        icon.setBackgroundColor(Color.BLUE);
+
+        verify(background).setColorFilter(Color.BLUE, PorterDuff.Mode.SRC_ATOP);
+    }
+
+    @Test
+    public void setBackgroundColor_externalTileWithBackgroundColorRawValue_shouldUpdateIcon() {
+        final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
+        mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON_BACKGROUND_ARGB, 0xff0000);
+        doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings))
+                .when(tile).getIcon(mContext);
+        final RoundedHomepageIcon icon =
+                new RoundedHomepageIcon(mContext, new ColorDrawable(Color.BLACK));
+
+        icon.setBackgroundColor(mContext, tile);
+        assertThat(icon.mBackgroundColor).isEqualTo(0xff0000);
+    }
+
+    @Test
+    public void onBindTile_externalTileWithBackgroundColorHint_shouldUpdateIcon() {
+        final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
+        mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON_BACKGROUND_HINT,
+                R.color.memory_critical);
+        doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings))
+                .when(tile).getIcon(mContext);
+
+        final RoundedHomepageIcon icon =
+                new RoundedHomepageIcon(mContext, new ColorDrawable(Color.BLACK));
+        icon.setBackgroundColor(mContext, tile);
+
+        assertThat(icon.mBackgroundColor)
+                .isEqualTo(mContext.getColor(R.color.memory_critical));
+    }
+
+}