Merge "Fake data to be 0B after clearing." into oc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4f94bf8..8535b2f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -945,7 +945,6 @@
 
         <activity android:name="Settings$ManageApplicationsActivity"
                 android:label="@string/applications_settings"
-                android:icon="@drawable/ic_settings_applications"
                 android:taskAffinity="">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.APPLICATION_SETTINGS" />
@@ -2507,7 +2506,6 @@
 
         <activity android:name="Settings$ConfigureNotificationSettingsActivity"
                 android:label="@string/configure_notification_settings"
-                android:icon="@drawable/ic_settings_notifications"
                 android:exported="true"
                 android:taskAffinity="">
             <intent-filter android:priority="1">
@@ -2850,7 +2848,7 @@
                 android:label="@string/install_other_apps"
                 android:taskAffinity="">
             <intent-filter android:priority="1">
-                <action android:name="android.settings.action.MANAGE_UNKNOWN_APP_SOURCES" />
+                <action android:name="android.settings.MANAGE_UNKNOWN_APP_SOURCES" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -2861,7 +2859,7 @@
                   android:label="@string/install_other_apps"
                   android:taskAffinity="">
             <intent-filter android:priority="1">
-                <action android:name="android.settings.action.MANAGE_UNKNOWN_APP_SOURCES" />
+                <action android:name="android.settings.MANAGE_UNKNOWN_APP_SOURCES" />
                 <category android:name="android.intent.category.DEFAULT" />
                 <data android:scheme="package" />
             </intent-filter>
@@ -2882,8 +2880,7 @@
         <activity android:name="Settings$AdvancedAppsActivity"
                   android:taskAffinity=""
                   android:exported="true"
-                  android:label="@string/app_default_dashboard_title"
-                  android:icon="@drawable/ic_adb">
+                  android:label="@string/app_default_dashboard_title">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.MANAGE_DEFAULT_APPS_SETTINGS" />
                 <action android:name="android.settings.HOME_SETTINGS" />
diff --git a/res/drawable/ic_adb.xml b/res/drawable/ic_adb.xml
deleted file mode 100644
index af28aa1..0000000
--- a/res/drawable/ic_adb.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-    Copyright (C) 2017 The Android Open Source Project
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24dp"
-        android:height="24dp"
-        android:viewportWidth="24.0"
-        android:viewportHeight="24.0"
-        android:tint="?android:attr/colorControlNormal">
-    <path
-        android:pathData="M5,16c0,3.87 3.13,7 7,7s7,-3.13 7,-7v-4L5,12v4zM16.12,4.37l2.1,-2.1 -0.82,-0.83 -2.3,2.31C14.16,3.28 13.12,3 12,3s-2.16,0.28 -3.09,0.75L6.6,1.44l-0.82,0.83 2.1,2.1C6.14,5.64 5,7.68 5,10v1h14v-1c0,-2.32 -1.14,-4.36 -2.88,-5.63zM9,9c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1 1,0.45 1,1 -0.45,1 -1,1zM15,9c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1 1,0.45 1,1 -0.45,1 -1,1z"
-        android:fillColor="#FFFFFFFF"/>
-</vector>
diff --git a/res/drawable/ic_find_device_disabled.xml b/res/drawable/ic_find_device_disabled.xml
index ac23101..0658707 100644
--- a/res/drawable/ic_find_device_disabled.xml
+++ b/res/drawable/ic_find_device_disabled.xml
@@ -14,24 +14,15 @@
     limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24dp"
-        android:height="24dp"
-        android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24"
+    android:tint="?android:attr/colorControlNormal">
+
     <path
-        android:pathData="M0,0l24,0l0,24l-24,0z"
-        android:strokeColor="#000000"
-        android:fillColor="#00000000"
-        android:strokeWidth="1.33333335e-11"
-        android:strokeAlpha="0.00784313771"/>
+        android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z" />
     <path
-        android:pathData="M5,20l0,2l14,0l0,-2z"
-        android:strokeColor="#00000000"
-        android:fillColor="#F09300"
-        android:strokeWidth="1"/>
-    <path
-        android:pathData="M12,5.917C13.15,5.917 14.083,6.85 14.083,8C14.083,8.613 13.813,9.158 13.392,9.542L16.417,12.567C17.229,11.017 17.833,9.404 17.833,8C17.833,4.779 15.221,2.167 12,2.167C10.35,2.167 8.863,2.854 7.804,3.954L10.458,6.608C10.837,6.188 11.387,5.917 12,5.917ZM15.646,13.917L11.792,10.063L11.7,9.971L4.725,3L3.667,4.063L6.317,6.713C6.221,7.125 6.167,7.554 6.167,8C6.167,12.375 12,18.833 12,18.833C12,18.833 13.392,17.292 14.813,15.208L17.604,18L18.667,16.938L15.646,13.917Z"
-        android:strokeColor="#00000000"
-        android:fillColor="#F09300"
-        android:strokeWidth="1"/>
+        android:fillColor="#000000"
+        android:pathData="M14,10.5v9.06C12.87,21,12,22,12,22S5,14.25,5,9A7,7,0,0,1,18.93,8H14.29A2.5,2.5,0,1,0,14,10.5ZM16,22h2V20H16Zm0-4h2V10H16Z" />
 </vector>
diff --git a/res/drawable/ic_find_device_enabled.xml b/res/drawable/ic_find_device_enabled.xml
index c47b9f0..37c2bdc 100644
--- a/res/drawable/ic_find_device_enabled.xml
+++ b/res/drawable/ic_find_device_enabled.xml
@@ -14,19 +14,17 @@
     limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24dp"
-        android:height="24dp"
-        android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24"
+    android:tint="?android:attr/colorControlNormal">
+
     <path
-        android:pathData="M0,0l24,0l0,24l-24,0z"
-        android:strokeColor="#000000"
-        android:fillColor="#00000000"
-        android:strokeWidth="1.33333335e-11"
-        android:strokeAlpha="0.00784313771"/>
+        android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z" />
     <path
-        android:pathData="M18,8C18,4.69 15.31,2 12,2C8.69,2 6,4.69 6,8C6,12.5 12,19 12,19C12,19 18,12.5 18,8ZM10,8C10,6.9 10.9,6 12,6C13.1,6 14,6.9 14,8C14,9.1 13.11,10 12,10C10.9,10 10,9.1 10,8ZM5,20L5,22L19,22L19,20L5,20Z"
-        android:strokeColor="#00000000"
-        android:fillColor="#4A90E2"
-        android:strokeWidth="1"/>
+        android:fillColor="#000000"
+        android:pathData="M12,2 C8.13400675,2 5,5.13400675 5,9 C5,14.25 12,22 12,22 C12,22 19,14.25 19,9
+C19,5.13400675 15.8659932,2 12,2 L12,2 Z M8.2,9.66 L9.61,8.24 L11,9.66
+L15.24,5.42 L16.65,6.83 L11,12.49 L8.2,9.66 Z" />
 </vector>
diff --git a/res/drawable/ic_ota_update_available.xml b/res/drawable/ic_ota_update_available.xml
index e2d7f33..34d0a64 100644
--- a/res/drawable/ic_ota_update_available.xml
+++ b/res/drawable/ic_ota_update_available.xml
@@ -14,19 +14,15 @@
     limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24dp"
-        android:height="24dp"
-        android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24"
+    android:tint="?android:attr/colorControlNormal">
+
     <path
-        android:pathData="M0,0l24,0l0,24l-24,0z"
-        android:strokeColor="#000000"
-        android:fillColor="#00000000"
-        android:strokeWidth="1.33333335e-11"
-        android:strokeAlpha="0.00784313771"/>
+        android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z" />
     <path
-        android:pathData="M17,1.01L7,1C5.9,1 5,1.9 5,3L5,21C5,22.1 5.9,23 7,23L17,23C18.1,23 19,22.1 19,21L19,3C19,1.9 18.1,1.01 17,1.01ZM17,19L7,19L7,5L17,5L17,19ZM16,13L13,13L13,8L11,8L11,13L8,13L12,17L16,13Z"
-        android:strokeColor="#00000000"
-        android:fillColor="#4A90E2"
-        android:strokeWidth="1"/>
+        android:fillColor="#000000"
+        android:pathData="M17,1H7A2,2,0,0,0,5,3V21a2,2,0,0,0,2,2H17a2,2,0,0,0,2-2V3A2,2,0,0,0,17,1Zm0,18H7V5H17Zm-1-6H13V8H11v5H8l4,4Z" />
 </vector>
diff --git a/res/drawable/ic_ota_update_current.xml b/res/drawable/ic_ota_update_current.xml
index d7a2f84..6a1d7a4 100644
--- a/res/drawable/ic_ota_update_current.xml
+++ b/res/drawable/ic_ota_update_current.xml
@@ -14,19 +14,15 @@
     limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24dp"
-        android:height="24dp"
-        android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24"
+    android:tint="?android:attr/colorControlNormal">
+
     <path
-        android:pathData="M0,0l24,0l0,24l-24,0z"
-        android:strokeColor="#000000"
-        android:fillColor="#00000000"
-        android:strokeWidth="1.33333335e-11"
-        android:strokeAlpha="0.00784313771"/>
+        android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z" />
     <path
-        android:pathData="M17,1.01L7,1C5.9,1 5,1.9 5,3L5,21C5,22.1 5.9,23 7,23L17,23C18.1,23 19,22.1 19,21L19,3C19,1.9 18.1,1.01 17,1.01ZM17,19L7,19L7,5L17,5L17,19ZM10.627,13.093L9.144,11.746L8.054,12.79L10.627,15.181L16.156,10.044L15.066,9L10.627,13.093Z"
-        android:strokeColor="#00000000"
-        android:fillColor="#4A90E2"
-        android:strokeWidth="1"/>
+        android:fillColor="#000000"
+        android:pathData="M17,1H7A2,2,0,0,0,5,3V21a2,2,0,0,0,2,2H17a2,2,0,0,0,2-2V3A2,2,0,0,0,17,1ZM9.11,14.06h0l1.41,1.41,5.66-5.66-1.42-1.4-4.24,4.24L9.11,11.24,7.7,12.66ZM17,19H7V5H17Z" />
 </vector>
diff --git a/res/drawable/ic_ota_update_stale.xml b/res/drawable/ic_ota_update_stale.xml
index 9145be8..8e51a23 100644
--- a/res/drawable/ic_ota_update_stale.xml
+++ b/res/drawable/ic_ota_update_stale.xml
@@ -14,19 +14,15 @@
     limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24dp"
-        android:height="24dp"
-        android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24"
+    android:tint="?android:attr/colorControlNormal">
+
     <path
-        android:pathData="M0,0l24,0l0,24l-24,0z"
-        android:strokeColor="#000000"
-        android:fillColor="#00000000"
-        android:strokeWidth="1.33333335e-11"
-        android:strokeAlpha="0.00784313771"/>
+        android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z" />
     <path
-        android:pathData="M17,1.01L7,1C5.9,1 5,1.9 5,3L5,21C5,22.1 5.9,23 7,23L17,23C18.1,23 19,22.1 19,21L19,3C19,1.9 18.1,1.01 17,1.01ZM17,19L7,19L7,5L17,5L17,19ZM16,13L13,13L13,8L11,8L11,13L8,13L12,17L16,13Z"
-        android:strokeColor="#00000000"
-        android:fillColor="#F09300"
-        android:strokeWidth="1"/>
+        android:fillColor="#000000"
+        android:pathData="M17,1a2,2,0,0,1,2,2V21a2,2,0,0,1-2,2H7a2,2,0,0,1-2-2V3A2,2,0,0,1,7,1Zm0,18V5H7V19ZM11,6.5h2v7H11Zm0,9h2v2H11Z" />
 </vector>
diff --git a/res/drawable/ic_package_verifier_disabled.xml b/res/drawable/ic_package_verifier_disabled.xml
index 5f19fec..b4054f3 100644
--- a/res/drawable/ic_package_verifier_disabled.xml
+++ b/res/drawable/ic_package_verifier_disabled.xml
@@ -14,18 +14,15 @@
     limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24dp"
-        android:height="24dp"
-        android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24"
+    android:tint="?android:attr/colorControlNormal">
+
     <path
-        android:pathData="M5.785,3.762L12,1L21,5L21,11C21,13.231 20.381,15.402 19.306,17.283L5.785,3.762ZM4.386,4.384L3,5L3,11C3,16.555 6.835,21.735 12,23C14.622,22.358 16.902,20.706 18.511,18.509L4.386,4.384Z"
-        android:strokeColor="#00000000"
-        android:fillColor="#F09300"
-        android:strokeWidth="1"/>
+        android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z" />
     <path
-        android:pathData="M2.808,2.808l17.678,17.678l-1.01,1.01l-17.678,-17.678z"
-        android:strokeColor="#00000000"
-        android:fillColor="#F09300"
-        android:strokeWidth="1"/>
+        android:fillColor="#000000"
+        android:pathData="M13.45,11l2.12-2.12L14.16,7.5,12,9.62,9.91,7.5,8.5,8.91,10.62,11,8.5,13.16l1.41,1.41L12,12.45l2.12,2.12,1.41-1.41Zm8.1-7.11A16.54,16.54,0,0,1,22,7.77a16.65,16.65,0,0,1-.47,4,16.56,16.56,0,0,1-3.79,7.14A16.66,16.66,0,0,1,12,23,16.61,16.61,0,0,1,2.45,3.93,33.57,33.57,0,0,1,12,1a33.57,33.57,0,0,1,9.55,2.93Z" />
 </vector>
diff --git a/res/drawable/ic_package_verifier_enabled.xml b/res/drawable/ic_package_verifier_enabled.xml
index 1059442..90f1490 100644
--- a/res/drawable/ic_package_verifier_enabled.xml
+++ b/res/drawable/ic_package_verifier_enabled.xml
@@ -14,19 +14,15 @@
     limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24dp"
-        android:height="24dp"
-        android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24"
+    android:tint="?android:attr/colorControlNormal">
+
     <path
-        android:pathData="M0,0l24,0l0,24l-24,0z"
-        android:strokeColor="#000000"
-        android:fillColor="#00000000"
-        android:strokeWidth="1.33333335e-11"
-        android:strokeAlpha="0.00784313771"/>
+        android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z" />
     <path
-        android:pathData="M12,1L3,5L3,11C3,16.55 6.84,21.74 12,23C17.16,21.74 21,16.55 21,11L21,5L12,1Z"
-        android:strokeColor="#00000000"
-        android:fillColor="#4A90E2"
-        android:strokeWidth="1"/>
+        android:fillColor="#000000"
+        android:pathData="M21.55,3.93A16.54,16.54,0,0,1,22,7.77a16.65,16.65,0,0,1-.47,4,16.56,16.56,0,0,1-3.79,7.14A16.66,16.66,0,0,1,12,23,16.61,16.61,0,0,1,2.45,3.93,33.57,33.57,0,0,1,12,1,33.57,33.57,0,0,1,21.55,3.93ZM15.27,8.41,9.61,14.07,11,15.49l5.66-5.66ZM9.61,11.24,8.2,12.66l1.41,1.41L11,12.66Z" />
 </vector>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 236ec29..b255123 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4474,10 +4474,10 @@
     <!-- Title for the cellular network in power use UI(i.e. Mobile network scanning: 30% of battery usage) [CHAR_LIMIT=40] -->
     <string name="device_cellular_network">Mobile network scanning</string>
 
-    <!-- Label for time since last full charge in power use UI, i.e. "7 h 20 min ago" [CHAR_LIMIT=60] -->
-    <string name="power_last_full_charge_summary"><xliff:g id="time">%1$s</xliff:g> ago</string>
-    <!-- Label for list of apps using battery in power use UI [CHAR_LIMIT=120] -->
-    <string name="power_usage_list_summary">App usage since full charge (<xliff:g id="time">%1$s</xliff:g> ago)</string>
+    <!-- Label for time since last full charge in power use UI, i.e. "7 h 20 min ago". Note: ^1 should be used in all translations [CHAR_LIMIT=60] -->
+    <string name="power_last_full_charge_summary"><xliff:g id="time">^1</xliff:g> ago</string>
+    <!-- Label for list of apps using battery in power use UI. Note: ^1 should be used in all translations[CHAR_LIMIT=120] -->
+    <string name="power_usage_list_summary">App usage since full charge (<xliff:g id="time">^1</xliff:g> ago)</string>
     <!-- Description for the screen usage item [CHAR_LIMIT=120] -->
     <string name="screen_usage_summary">Amount of time screen has been on since full charge</string>
     <!-- Label for list of different types using battery in power use UI [CHAR_LIMIT=60] -->
@@ -4539,8 +4539,8 @@
     <string name="power_wifi">Wi\u2011Fi</string>
     <!-- Label for power consumed by Bluetooth -->
     <string name="power_bluetooth">Bluetooth</string>
-    <!-- Label for power consumed by Cell idle -->
-    <string name="power_cell">Cell standby</string>
+    <!-- Label for power consumed by Mobile network idle -->
+    <string name="power_cell">Mobile network standby</string>
     <!-- Label for power consumed by Calling -->
     <string name="power_phone">Voice calls</string>
     <!-- Label for power consumed when Idle -->
@@ -4676,8 +4676,8 @@
     <!-- Representation of a mAh value. [CHAR LIMIT=NONE] -->
     <string name="mah"><xliff:g id="number" example="30">%d</xliff:g> mAh</string>
 
-    <!-- Description for battery usage time for an app, i.e. Used for 30min. [CHAR LIMIT=60] -->
-    <string name="battery_used_for">Used for %1$s</string>
+    <!-- Description for battery usage time for an app, i.e. Used for 30min. Note: ^1 should be used in all translations [CHAR LIMIT=60] -->
+    <string name="battery_used_for">Used for <xliff:g id="time">^1</xliff:g></string>
     <!-- Description for battery usage info for an app, i.e. 60% used by facebook. [CHAR LIMIT=60] -->
     <string name="battery_used_by"><xliff:g id="percent">%1$s</xliff:g> used by <xliff:g id="app">%2$s</xliff:g></string>
     <!-- Description for percentage of battery usage for an app, i.e. Screen: 30% of overall battery. [CHAR LIMIT=60] -->
@@ -7678,11 +7678,11 @@
     <!-- Summary of app not allowed to write system settings [CHAR LIMIT=45] -->
     <string name="write_settings_off">No</string>
     <!-- Summary of app trusted to install apps [CHAR LIMIT=45] -->
-    <string name="external_source_trusted">Yes</string>
+    <string name="external_source_trusted">Allowed</string>
     <!-- Summary of app not trusted to install apps [CHAR LIMIT=45] -->
-    <string name="external_source_untrusted">No</string>
+    <string name="external_source_untrusted">Not allowed</string>
     <!-- Title of switch preference that controls whether an external app source is trusted or not [CHAR LIMIT=50] -->
-    <string name="external_source_switch_title">Allow app installs</string>
+    <string name="external_source_switch_title">Allow from this source</string>
 
     <!-- Title of setting that controls gesture to open camera [CHAR LIMIT=40] -->
     <string name="camera_gesture_title">Double twist for camera</string>
@@ -8171,8 +8171,11 @@
     <!-- Summary for Bluetooth when disabled. [CHAR LIMIT=NONE] -->
     <string name="bluetooth_disabled">Not visible to other devices</string>
 
-    <!-- Summary for Bluetooth when connected. [CHAR LIMIT=NONE] -->
-    <string name="bluetooth_connected_summary">Connected to </string>
+    <!-- Summary for Bluetooth when connected to one device. [CHAR LIMIT=NONE] -->
+    <string name="bluetooth_connected_summary">Connected to <xliff:g name="device">%1$s</xliff:g></string>
+
+    <!-- Summary for Bluetooth when connected to multiple devices. [CHAR LIMIT=NONE] -->
+    <string name="bluetooth_connected_multiple_devices_summary">Connected to multiple devices</string>
 
     <!-- [CHAR LIMIT=60] Name of dev option called "System UI demo mode" -->
     <string name="demo_mode">System UI demo mode</string>
diff --git a/res/xml/app_and_notification.xml b/res/xml/app_and_notification.xml
index adbd402..627d3f8 100644
--- a/res/xml/app_and_notification.xml
+++ b/res/xml/app_and_notification.xml
@@ -23,7 +23,6 @@
     <Preference
         android:key="manage_perms"
         android:title="@string/app_permissions"
-        android:icon="@drawable/ic_apps"
         android:order="-130"
         settings:keywords="@string/keywords_app_permissions">
         <intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml
index 2866767..abd659e 100644
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -46,7 +46,7 @@
 
         <com.android.settings.widget.MasterSwitchPreference
             android:fragment="com.android.settings.fuelgauge.BatterySaverSettings"
-            android:key="battery_saver"
+            android:key="battery_saver_summary"
             android:title="@string/battery_saver"/>
 
         <SwitchPreference
@@ -56,14 +56,14 @@
 
         <!-- Cross-listed item, if you change this, also change it in ia_display_settings.xml -->
         <SwitchPreference
-            android:key="auto_brightness"
+            android:key="auto_brightness_battery"
             android:title="@string/auto_brightness_title"
             android:summary="@string/auto_brightness_summary"
             settings:keywords="@string/keywords_display_auto_brightness"/>
 
         <!-- Cross-listed item, if you change this, also change it in ia_display_settings.xml -->
         <com.android.settings.TimeoutListPreference
-            android:key="screen_timeout"
+            android:key="screen_timeout_battery"
             android:title="@string/screen_timeout"
             android:summary="@string/screen_timeout_summary"
             android:entries="@array/screen_timeout_entries"
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index 1230ae5..951a26b 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -51,6 +51,9 @@
 public class DisplaySettings extends DashboardFragment {
     private static final String TAG = "DisplaySettings";
 
+    private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness";
+    private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
+
     @Override
     public int getMetricsCategory() {
         return MetricsEvent.DISPLAY;
@@ -85,7 +88,7 @@
     private static List<PreferenceController> buildPreferenceControllers(
             Context context, Lifecycle lifecycle) {
         final List<PreferenceController> controllers = new ArrayList<>();
-        controllers.add(new AutoBrightnessPreferenceController(context));
+        controllers.add(new AutoBrightnessPreferenceController(context, KEY_AUTO_BRIGHTNESS));
         controllers.add(new AutoRotatePreferenceController(context));
         controllers.add(new CameraGesturePreferenceController(context));
         controllers.add(new DozePreferenceController(context));
@@ -100,7 +103,7 @@
         controllers.add(new DoubleTapScreenPreferenceController(
                 context, lifecycle, ambientDisplayConfig, UserHandle.myUserId()));
         controllers.add(new TapToWakePreferenceController(context));
-        controllers.add(new TimeoutPreferenceController(context));
+        controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT));
         controllers.add(new VrDisplayPreferenceController(context));
         controllers.add(new WallpaperPreferenceController(context));
         controllers.add(new ThemePreferenceController(context));
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index fa9410d..69f563e 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -284,11 +284,13 @@
                     .getAuthenticatorTypesAsUser(profileId);
             final int M = descs.length;
 
-            View titleView = Utils.inflateCategoryHeader(inflater, contents);
-            final TextView titleText = (TextView) titleView.findViewById(android.R.id.title);
-            titleText.setText(userInfo.isManagedProfile() ? R.string.category_work
-                    : R.string.category_personal);
-            contents.addView(titleView);
+            if (profilesSize > 1) {
+                View titleView = Utils.inflateCategoryHeader(inflater, contents);
+                final TextView titleText = (TextView) titleView.findViewById(android.R.id.title);
+                titleText.setText(userInfo.isManagedProfile() ? R.string.category_work
+                        : R.string.category_personal);
+                contents.addView(titleView);
+            }
 
             for (int i = 0; i < N; i++) {
                 Account account = accounts[i];
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index d04ae8d..f6f980a 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -81,6 +81,8 @@
 import android.telephony.TelephonyManager;
 import android.text.Spannable;
 import android.text.SpannableString;
+import android.text.SpannableStringBuilder;
+import android.text.Spanned;
 import android.text.TextUtils;
 import android.text.format.DateUtils;
 import android.text.style.TtsSpan;
@@ -770,8 +772,9 @@
      * @param withSeconds include seconds?
      * @return the formatted elapsed time
      */
-    public static String formatElapsedTime(Context context, double millis, boolean withSeconds) {
-        StringBuilder sb = new StringBuilder();
+    public static CharSequence formatElapsedTime(Context context, double millis,
+            boolean withSeconds) {
+        SpannableStringBuilder sb = new SpannableStringBuilder();
         int seconds = (int) Math.floor(millis / 1000);
         if (!withSeconds) {
             // Round up.
@@ -812,9 +815,15 @@
                         hours, minutes));
             } else {
                 sb.append(context.getString(R.string.battery_history_minutes_no_seconds, minutes));
+
+                // Add ttsSpan if it only have minute value, because it will be read as "meters"
+                TtsSpan ttsSpan = new TtsSpan.MeasureBuilder().setNumber(minutes)
+                        .setUnit("minute").build();
+                sb.setSpan(ttsSpan, 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
             }
         }
-        return sb.toString();
+
+        return sb;
     }
 
     /**
@@ -1256,4 +1265,5 @@
         return (volume != null) && (volume.getType() == VolumeInfo.TYPE_PRIVATE)
                 && volume.isMountedReadable();
     }
+
 }
diff --git a/src/com/android/settings/applications/AppHeaderController.java b/src/com/android/settings/applications/AppHeaderController.java
index 45938ae..804d645 100644
--- a/src/com/android/settings/applications/AppHeaderController.java
+++ b/src/com/android/settings/applications/AppHeaderController.java
@@ -52,15 +52,13 @@
     @IntDef({ActionType.ACTION_NONE,
             ActionType.ACTION_APP_INFO,
             ActionType.ACTION_APP_PREFERENCE,
-            ActionType.ACTION_STORE_DEEP_LINK,
             ActionType.ACTION_NOTIF_PREFERENCE})
     @Retention(RetentionPolicy.SOURCE)
     public @interface ActionType {
         int ACTION_NONE = 0;
         int ACTION_APP_INFO = 1;
-        int ACTION_STORE_DEEP_LINK = 2;
-        int ACTION_APP_PREFERENCE = 3;
-        int ACTION_NOTIF_PREFERENCE = 4;
+        int ACTION_APP_PREFERENCE = 2;
+        int ACTION_NOTIF_PREFERENCE = 3;
     }
 
     public static final String PREF_KEY_APP_HEADER = "pref_app_header";
@@ -254,20 +252,6 @@
                 }
                 return;
             }
-            case ActionType.ACTION_STORE_DEEP_LINK: {
-                final Intent intent = new Intent(Intent.ACTION_SHOW_APP_INFO)
-                        .setPackage(getInstallerPackageName(mContext, mPackageName));
-                final Intent result = resolveIntent(intent);
-                if (result == null) {
-                    button.setVisibility(View.GONE);
-                } else {
-                    result.putExtra(Intent.EXTRA_PACKAGE_NAME, mPackageName);
-                    button.setImageResource(R.drawable.ic_sim_sd);
-                    button.setOnClickListener(v -> mFragment.startActivity(intent));
-                    button.setVisibility(View.VISIBLE);
-                }
-                return;
-            }
             case ActionType.ACTION_NOTIF_PREFERENCE: {
                 if (mAppNotifPrefIntent == null) {
                     button.setVisibility(View.GONE);
@@ -295,15 +279,6 @@
         }
     }
 
-    private String getInstallerPackageName(Context context, String packageName) {
-        try {
-            return context.getPackageManager().getInstallerPackageName(packageName);
-        } catch (IllegalArgumentException e) {
-            Log.e(TAG, "Exception while retrieving the package installer of " + packageName, e);
-            return null;
-        }
-    }
-
     private Intent resolveIntent(Intent i) {
         ResolveInfo result = mContext.getPackageManager().resolveActivity(i, 0);
         if (result != null) {
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 09771f2..16621f4 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -415,8 +415,8 @@
                 .getApplicationFeatureProvider(activity)
                 .newAppHeaderController(this, mHeader.findViewById(R.id.app_snippet))
                 .setPackageName(mPackageName)
-                .setButtonActions(AppHeaderController.ActionType.ACTION_STORE_DEEP_LINK,
-                        AppHeaderController.ActionType.ACTION_APP_PREFERENCE)
+                .setButtonActions(AppHeaderController.ActionType.ACTION_APP_PREFERENCE,
+                        AppHeaderController.ActionType.ACTION_NONE)
                 .styleActionBar(activity)
                 .bindAppHeaderButtons();
         prepareUninstallAndStop();
diff --git a/src/com/android/settings/applications/LayoutPreference.java b/src/com/android/settings/applications/LayoutPreference.java
index b958b3a..b823f8e 100644
--- a/src/com/android/settings/applications/LayoutPreference.java
+++ b/src/com/android/settings/applications/LayoutPreference.java
@@ -18,6 +18,7 @@
 
 import android.content.Context;
 import android.content.res.TypedArray;
+import android.support.annotation.VisibleForTesting;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceViewHolder;
 import android.util.AttributeSet;
@@ -31,7 +32,10 @@
 
 public class LayoutPreference extends Preference {
 
-    private View mRootView;
+    private final View.OnClickListener mClickListener = v -> performClick(v);
+
+    @VisibleForTesting
+    View mRootView;
 
     public LayoutPreference(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -59,7 +63,7 @@
 
     private void setView(View view) {
         setLayoutResource(R.layout.layout_preference_frame);
-        final ViewGroup allDetails = (ViewGroup) view.findViewById(R.id.all_details);
+        final ViewGroup allDetails = view.findViewById(R.id.all_details);
         if (allDetails != null) {
             Utils.forceCustomPadding(allDetails, true /* additive padding */);
         }
@@ -68,9 +72,14 @@
     }
 
     @Override
-    public void onBindViewHolder(PreferenceViewHolder view) {
-        super.onBindViewHolder(view);
-        FrameLayout layout = (FrameLayout) view.itemView;
+    public void onBindViewHolder(PreferenceViewHolder holder) {
+        holder.itemView.setOnClickListener(mClickListener);
+
+        final boolean selectable = isSelectable();
+        holder.itemView.setFocusable(selectable);
+        holder.itemView.setClickable(selectable);
+
+        FrameLayout layout = (FrameLayout) holder.itemView;
         layout.removeAllViews();
         ViewGroup parent = (ViewGroup) mRootView.getParent();
         if (parent != null) {
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingService.java b/src/com/android/settings/bluetooth/BluetoothPairingService.java
index 41a5cce..58df919 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingService.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingService.java
@@ -17,6 +17,8 @@
 package com.android.settings.bluetooth;
 
 import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.NotificationChannel;
 import android.app.PendingIntent;
 import android.app.Service;
 import android.bluetooth.BluetoothDevice;
@@ -37,119 +39,147 @@
  */
 public final class BluetoothPairingService extends Service {
 
-  private static final int NOTIFICATION_ID = android.R.drawable.stat_sys_data_bluetooth;
+    private static final int NOTIFICATION_ID = android.R.drawable.stat_sys_data_bluetooth;
 
-  private static final String TAG = "BluetoothPairingService";
+    private static final String ACTION_DISMISS_PAIRING =
+            "com.android.settings.bluetooth.ACTION_DISMISS_PAIRING";
 
-  private BluetoothDevice mDevice;
+    private static final String BLUETOOTH_NOTIFICATION_CHANNEL =
+            "bluetooth_notification_channel";
 
-  public static Intent getPairingDialogIntent(Context context, Intent intent) {
+    private static final String TAG = "BluetoothPairingService";
 
-    BluetoothDevice device =
-        intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
-    int type = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
-        BluetoothDevice.ERROR);
-    Intent pairingIntent = new Intent();
-    pairingIntent.setClass(context, BluetoothPairingDialog.class);
-    pairingIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
-    pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, type);
-    if (type == BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION ||
-        type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY ||
-        type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN) {
-      int pairingKey = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_KEY,
-          BluetoothDevice.ERROR);
-      pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_KEY, pairingKey);
-    }
-    pairingIntent.setAction(BluetoothDevice.ACTION_PAIRING_REQUEST);
-    pairingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-    return pairingIntent;
-  }
+    private BluetoothDevice mDevice;
 
-  private boolean mRegistered = false;
-  private final BroadcastReceiver mCancelReceiver = new BroadcastReceiver() {
-    @Override
-    public void onReceive(Context context, Intent intent) {
-      String action = intent.getAction();
-      if (action.equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)) {
-        int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE,
-            BluetoothDevice.ERROR);
-        if ((bondState != BluetoothDevice.BOND_NONE) && (bondState != BluetoothDevice.BOND_BONDED)) {
-          return;
+    public static Intent getPairingDialogIntent(Context context, Intent intent) {
+        BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+        int type = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
+                BluetoothDevice.ERROR);
+        Intent pairingIntent = new Intent();
+        pairingIntent.setClass(context, BluetoothPairingDialog.class);
+        pairingIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
+        pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, type);
+        if (type == BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION ||
+                type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY ||
+                type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN) {
+            int pairingKey = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_KEY,
+                    BluetoothDevice.ERROR);
+            pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_KEY, pairingKey);
         }
-        Log.d(TAG, "Dismiss pairing for " + mDevice.getAddress() + " (" + mDevice.getName() + "), BondState: " + bondState);
-      } else {
-        Log.d(TAG, "Dismiss pairing for " + mDevice.getAddress() + " (" + mDevice.getName() + "), Cancelled.");
-      }
-      stopForeground(true);
-      stopSelf();
-    }
-  };
-
-  @Override
-  public void onCreate() {
-  }
-
-  @Override
-  public int onStartCommand(Intent intent, int flags, int startId) {
-    if (intent == null) {
-      Log.e(TAG, "Can't start: null intent!");
-      stopSelf();
-      return START_NOT_STICKY;
+        pairingIntent.setAction(BluetoothDevice.ACTION_PAIRING_REQUEST);
+        pairingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        return pairingIntent;
     }
 
-    Resources res = getResources();
-    Notification.Builder builder = new Notification.Builder(this)
-        .setSmallIcon(android.R.drawable.stat_sys_data_bluetooth)
-        .setTicker(res.getString(R.string.bluetooth_notif_ticker));
+    private boolean mRegistered = false;
+    private final BroadcastReceiver mCancelReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String action = intent.getAction();
+            if (action.equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)) {
+                int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE,
+                        BluetoothDevice.ERROR);
+                if ((bondState != BluetoothDevice.BOND_NONE) && (bondState != BluetoothDevice.BOND_BONDED)) {
+                    return;
+                }
+            } else if (action.equals(ACTION_DISMISS_PAIRING)) {
+                Log.d(TAG, "Notification cancel " + mDevice.getAddress() + " (" +
+                        mDevice.getName() + ")");
+                mDevice.cancelPairingUserInput();
+            } else {
+                int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE,
+                        BluetoothDevice.ERROR);
+                Log.d(TAG, "Dismiss pairing for " + mDevice.getAddress() + " (" +
+                        mDevice.getName() + "), BondState: " + bondState);
+            }
+            stopForeground(true);
+            stopSelf();
+        }
+    };
 
-    PendingIntent pending = PendingIntent.getActivity(this, 0,
-        getPairingDialogIntent(this, intent), PendingIntent.FLAG_ONE_SHOT);
-
-    mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
-
-    if (mDevice.getBondState() != BluetoothDevice.BOND_BONDING) {
-      Log.w(TAG, "Device " + mDevice + " not bonding: " + mDevice.getBondState());
-      stopSelf();
-      return START_NOT_STICKY;
+    @Override
+    public void onCreate() {
+      NotificationManager mgr = (NotificationManager)this
+         .getSystemService(Context.NOTIFICATION_SERVICE);
+      NotificationChannel notificationChannel = new NotificationChannel(
+         BLUETOOTH_NOTIFICATION_CHANNEL,
+         this.getString(R.string.bluetooth),
+         NotificationManager.IMPORTANCE_HIGH);
+      mgr.createNotificationChannel(notificationChannel);
     }
 
-    String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
-    if (TextUtils.isEmpty(name)) {
-      BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
-      name = device != null ? device.getAliasName() : getString(android.R.string.unknownName);
+    @Override
+    public int onStartCommand(Intent intent, int flags, int startId) {
+        if (intent == null) {
+            Log.e(TAG, "Can't start: null intent!");
+            stopSelf();
+            return START_NOT_STICKY;
+        }
+
+        Resources res = getResources();
+        Notification.Builder builder = new Notification.Builder(this,
+            BLUETOOTH_NOTIFICATION_CHANNEL)
+                .setSmallIcon(android.R.drawable.stat_sys_data_bluetooth)
+                .setTicker(res.getString(R.string.bluetooth_notif_ticker));
+
+        PendingIntent pairIntent = PendingIntent.getActivity(this, 0,
+                getPairingDialogIntent(this, intent), PendingIntent.FLAG_ONE_SHOT);
+
+        PendingIntent dismissIntent = PendingIntent.getBroadcast(this, 0,
+                new Intent(ACTION_DISMISS_PAIRING), PendingIntent.FLAG_ONE_SHOT);
+
+        mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+
+        if (mDevice != null && mDevice.getBondState() != BluetoothDevice.BOND_BONDING) {
+            Log.w(TAG, "Device " + mDevice + " not bonding: " + mDevice.getBondState());
+            stopSelf();
+            return START_NOT_STICKY;
+        }
+
+        String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
+        if (TextUtils.isEmpty(name)) {
+            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+            name = device != null ? device.getAliasName() : res.getString(android.R.string.unknownName);
+        }
+
+        Log.d(TAG, "Show pairing notification for " + mDevice.getAddress() + " (" + name + ")");
+
+        Notification.Action pairAction = new Notification.Action.Builder(0,
+                res.getString(R.string.bluetooth_device_context_pair_connect), pairIntent).build();
+        Notification.Action dismissAction = new Notification.Action.Builder(0,
+                res.getString(android.R.string.cancel), dismissIntent).build();
+
+        builder.setContentTitle(res.getString(R.string.bluetooth_notif_title))
+                .setContentText(res.getString(R.string.bluetooth_notif_message, name))
+                .setContentIntent(pairIntent)
+                .setDefaults(Notification.DEFAULT_SOUND)
+                .setColor(getColor(com.android.internal.R.color.system_notification_accent_color))
+                .addAction(pairAction)
+                .addAction(dismissAction);
+
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
+        filter.addAction(BluetoothDevice.ACTION_PAIRING_CANCEL);
+        filter.addAction(ACTION_DISMISS_PAIRING);
+        registerReceiver(mCancelReceiver, filter);
+        mRegistered = true;
+
+        startForeground(NOTIFICATION_ID, builder.getNotification());
+        return START_REDELIVER_INTENT;
     }
 
-    Log.d(TAG, "Show pairing notification for " + mDevice.getAddress() + " (" + name + ")");
-
-    builder.setContentTitle(res.getString(R.string.bluetooth_notif_title))
-        .setContentText(res.getString(R.string.bluetooth_notif_message, name))
-        .setContentIntent(pending)
-        .setDefaults(Notification.DEFAULT_SOUND)
-        .setColor(getColor(com.android.internal.R.color.system_notification_accent_color));
-
-    IntentFilter filter = new IntentFilter();
-    filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
-    filter.addAction(BluetoothDevice.ACTION_PAIRING_CANCEL);
-    registerReceiver(mCancelReceiver, filter);
-    mRegistered = true;
-
-    startForeground(NOTIFICATION_ID, builder.getNotification());
-    return START_REDELIVER_INTENT;
-  }
-
-  @Override
-  public void onDestroy() {
-    if (mRegistered) {
-      unregisterReceiver(mCancelReceiver);
-      mRegistered = false;
+    @Override
+    public void onDestroy() {
+        if (mRegistered) {
+            unregisterReceiver(mCancelReceiver);
+            mRegistered = false;
+        }
+        stopForeground(true);
     }
-    stopForeground(true);
-  }
 
-  @Override
-  public IBinder onBind(Intent intent) {
-    // No binding.
-    return null;
-  }
-
+    @Override
+    public IBinder onBind(Intent intent) {
+        // No binding.
+        return null;
+    }
 }
diff --git a/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java b/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java
index 282f613..5a2dcb2 100644
--- a/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java
@@ -17,14 +17,22 @@
 package com.android.settings.bluetooth;
 
 import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
 import android.content.Context;
+import android.support.annotation.VisibleForTesting;
+import android.text.TextUtils;
+
 import com.android.settings.R;
 import com.android.settings.widget.SummaryUpdater;
 import com.android.settingslib.bluetooth.BluetoothCallback;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
 import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
+
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
+import java.util.Set;
 
 /**
  * Helper class that listeners to bluetooth callback and notify client when there is update in
@@ -98,7 +106,7 @@
         }
         switch (mConnectionState) {
             case BluetoothAdapter.STATE_CONNECTED:
-                return mContext.getString(R.string.bluetooth_connected_summary);
+                return getConnectedDeviceSummary();
             case BluetoothAdapter.STATE_CONNECTING:
                 return mContext.getString(R.string.bluetooth_connecting);
             case BluetoothAdapter.STATE_DISCONNECTING:
@@ -145,4 +153,27 @@
             : null;
     }
 
+    @VisibleForTesting
+    String getConnectedDeviceSummary() {
+        String deviceName = null;
+        int count = 0;
+        final Set<BluetoothDevice> devices = mBluetoothAdapter.getBondedDevices();
+        if (devices == null || devices.isEmpty()) {
+            return null;
+        }
+
+        for (BluetoothDevice device : devices) {
+            if (device.isConnected()) {
+                deviceName = device.getName();
+                count++;
+                if (count > 1) {
+                    break;
+                }
+            }
+        }
+
+        return count > 1 ? mContext.getString(R.string.bluetooth_connected_multiple_devices_summary)
+                : mContext.getString(R.string.bluetooth_connected_summary, deviceName);
+    }
+
 }
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionsChecks.java b/src/com/android/settings/dashboard/suggestions/SuggestionsChecks.java
index 9a92c93..1be2c68 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionsChecks.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionsChecks.java
@@ -68,7 +68,11 @@
         } else if (className.equals(ScreenLockSuggestionActivity.class.getName())) {
             return isDeviceSecured();
         } else if (className.equals(FingerprintEnrollSuggestionActivity.class.getName())) {
-            return isDeviceSecured() || !isFingerprintEnabled();
+            FingerprintManager manager = Utils.getFingerprintManagerOrNull(mContext);
+            if (manager == null || !isFingerprintEnabled()) {
+                return true;
+            }
+            return manager.hasEnrolledFingerprints();
         }
 
         SuggestionFeatureProvider provider =
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index 5c4e354..31ca148 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -275,6 +275,7 @@
         intent.setAction(android.content.Intent.ACTION_VIEW);
         intent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
         intent.setType(IMAGE_MIME_TYPE);
+        intent.putExtra(Intent.EXTRA_FROM_STORAGE, true);
         return intent;
     }
 
diff --git a/src/com/android/settings/display/AutoBrightnessPreferenceController.java b/src/com/android/settings/display/AutoBrightnessPreferenceController.java
index 83304c2..6f9a302 100644
--- a/src/com/android/settings/display/AutoBrightnessPreferenceController.java
+++ b/src/com/android/settings/display/AutoBrightnessPreferenceController.java
@@ -33,10 +33,11 @@
 public class AutoBrightnessPreferenceController extends PreferenceController implements
         Preference.OnPreferenceChangeListener {
 
-    private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness";
+    private final String mAutoBrightnessKey;
 
-    public AutoBrightnessPreferenceController(Context context) {
+    public AutoBrightnessPreferenceController(Context context, String key) {
         super(context);
+        mAutoBrightnessKey = key;
     }
 
     @Override
@@ -47,7 +48,7 @@
 
     @Override
     public String getPreferenceKey() {
-        return KEY_AUTO_BRIGHTNESS;
+        return mAutoBrightnessKey;
     }
 
     @Override
diff --git a/src/com/android/settings/display/TimeoutPreferenceController.java b/src/com/android/settings/display/TimeoutPreferenceController.java
index d409656..b2890c2 100644
--- a/src/com/android/settings/display/TimeoutPreferenceController.java
+++ b/src/com/android/settings/display/TimeoutPreferenceController.java
@@ -35,10 +35,11 @@
     /** If there is no setting in the provider, use this. */
     public static final int FALLBACK_SCREEN_TIMEOUT_VALUE = 30000;
 
-    private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
+    private final String mScreenTimeoutKey;
 
-    public TimeoutPreferenceController(Context context) {
+    public TimeoutPreferenceController(Context context, String key) {
         super(context);
+        mScreenTimeoutKey = key;
     }
 
     @Override
@@ -48,7 +49,7 @@
 
     @Override
     public String getPreferenceKey() {
-        return KEY_SCREEN_TIMEOUT;
+        return mScreenTimeoutKey;
     }
 
     @Override
diff --git a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
index 0c798a6..eede37a 100644
--- a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
+++ b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
@@ -28,6 +28,7 @@
 import android.support.annotation.VisibleForTesting;
 import android.support.v14.preference.PreferenceFragment;
 import android.support.v7.preference.Preference;
+import android.text.TextUtils;
 import android.view.View;
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -82,6 +83,8 @@
     ApplicationsState mState;
     @VisibleForTesting
     ApplicationsState.AppEntry mAppEntry;
+    @VisibleForTesting
+    BatteryUtils mBatteryUtils;
 
     private Preference mForegroundPreference;
     private Preference mBackgroundPreference;
@@ -101,11 +104,12 @@
         final BatterySipper sipper = entry.sipper;
         final BatteryStats.Uid uid = sipper.uidObj;
         final BatteryUtils batteryUtils = BatteryUtils.getInstance(caller);
+        final boolean isTypeApp = sipper.drainType == BatterySipper.DrainType.APP;
 
-        final long backgroundTimeMs = batteryUtils.getProcessTimeMs(
-                BatteryUtils.StatusType.BACKGROUND, uid, which);
-        final long foregroundTimeMs = batteryUtils.getProcessTimeMs(
-                BatteryUtils.StatusType.FOREGROUND, uid, which);
+        final long foregroundTimeMs = isTypeApp ? batteryUtils.getProcessTimeMs(
+                BatteryUtils.StatusType.FOREGROUND, uid, which) : sipper.usageTimeMs;
+        final long backgroundTimeMs = isTypeApp ? batteryUtils.getProcessTimeMs(
+                BatteryUtils.StatusType.BACKGROUND, uid, which) : 0;
 
         if (ArrayUtils.isEmpty(sipper.mPackages)) {
             // populate data for system app
@@ -136,6 +140,7 @@
                 (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE));
         mUserManager = (UserManager) activity.getSystemService(Context.USER_SERVICE);
         mPackageManager = activity.getPackageManager();
+        mBatteryUtils = BatteryUtils.getInstance(getContext());
     }
 
     @Override
diff --git a/src/com/android/settings/fuelgauge/BatterySaverController.java b/src/com/android/settings/fuelgauge/BatterySaverController.java
index 08d570a..34c9a26 100644
--- a/src/com/android/settings/fuelgauge/BatterySaverController.java
+++ b/src/com/android/settings/fuelgauge/BatterySaverController.java
@@ -43,7 +43,7 @@
 
 public class BatterySaverController extends PreferenceController implements
         Preference.OnPreferenceChangeListener, LifecycleObserver, OnStart, OnStop {
-    private static final String KEY_BATTERY_SAVER = "battery_saver";
+    private static final String KEY_BATTERY_SAVER = "battery_saver_summary";
     private static final String TAG = "BatterySaverController";
     private static final boolean DEBUG = false;
 
diff --git a/src/com/android/settings/fuelgauge/BatteryUtils.java b/src/com/android/settings/fuelgauge/BatteryUtils.java
index 48e2421..c8af4a0 100644
--- a/src/com/android/settings/fuelgauge/BatteryUtils.java
+++ b/src/com/android/settings/fuelgauge/BatteryUtils.java
@@ -15,14 +15,13 @@
  */
 package com.android.settings.fuelgauge;
 
-import android.annotation.IntDef;
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.os.BatteryStats;
 import android.os.SystemClock;
+import android.support.annotation.IntDef;
 import android.support.annotation.Nullable;
 import android.support.annotation.VisibleForTesting;
-import android.text.format.DateUtils;
 import android.util.Log;
 
 import com.android.internal.os.BatterySipper;
@@ -64,7 +63,8 @@
         return sInstance;
     }
 
-    private BatteryUtils(Context context) {
+    @VisibleForTesting
+    BatteryUtils(Context context) {
         mPackageManager = context.getPackageManager();
         mPowerUsageFeatureProvider = FeatureFactory.getFactory(
                 context).getPowerUsageFeatureProvider(context);
diff --git a/src/com/android/settings/fuelgauge/PowerGaugePreference.java b/src/com/android/settings/fuelgauge/PowerGaugePreference.java
index bdadf4c..b124c81 100644
--- a/src/com/android/settings/fuelgauge/PowerGaugePreference.java
+++ b/src/com/android/settings/fuelgauge/PowerGaugePreference.java
@@ -79,11 +79,15 @@
         return mProgress.toString();
     }
 
-    public void setSubtitle(String subtitle) {
+    public void setSubtitle(CharSequence subtitle) {
         mProgress = subtitle;
         notifyChanged();
     }
 
+    public CharSequence getSubtitle() {
+        return mProgress;
+    }
+
     BatteryEntry getInfo() {
         return mInfo;
     }
diff --git a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
index 722f4ad..28dfe1d 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
@@ -29,6 +29,7 @@
 import android.support.annotation.VisibleForTesting;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceGroup;
+import android.text.TextUtils;
 
 import com.android.internal.logging.nano.MetricsProto;
 import com.android.internal.os.BatterySipper;
@@ -60,7 +61,6 @@
     final int[] mUsageTypes = {
             UsageType.WIFI,
             UsageType.CELL,
-            UsageType.SERVICE,
             UsageType.SYSTEM,
             UsageType.BLUETOOTH,
             UsageType.USER,
@@ -68,13 +68,15 @@
             UsageType.APP,
             UsageType.UNACCOUNTED,
             UsageType.OVERCOUNTED};
+
+    @VisibleForTesting
+    BatteryUtils mBatteryUtils;
     private BatteryHistoryPreference mHistPref;
     private PreferenceGroup mUsageListGroup;
     private PowerUsageFeatureProvider mPowerUsageFeatureProvider;
     private PackageManager mPackageManager;
     private UserManager mUserManager;
     private Map<Integer, PowerUsageData> mBatteryDataMap;
-    private BatteryUtils mBatteryUtils;
 
     Handler mHandler = new Handler() {
 
@@ -207,10 +209,9 @@
             return UsageType.UNACCOUNTED;
         } else if (drainType == DrainType.OVERCOUNTED) {
             return UsageType.OVERCOUNTED;
-        } else if (mPowerUsageFeatureProvider.isTypeSystem(sipper)) {
+        } else if (mPowerUsageFeatureProvider.isTypeSystem(sipper)
+                || mPowerUsageFeatureProvider.isTypeService(sipper)) {
             return UsageType.SYSTEM;
-        } else if (mPowerUsageFeatureProvider.isTypeService(sipper)) {
-            return UsageType.SERVICE;
         } else {
             return UsageType.APP;
         }
@@ -272,8 +273,10 @@
             return;
         }
         if (usageData.usageList.size() <= 1) {
-            usageData.summary = getString(R.string.battery_used_for,
-                    Utils.formatElapsedTime(getContext(), usageData.totalUsageTimeMs, false));
+            CharSequence timeSequence = Utils.formatElapsedTime(getContext(),
+                    usageData.totalUsageTimeMs, false);
+            usageData.summary = TextUtils.expandTemplate(getText(R.string.battery_used_for),
+                    timeSequence);
         } else {
             BatterySipper sipper = findBatterySipperWithMaxBatteryUsage(usageData.usageList);
             BatteryEntry batteryEntry = new BatteryEntry(getContext(), mHandler, mUserManager,
@@ -328,7 +331,6 @@
         @IntDef({UsageType.APP,
                 UsageType.WIFI,
                 UsageType.CELL,
-                UsageType.SERVICE,
                 UsageType.SYSTEM,
                 UsageType.BLUETOOTH,
                 UsageType.USER,
@@ -339,18 +341,17 @@
             int APP = 0;
             int WIFI = 1;
             int CELL = 2;
-            int SERVICE = 3;
-            int SYSTEM = 4;
-            int BLUETOOTH = 5;
-            int USER = 6;
-            int IDLE = 7;
-            int UNACCOUNTED = 8;
-            int OVERCOUNTED = 9;
+            int SYSTEM = 3;
+            int BLUETOOTH = 4;
+            int USER = 5;
+            int IDLE = 6;
+            int UNACCOUNTED = 7;
+            int OVERCOUNTED = 8;
         }
 
         @StringRes
         public int titleResId;
-        public String summary;
+        public CharSequence summary;
         public double percentage;
         public double totalPowerMah;
         public long totalUsageTimeMs;
@@ -379,8 +380,6 @@
                     return R.string.power_wifi;
                 case UsageType.CELL:
                     return R.string.power_cell;
-                case UsageType.SERVICE:
-                    return R.string.power_service;
                 case UsageType.SYSTEM:
                     return R.string.power_system;
                 case UsageType.BLUETOOTH:
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 5f12d7c..1bc67af 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -86,6 +86,9 @@
     private static final String KEY_SCREEN_USAGE = "screen_usage";
     private static final String KEY_TIME_SINCE_LAST_FULL_CHARGE = "last_full_charge";
 
+    private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness_battery";
+    private static final String KEY_SCREEN_TIMEOUT = "screen_timeout_battery";
+    private static final String KEY_BATTERY_SAVER_SUMMARY = "battery_saver_summary";
 
     private static final int MENU_STATS_TYPE = Menu.FIRST;
     @VisibleForTesting
@@ -185,8 +188,8 @@
     @Override
     protected List<PreferenceController> getPreferenceControllers(Context context) {
         final List<PreferenceController> controllers = new ArrayList<>();
-        controllers.add(new AutoBrightnessPreferenceController(context));
-        controllers.add(new TimeoutPreferenceController(context));
+        controllers.add(new AutoBrightnessPreferenceController(context, KEY_AUTO_BRIGHTNESS));
+        controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT));
         controllers.add(new BatterySaverController(context, getLifecycle()));
         controllers.add(new BatteryPercentagePreferenceController(context));
         return controllers;
@@ -415,15 +418,16 @@
         final TypedValue value = new TypedValue();
         context.getTheme().resolveAttribute(android.R.attr.colorControlNormal, value, true);
         final int colorControl = context.getColor(value.resourceId);
-        final String usedTime = context.getString(R.string.battery_used_for);
         final int dischargeAmount = USE_FAKE_DATA ? 5000
                 : stats != null ? stats.getDischargeAmount(mStatsType) : 0;
 
         final long runningTime = calculateRunningTimeBasedOnStatsType();
         updateScreenPreference();
         updateLastFullChargePreference(runningTime);
-        mAppListGroup.setTitle(getString(R.string.power_usage_list_summary,
-                Utils.formatElapsedTime(context, runningTime, false)));
+
+        final CharSequence timeSequence = Utils.formatElapsedTime(context, runningTime, false);
+        mAppListGroup.setTitle(
+                TextUtils.expandTemplate(getText(R.string.power_usage_list_summary), timeSequence));
 
         if (averagePower >= MIN_AVERAGE_POWER_THRESHOLD_MILLI_AMP || USE_FAKE_DATA) {
             final List<BatterySipper> usageList = getCoalescedUsageList(
@@ -494,7 +498,7 @@
                     sipper.usageTimeMs = mBatteryUtils.getProcessTimeMs(
                             BatteryUtils.StatusType.FOREGROUND, sipper.uidObj, mStatsType);
                 }
-                setUsageSummary(pref, usedTime, sipper.usageTimeMs);
+                setUsageSummary(pref, sipper.usageTimeMs);
                 if ((sipper.drainType != DrainType.APP
                         || sipper.uidObj.getUid() == Process.ROOT_UID)
                         && sipper.drainType != DrainType.USER) {
@@ -531,16 +535,17 @@
     void updateScreenPreference() {
         final BatterySipper sipper = findBatterySipperByType(
                 mStatsHelper.getUsageList(), DrainType.SCREEN);
-        final Context context = getContext();
         final long usageTimeMs = sipper != null ? sipper.usageTimeMs : 0;
 
-        mScreenUsagePref.setSubtitle(Utils.formatElapsedTime(context, usageTimeMs, false));
+        mScreenUsagePref.setSubtitle(Utils.formatElapsedTime(getContext(), usageTimeMs, false));
     }
 
     @VisibleForTesting
     void updateLastFullChargePreference(long timeMs) {
-        mLastFullChargePref.setSubtitle(getString(R.string.power_last_full_charge_summary,
-                Utils.formatElapsedTime(getContext(), timeMs, false)));
+        final CharSequence timeSequence = Utils.formatElapsedTime(getContext(), timeMs, false);
+        mLastFullChargePref.setSubtitle(
+                TextUtils.expandTemplate(getText(R.string.power_last_full_charge_summary),
+                        timeSequence));
     }
 
     @VisibleForTesting
@@ -580,11 +585,13 @@
     }
 
     @VisibleForTesting
-    void setUsageSummary(Preference preference, String usedTimePrefix, long usageTimeMs) {
+    void setUsageSummary(Preference preference, long usageTimeMs) {
         // Only show summary when usage time is longer than one minute
         if (usageTimeMs >= DateUtils.MINUTE_IN_MILLIS) {
-            preference.setSummary(String.format(usedTimePrefix,
-                    Utils.formatElapsedTime(getContext(), usageTimeMs, false)));
+            final CharSequence timeSequence = Utils.formatElapsedTime(getContext(), usageTimeMs,
+                    false);
+            preference.setSummary(
+                    TextUtils.expandTemplate(getText(R.string.battery_used_for), timeSequence));
         }
     }
 
@@ -718,6 +725,16 @@
                     sir.xmlResId = R.xml.power_usage_summary;
                     return Arrays.asList(sir);
                 }
+
+                @Override
+                public List<String> getNonIndexableKeys(Context context) {
+                    List<String> niks = new ArrayList<>();
+                    // Duplicates in display
+                    niks.add(KEY_AUTO_BRIGHTNESS);
+                    niks.add(KEY_SCREEN_TIMEOUT);
+                    niks.add(KEY_BATTERY_SAVER_SUMMARY);
+                    return niks;
+                }
             };
 
     public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
diff --git a/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceController.java b/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceController.java
index b7bf3dc..5436901 100644
--- a/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceController.java
+++ b/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceController.java
@@ -20,6 +20,7 @@
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.support.v7.preference.Preference;
+import android.text.BidiFormatter;
 import android.view.inputmethod.InputMethodInfo;
 import android.view.inputmethod.InputMethodManager;
 
@@ -76,12 +77,15 @@
             return;
         }
 
+        final BidiFormatter bidiFormatter = BidiFormatter.getInstance();
+
         String summary = null;
         for (String label : labels) {
             if (summary == null) {
-                summary = label;
+                summary = bidiFormatter.unicodeWrap(label);
             } else {
-                summary = mContext.getString(R.string.join_many_items_middle, summary, label);
+                summary = mContext.getString(R.string.join_many_items_middle, summary,
+                        bidiFormatter.unicodeWrap(label));
             }
         }
         preference.setSummary(summary);
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index a87bd19..66e8c54 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -340,19 +340,13 @@
         mWifiTracker.startTracking();
 
         if (!isUiRestricted() && mWifiManager.isWifiEnabled()) {
-            forceUpdateAPs();
-        }
-    }
+            setProgressBarVisible(true);
+            mWifiTracker.forceUpdate();
+            if (DEBUG) Log.d(TAG, "WifiSettings onStart APs: " + mWifiTracker.getAccessPoints());
 
-    private void forceUpdateAPs() {
-        setProgressBarVisible(true);
-        mWifiTracker.forceUpdate();
-        if (DEBUG) {
-            Log.d(TAG, "WifiSettings force update APs: " + mWifiTracker.getAccessPoints());
+            getView().removeCallbacks(mUpdateAccessPointsRunnable);
+            updateAccessPointPreferences();
         }
-
-        getView().removeCallbacks(mUpdateAccessPointsRunnable);
-        updateAccessPointPreferences();
     }
 
     /**
@@ -667,7 +661,7 @@
         final int wifiState = mWifiManager.getWifiState();
         switch (wifiState) {
             case WifiManager.WIFI_STATE_ENABLED:
-                forceUpdateAPs();
+                updateAccessPointsDelayed();
                 break;
 
             case WifiManager.WIFI_STATE_ENABLING:
diff --git a/tests/robotests/assets/whitelist_duplicate_index_key b/tests/robotests/assets/whitelist_duplicate_index_key
new file mode 100644
index 0000000..5b5153c
--- /dev/null
+++ b/tests/robotests/assets/whitelist_duplicate_index_key
@@ -0,0 +1,12 @@
+add_users_when_locked
+additional_system_update_settings
+dashboard_tile_placeholder
+gesture_assist
+gesture_double_tap_power
+gesture_double_tap_screen
+gesture_double_twist
+gesture_pick_up
+gesture_swipe_down_fingerprint
+lock_screen_notifications
+screen_zoom
+usage_access
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/UtilsTest.java b/tests/robotests/src/com/android/settings/UtilsTest.java
index 8b7605c..8dfd32a 100644
--- a/tests/robotests/src/com/android/settings/UtilsTest.java
+++ b/tests/robotests/src/com/android/settings/UtilsTest.java
@@ -19,7 +19,10 @@
 import android.os.storage.DiskInfo;
 import android.os.storage.StorageManager;
 import android.os.storage.VolumeInfo;
+import android.text.SpannableString;
+import android.text.SpannableStringBuilder;
 import android.text.format.DateUtils;
+import android.text.style.TtsSpan;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -35,10 +38,14 @@
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public class UtilsTest {
 
+    private static final String TIME_DESCRIPTION = "1 day 20 hours 30 minutes";
     private Context mContext;
-    @Mock private WifiManager wifiManager;
-    @Mock private Network network;
-    @Mock private ConnectivityManager connectivityManager;
+    @Mock
+    private WifiManager wifiManager;
+    @Mock
+    private Network network;
+    @Mock
+    private ConnectivityManager connectivityManager;
 
     @Before
     public void setUp() {
@@ -47,7 +54,7 @@
         mContext = spy(RuntimeEnvironment.application);
         when(mContext.getSystemService(WifiManager.class)).thenReturn(wifiManager);
         when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
-            .thenReturn(connectivityManager);
+                .thenReturn(connectivityManager);
     }
 
     @Test
@@ -89,7 +96,8 @@
         final double testMillis = 5 * DateUtils.MINUTE_IN_MILLIS;
         final String expectedTime = "5m 0s";
 
-        assertThat(Utils.formatElapsedTime(mContext, testMillis, true)).isEqualTo(expectedTime);
+        assertThat(Utils.formatElapsedTime(mContext, testMillis, true).toString()).isEqualTo(
+                expectedTime);
     }
 
     @Test
@@ -97,7 +105,8 @@
         final double testMillis = 5 * DateUtils.MINUTE_IN_MILLIS;
         final String expectedTime = "5m";
 
-        assertThat(Utils.formatElapsedTime(mContext, testMillis, false)).isEqualTo(expectedTime);
+        assertThat(Utils.formatElapsedTime(mContext, testMillis, false).toString()).isEqualTo(
+                expectedTime);
     }
 
     @Test
@@ -106,7 +115,23 @@
                 + 4 * DateUtils.HOUR_IN_MILLIS + 15 * DateUtils.MINUTE_IN_MILLIS;
         final String expectedTime = "2d 4h 15m";
 
-        assertThat(Utils.formatElapsedTime(mContext, testMillis, false)).isEqualTo(expectedTime);
+        assertThat(Utils.formatElapsedTime(mContext, testMillis, false).toString()).isEqualTo(
+                expectedTime);
+    }
+
+    @Test
+    public void testFormatElapsedTime_onlyContainsMinute_hasTtsSpan() {
+        final double testMillis = 15 * DateUtils.MINUTE_IN_MILLIS;
+
+        final CharSequence charSequence = Utils.formatElapsedTime(mContext, testMillis, false);
+        assertThat(charSequence).isInstanceOf(SpannableStringBuilder.class);
+
+        final SpannableStringBuilder expectedString = (SpannableStringBuilder) charSequence;
+        final TtsSpan[] ttsSpans = expectedString.getSpans(0, expectedString.length(),
+                TtsSpan.class);
+
+        assertThat(ttsSpans).asList().hasSize(1);
+        assertThat(ttsSpans[0].getType()).isEqualTo(TtsSpan.TYPE_MEASURE);
     }
 
     @Test
@@ -119,13 +144,13 @@
     }
 
     @Test
-    public void getInstallationStatus_notInstalled_shouldReturnUninstalled() {
+    public void testGetInstallationStatus_notInstalled_shouldReturnUninstalled() {
         assertThat(Utils.getInstallationStatus(new ApplicationInfo()))
                 .isEqualTo(R.string.not_installed);
     }
 
     @Test
-    public void getInstallationStatus_enabled_shouldReturnInstalled() {
+    public void testGetInstallationStatus_enabled_shouldReturnInstalled() {
         final ApplicationInfo info = new ApplicationInfo();
         info.flags = ApplicationInfo.FLAG_INSTALLED;
         info.enabled = true;
@@ -134,7 +159,7 @@
     }
 
     @Test
-    public void getInstallationStatus_disabled_shouldReturnDisabled() {
+    public void testGetInstallationStatus_disabled_shouldReturnDisabled() {
         final ApplicationInfo info = new ApplicationInfo();
         info.flags = ApplicationInfo.FLAG_INSTALLED;
         info.enabled = false;
diff --git a/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java b/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java
index 37a7521..8b9b4b4 100644
--- a/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java
@@ -18,7 +18,6 @@
 
 
 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.eq;
@@ -172,25 +171,6 @@
     }
 
     @Test
-    public void bindButton_noStoreLink_shouldNotShowButton() {
-        final View appLinks = mLayoutInflater
-                .inflate(R.layout.app_details, null /* root */);
-        when(mContext.getPackageManager().resolveActivity(any(Intent.class), anyInt()))
-                .thenReturn(null);
-
-        mController = new AppHeaderController(mContext, mFragment, appLinks);
-        mController.setButtonActions(
-                AppHeaderController.ActionType.ACTION_STORE_DEEP_LINK,
-                AppHeaderController.ActionType.ACTION_NONE);
-        mController.done(mActivity);
-
-        assertThat(appLinks.findViewById(R.id.left_button).getVisibility())
-                .isEqualTo(View.GONE);
-        assertThat(appLinks.findViewById(R.id.right_button).getVisibility())
-                .isEqualTo(View.GONE);
-    }
-
-    @Test
     public void bindButton_noAppInfo_shouldNotShowButton() {
         final View appLinks = mLayoutInflater
                 .inflate(R.layout.app_details, null /* root */);
diff --git a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
index f372836..9c91ccf 100644
--- a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
@@ -87,6 +87,8 @@
     private BatteryStatsHelper mBatteryStatsHelper;
     @Mock
     private BatteryStats.Uid mUid;
+    @Mock
+    private PackageManager mPackageManager;
 
     private InstalledAppDetails mAppDetail;
     private Context mShadowContext;
@@ -94,14 +96,15 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mShadowContext = RuntimeEnvironment.application;
 
+        mShadowContext = RuntimeEnvironment.application;
         mAppDetail = spy(new InstalledAppDetails());
 
         mBatterySipper.drainType = BatterySipper.DrainType.IDLE;
         mBatterySipper.uidObj = mUid;
         doReturn(mActivity).when(mAppDetail).getActivity();
         doReturn(mShadowContext).when(mAppDetail).getContext();
+        doReturn(mPackageManager).when(mActivity).getPackageManager();
 
         // Default to not considering any apps to be instant (individual tests can override this).
         ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
diff --git a/tests/robotests/src/com/android/settings/applications/LayoutPreferenceTest.java b/tests/robotests/src/com/android/settings/applications/LayoutPreferenceTest.java
new file mode 100644
index 0000000..04d4342
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/LayoutPreferenceTest.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.applications;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.support.v7.preference.Preference.OnPreferenceClickListener;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class LayoutPreferenceTest {
+
+    private Context mContext;
+    private LayoutPreference mPreference;
+    private View mRootView;
+    private PreferenceViewHolder mHolder;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mPreference = new LayoutPreference(mContext, R.layout.app_action_buttons);
+        mRootView = mPreference.mRootView;
+        mHolder = PreferenceViewHolder.createInstanceForTests(LayoutInflater.from(mContext)
+                .inflate(R.layout.layout_preference_frame, null, false));
+    }
+
+    @Test
+    public void setOnClickListener_shouldAttachToRootView() {
+        final OnPreferenceClickListener listener = mock(OnPreferenceClickListener.class);
+
+        mPreference.setOnPreferenceClickListener(listener);
+        mPreference.onBindViewHolder(mHolder);
+
+        mHolder.itemView.callOnClick();
+
+        verify(listener).onPreferenceClick(mPreference);
+        assertThat(mHolder.itemView.isFocusable()).isTrue();
+        assertThat(mHolder.itemView.isClickable()).isTrue();
+    }
+
+    @Test
+    public void setNonSelectable_viewShouldNotBeSelectable() {
+        mPreference.setSelectable(false);
+        mPreference.onBindViewHolder(mHolder);
+
+        assertThat(mHolder.itemView.isFocusable()).isFalse();
+        assertThat(mHolder.itemView.isClickable()).isFalse();
+    }
+
+    @Test
+    public void disableSomeView_shouldMaintainStateAfterBind() {
+        mPreference.findViewById(R.id.left_button).setEnabled(false);
+        mPreference.findViewById(R.id.right_button).setEnabled(true);
+
+        mPreference.onBindViewHolder(mHolder);
+
+        assertThat(mPreference.findViewById(R.id.left_button).isEnabled()).isFalse();
+        assertThat(mPreference.findViewById(R.id.right_button).isEnabled()).isTrue();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java
index cc059ad..79daa0e 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java
@@ -16,7 +16,10 @@
 
 package com.android.settings.bluetooth;
 
+import static com.google.common.truth.Truth.assertThat;
+
 import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
 import android.content.Context;
 
 import com.android.settings.R;
@@ -35,29 +38,38 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowBluetoothAdapter;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
+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;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public class BluetoothSummaryUpdaterTest {
+    private static final String DEVICE_NAME = "Nightshade";
+    private static final String DEVICE_KEYBOARD_NAME = "Bluetooth Keyboard";
 
     private Context mContext;
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private LocalBluetoothManager mBluetoothManager;
     @Mock
     private LocalBluetoothAdapter mBtAdapter;
-
-    private BluetoothSummaryUpdater mSummaryUpdater;
+    @Mock
+    private BluetoothDevice mConnectedDevice;
+    @Mock
+    private BluetoothDevice mConnectedKeyBoardDevice;
     @Mock
     private SummaryListener mListener;
 
+    private BluetoothSummaryUpdater mSummaryUpdater;
+
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
@@ -84,10 +96,12 @@
 
     @Test
     public void register_true_shouldSendSummaryChange() {
+        prepareConnectedDevice(false);
+
         mSummaryUpdater.register(true);
 
         verify(mListener).onSummaryChanged(
-            mContext.getString(R.string.bluetooth_connected_summary));
+                mContext.getString(R.string.bluetooth_connected_summary, DEVICE_NAME));
     }
 
     @Test
@@ -100,11 +114,13 @@
 
     @Test
     public void onBluetoothStateChanged_btEnabled_connected_shouldSendConnectedSummary() {
+        prepareConnectedDevice(false);
+
         mSummaryUpdater.register(true);
         mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_ON);
 
         verify(mListener).onSummaryChanged(
-            mContext.getString(R.string.bluetooth_connected_summary));
+                mContext.getString(R.string.bluetooth_connected_summary, DEVICE_NAME));
     }
 
     @Test
@@ -114,7 +130,7 @@
         mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_TURNING_ON);
 
         verify(mListener).onSummaryChanged(
-            mContext.getString(R.string.disconnected));
+                mContext.getString(R.string.disconnected));
     }
 
     @Test
@@ -123,26 +139,28 @@
         devices.add(mock(CachedBluetoothDevice.class));
         when(devices.get(0).isConnected()).thenReturn(true);
         when(mBluetoothManager.getCachedDeviceManager().getCachedDevicesCopy())
-            .thenReturn(devices);
+                .thenReturn(devices);
         when(mBtAdapter.getConnectionState()).thenReturn(BluetoothAdapter.STATE_DISCONNECTED);
+        prepareConnectedDevice(false);
+
         mSummaryUpdater.register(true);
 
         when(mBtAdapter.getConnectionState()).thenReturn(BluetoothAdapter.STATE_CONNECTED);
         mSummaryUpdater.onConnectionStateChanged(null /* device */,
-            BluetoothAdapter.STATE_CONNECTED);
+                BluetoothAdapter.STATE_CONNECTED);
 
         verify(mListener).onSummaryChanged(
-            mContext.getString(R.string.bluetooth_connected_summary));
+                mContext.getString(R.string.bluetooth_connected_summary, DEVICE_NAME));
     }
 
     @Test
     public void onConnectionStateChanged_inconsistentState_shouldSendDisconnectedMessage() {
         mSummaryUpdater.register(true);
         mSummaryUpdater.onConnectionStateChanged(null /* device */,
-            BluetoothAdapter.STATE_CONNECTED);
+                BluetoothAdapter.STATE_CONNECTED);
 
         verify(mListener).onSummaryChanged(
-            mContext.getString(R.string.disconnected));
+                mContext.getString(R.string.disconnected));
     }
 
     @Test
@@ -150,7 +168,7 @@
         mSummaryUpdater.register(true);
         when(mBtAdapter.getConnectionState()).thenReturn(BluetoothAdapter.STATE_CONNECTING);
         mSummaryUpdater.onConnectionStateChanged(null /* device */,
-            BluetoothAdapter.STATE_CONNECTING);
+                BluetoothAdapter.STATE_CONNECTING);
 
         verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_connecting));
     }
@@ -160,11 +178,44 @@
         mSummaryUpdater.register(true);
         when(mBtAdapter.getConnectionState()).thenReturn(BluetoothAdapter.STATE_DISCONNECTING);
         mSummaryUpdater.onConnectionStateChanged(null /* device */,
-            BluetoothAdapter.STATE_DISCONNECTING);
+                BluetoothAdapter.STATE_DISCONNECTING);
 
         verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_disconnecting));
     }
 
+    @Test
+    public void getConnectedDeviceSummary_hasConnectedDevice_returnOneDeviceSummary() {
+        prepareConnectedDevice(false);
+        final String expectedSummary = mContext.getString(R.string.bluetooth_connected_summary,
+                DEVICE_NAME);
+
+        assertThat(mSummaryUpdater.getConnectedDeviceSummary()).isEqualTo(expectedSummary);
+    }
+
+    @Test
+    public void getConnectedDeviceSummary_multipleDevices_returnMultipleDevicesSummary() {
+        prepareConnectedDevice(true);
+        final String expectedSummary = mContext.getString(
+                R.string.bluetooth_connected_multiple_devices_summary);
+
+        assertThat(mSummaryUpdater.getConnectedDeviceSummary()).isEqualTo(expectedSummary);
+    }
+
+    private void prepareConnectedDevice(boolean multipleDevices) {
+        final Set<BluetoothDevice> devices = new HashSet<>();
+        doReturn(DEVICE_NAME).when(mConnectedDevice).getName();
+        doReturn(true).when(mConnectedDevice).isConnected();
+        devices.add(mConnectedDevice);
+        if (multipleDevices) {
+            // Add one more device if we need to test multiple devices
+            doReturn(DEVICE_KEYBOARD_NAME).when(mConnectedKeyBoardDevice).getName();
+            doReturn(true).when(mConnectedKeyBoardDevice).isConnected();
+            devices.add(mConnectedKeyBoardDevice);
+        }
+
+        doReturn(devices).when(mBtAdapter).getBondedDevices();
+    }
+
     private class SummaryListener implements OnSummaryChangeListener {
         String summary;
 
diff --git a/tests/robotests/src/com/android/settings/core/codeinspection/CodeInspector.java b/tests/robotests/src/com/android/settings/core/codeinspection/CodeInspector.java
index 86c14a5..2f786f8 100644
--- a/tests/robotests/src/com/android/settings/core/codeinspection/CodeInspector.java
+++ b/tests/robotests/src/com/android/settings/core/codeinspection/CodeInspector.java
@@ -70,7 +70,7 @@
         return true;
     }
 
-    protected void initializeGrandfatherList(List<String> grandfather, String filename) {
+    public static void initializeGrandfatherList(List<String> grandfather, String filename) {
         try {
             final InputStream in = ShadowApplication.getInstance().getApplicationContext()
                     .getAssets()
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionsChecksTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionsChecksTest.java
new file mode 100644
index 0000000..72231b2
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionsChecksTest.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2017 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.dashboard.suggestions;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.when;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.hardware.fingerprint.FingerprintManager;
+
+import com.android.settings.Settings;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settingslib.drawer.Tile;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class SuggestionsChecksTest {
+
+    @Mock
+    private Context mContext;
+    @Mock
+    private PackageManager mPackageManager;
+    @Mock
+    private FingerprintManager mFingerprintManager;
+    @Mock
+    private DevicePolicyManager mDevicePolicyManager;
+
+    private SuggestionsChecks mSuggestionsChecks;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        when(mContext.getApplicationContext()).thenReturn(mContext);
+        mSuggestionsChecks = new SuggestionsChecks(mContext);
+        when(mContext.getPackageManager()).thenReturn(mPackageManager);
+        when(mContext.getSystemService(eq(Context.DEVICE_POLICY_SERVICE)))
+                .thenReturn(mDevicePolicyManager);
+        when(mDevicePolicyManager.getKeyguardDisabledFeatures(any(), anyInt()))
+                .thenReturn(0);
+        when(mContext.getSystemService(FingerprintManager.class)).thenReturn(mFingerprintManager);
+    }
+
+    @Test
+    public void testFingerprintEnrollmentIntroductionIsCompleteWhenFingerprintAdded() {
+        stubFingerprintSupported(true);
+        when(mFingerprintManager.hasEnrolledFingerprints()).thenReturn(true);
+        Tile tile = createFingerprintTile();
+        assertThat(mSuggestionsChecks.isSuggestionComplete(tile)).isTrue();
+    }
+
+    @Test
+    public void testFingerprintEnrollmentIntroductionIsNotCompleteWhenNoFingerprintAdded() {
+        stubFingerprintSupported(true);
+        when(mFingerprintManager.hasEnrolledFingerprints()).thenReturn(false);
+        Tile tile = createFingerprintTile();
+        assertThat(mSuggestionsChecks.isSuggestionComplete(tile)).isFalse();
+    }
+
+
+    @Test
+    public void testFingerprintEnrollmentIntroductionIsCompleteWhenFingerprintNotSupported() {
+        stubFingerprintSupported(false);
+        Tile tile = createFingerprintTile();
+        assertThat(mSuggestionsChecks.isSuggestionComplete(tile)).isTrue();
+    }
+
+    @Test
+    public void testFingerprintEnrollmentIntroductionIsCompleteWhenFingerprintDisabled() {
+        stubFingerprintSupported(true);
+        when(mFingerprintManager.hasEnrolledFingerprints()).thenReturn(false);
+        when(mDevicePolicyManager.getKeyguardDisabledFeatures(any(), anyInt()))
+                .thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT);
+
+        Tile tile = createFingerprintTile();
+        assertThat(mSuggestionsChecks.isSuggestionComplete(tile)).isTrue();
+    }
+
+    private void stubFingerprintSupported(boolean enabled) {
+        when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
+                .thenReturn(enabled);
+    }
+
+    private Tile createFingerprintTile() {
+        Tile tile = new Tile();
+        tile.intent = new Intent();
+        tile.intent.setComponent(new ComponentName(mContext,
+                Settings.FingerprintEnrollSuggestionActivity.class));
+        return tile;
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
index 2231c22..47d910d 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
@@ -114,6 +114,7 @@
         Intent intent = argumentCaptor.getValue();
         assertThat(intent.getType()).isEqualTo("image/*");
         assertThat(intent.getAction()).isEqualTo(android.content.Intent.ACTION_VIEW);
+        assertThat(intent.getBooleanExtra(Intent.EXTRA_FROM_STORAGE, false)).isTrue();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java
index cc9b6d0..6d8696f 100644
--- a/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java
@@ -43,12 +43,13 @@
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private Context mContext;
     private AutoBrightnessPreferenceController mController;
+    private final String PREFERENCE_KEY = "auto_brightness";
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
-        mController = new AutoBrightnessPreferenceController(mContext);
+        mController = new AutoBrightnessPreferenceController(mContext, PREFERENCE_KEY);
     }
 
     @Test
@@ -72,7 +73,7 @@
     @Test
     public void testPreferenceController_ProperResultPayloadType() {
         final Context context = ShadowApplication.getInstance().getApplicationContext();
-        mController = new AutoBrightnessPreferenceController(context);
+        mController = new AutoBrightnessPreferenceController(context, PREFERENCE_KEY);
         ResultPayload payload = mController.getResultPayload();
         assertThat(payload).isInstanceOf(InlineSwitchPayload.class);
     }
@@ -80,7 +81,7 @@
     @Test
     public void testPreferenceController_CorrectPayload() {
         final Context context = ShadowApplication.getInstance().getApplicationContext();
-        mController = new AutoBrightnessPreferenceController(context);
+        mController = new AutoBrightnessPreferenceController(context, PREFERENCE_KEY);
         InlineSwitchPayload payload = (InlineSwitchPayload) mController.getResultPayload();
         assertThat(payload.settingsUri).isEqualTo("screen_brightness_mode");
         assertThat(payload.settingSource).isEqualTo(ResultPayload.SettingsSource.SYSTEM);
diff --git a/tests/robotests/src/com/android/settings/display/TimeoutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/TimeoutPreferenceControllerTest.java
index ec142c2..2ebad46 100644
--- a/tests/robotests/src/com/android/settings/display/TimeoutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/TimeoutPreferenceControllerTest.java
@@ -42,11 +42,13 @@
     private TimeoutListPreference mPreference;
     private TimeoutPreferenceController mController;
 
+    private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
+
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
-        mController = new TimeoutPreferenceController(mContext);
+        mController = new TimeoutPreferenceController(mContext, KEY_SCREEN_TIMEOUT);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
index 801034c..4305dc7 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
@@ -57,6 +57,8 @@
 import org.mockito.MockitoAnnotations;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
+import org.robolectric.RuntimeEnvironment;
+
 import org.robolectric.annotation.Config;
 import org.robolectric.util.ReflectionHelpers;
 
@@ -73,6 +75,8 @@
     private static final long FOREGROUND_TIME_US = 200 * 1000;
     private static final long BACKGROUND_TIME_MS = 100;
     private static final long FOREGROUND_TIME_MS = 200;
+    private static final long PHONE_FOREGROUND_TIME_MS = 250 * 1000;
+    private static final long PHONE_BACKGROUND_TIME_MS = 0;
 
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private Context mContext;
@@ -137,9 +141,11 @@
         ReflectionHelpers.setField(mBatteryEntry, "sipper", mBatterySipper);
         mBatteryEntry.iconId = ICON_ID;
         mBatterySipper.uidObj = mUid;
+        mBatterySipper.drainType = BatterySipper.DrainType.APP;
 
         mFragment.mHeaderPreference = mHeaderPreference;
         mFragment.mState = mState;
+        mFragment.mBatteryUtils = new BatteryUtils(RuntimeEnvironment.application);
         mAppEntry.info = mock(ApplicationInfo.class);
 
         mTestActivity = spy(new SettingsActivity());
@@ -191,6 +197,23 @@
     }
 
     @Test
+    public void testStartBatteryDetailPage_typeNotApp_hasBasicData() {
+        mBatterySipper.drainType = BatterySipper.DrainType.PHONE;
+        mBatterySipper.usageTimeMs = PHONE_FOREGROUND_TIME_MS;
+
+        AdvancedPowerUsageDetail.startBatteryDetailPage(mTestActivity, null, mBatteryStatsHelper, 0,
+                mBatteryEntry, USAGE_PERCENT);
+
+        assertThat(mBundle.getInt(AdvancedPowerUsageDetail.EXTRA_UID)).isEqualTo(UID);
+        assertThat(mBundle.getLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME)).isEqualTo(
+                PHONE_FOREGROUND_TIME_MS);
+        assertThat(mBundle.getLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME)).isEqualTo(
+                PHONE_BACKGROUND_TIME_MS);
+        assertThat(mBundle.getString(AdvancedPowerUsageDetail.EXTRA_POWER_USAGE_PERCENT)).isEqualTo(
+                USAGE_PERCENT);
+    }
+
+    @Test
     public void testStartBatteryDetailPage_NormalApp() {
         mBatterySipper.mPackages = PACKAGE_NAME;
         AdvancedPowerUsageDetail.startBatteryDetailPage(mTestActivity, null, mBatteryStatsHelper, 0,
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
index e5383c8..52cfe4c 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
@@ -33,6 +33,9 @@
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import static android.os.BatteryStats.Uid.PROCESS_STATE_BACKGROUND;
 import static android.os.BatteryStats.Uid.PROCESS_STATE_FOREGROUND;
 import static android.os.BatteryStats.Uid.PROCESS_STATE_FOREGROUND_SERVICE;
@@ -47,9 +50,7 @@
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.List;
+import static org.mockito.Mockito.spy;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@@ -127,6 +128,8 @@
 
         mBatteryUtils = BatteryUtils.getInstance(RuntimeEnvironment.application);
         mBatteryUtils.mPowerUsageFeatureProvider = mProvider;
+
+        mBatteryUtils = spy(new BatteryUtils(RuntimeEnvironment.application));
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
index 66d2c1a..7a1284a 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
@@ -18,6 +18,7 @@
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.os.UserManager;
+import android.text.TextUtils;
 
 import com.android.internal.os.BatterySipper;
 import com.android.internal.os.BatterySipper.DrainType;
@@ -105,9 +106,12 @@
         when(mPowerUsageAdvanced.getContext()).thenReturn(mShadowContext);
         doReturn(STUB_STRING).when(mPowerUsageAdvanced).getString(anyInt(), any(), any());
         doReturn(STUB_STRING).when(mPowerUsageAdvanced).getString(anyInt(), any());
+        doReturn(mShadowContext.getText(R.string.battery_used_for)).when(
+                mPowerUsageAdvanced).getText(R.string.battery_used_for);
         mPowerUsageAdvanced.setPackageManager(mPackageManager);
         mPowerUsageAdvanced.setPowerUsageFeatureProvider(mPowerUsageFeatureProvider);
         mPowerUsageAdvanced.setUserManager(mUserManager);
+        mPowerUsageAdvanced.mBatteryUtils = spy(new BatteryUtils(mShadowContext));
 
         mPowerUsageData = new PowerUsageData(UsageType.APP);
         mMaxBatterySipper.totalPowerMah = TYPE_BLUETOOTH_USAGE;
@@ -140,13 +144,13 @@
     }
 
     @Test
-    public void testExtractUsageType_TypeService_ReturnService() {
+    public void testExtractUsageType_TypeService_ReturnSystem() {
         mNormalBatterySipper.drainType = DrainType.APP;
         when(mNormalBatterySipper.getUid()).thenReturn(FAKE_UID_1);
         when(mPowerUsageFeatureProvider.isTypeService(any())).thenReturn(true);
 
         assertThat(mPowerUsageAdvanced.extractUsageType(mNormalBatterySipper))
-                .isEqualTo(UsageType.SERVICE);
+                .isEqualTo(UsageType.SYSTEM);
     }
 
     @Test
@@ -176,10 +180,12 @@
 
     @Test
     public void testUpdateUsageDataSummary_onlyOneApp_showUsageTime() {
+        final String expectedSummary = "Used for 0m";
         mPowerUsageData.usageList.add(mNormalBatterySipper);
+
         mPowerUsageAdvanced.updateUsageDataSummary(mPowerUsageData, TOTAL_POWER, DISCHARGE_AMOUNT);
 
-        verify(mPowerUsageAdvanced).getString(eq(R.string.battery_used_for), any());
+        assertThat(mPowerUsageData.summary.toString()).isEqualTo(expectedSummary);
     }
 
     @Test
@@ -210,8 +216,8 @@
         final int[] usageTypeSet = mPowerUsageAdvanced.mUsageTypes;
 
         assertThat(usageTypeSet).asList().containsExactly(UsageType.APP, UsageType.WIFI,
-                UsageType.CELL, UsageType.BLUETOOTH, UsageType.IDLE, UsageType.SERVICE,
-                UsageType.USER, UsageType.SYSTEM, UsageType.UNACCOUNTED, UsageType.OVERCOUNTED);
+                UsageType.CELL, UsageType.BLUETOOTH, UsageType.IDLE, UsageType.USER,
+                UsageType.SYSTEM, UsageType.UNACCOUNTED, UsageType.OVERCOUNTED);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
index 39c386b..5cb60d2 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
@@ -36,9 +36,11 @@
 import com.android.settings.TestConfig;
 import com.android.settings.Utils;
 import com.android.settings.applications.LayoutPreference;
+import com.android.settings.core.PreferenceController;
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.shadow.SettingsShadowResources;
 import com.android.settings.testutils.shadow.ShadowDynamicIndexableContentMonitor;
+import com.android.settings.testutils.XmlTestUtils;
 import com.android.settingslib.BatteryInfo;
 
 import org.junit.Before;
@@ -86,15 +88,16 @@
 public class PowerUsageSummaryTest {
     private static final String[] PACKAGE_NAMES = {"com.app1", "com.app2"};
     private static final String TIME_LEFT = "2h30min";
+    private static final String STUB_STRING = "stub_string";
     private static final int BATTERY_LEVEL = 55;
     private static final int UID = 123;
     private static final int POWER_MAH = 100;
     private static final long REMAINING_TIME_US = 100000;
-    private static final long TIME_SINCE_LAST_FULL_CHARGE_MS = 25000;
+    private static final long TIME_SINCE_LAST_FULL_CHARGE_MS = 120 * 60 * 1000;
     private static final long TIME_SINCE_LAST_FULL_CHARGE_US =
             TIME_SINCE_LAST_FULL_CHARGE_MS * 1000;
     private static final int DISCHARGE_AMOUNT = 100;
-    private static final long USAGE_TIME_MS = 10000;
+    private static final long USAGE_TIME_MS = 65 * 60 * 1000;
     private static final double TOTAL_POWER = 200;
     private static final double BATTERY_SCREEN_USAGE = 300;
     private static final double BATTERY_SYSTEM_USAGE = 600;
@@ -123,8 +126,6 @@
     @Mock
     private BatterySipper mCellBatterySipper;
     @Mock
-    private PowerGaugePreference mPreference;
-    @Mock
     private LayoutPreference mBatteryLayoutPref;
     @Mock
     private TextView mBatteryPercentText;
@@ -132,10 +133,6 @@
     private TextView mSummary1;
     @Mock
     private BatteryInfo mBatteryInfo;
-    @Mock
-    private PowerGaugePreference mScreenUsagePref;
-    @Mock
-    private PowerGaugePreference mLastFullChargePref;
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private BatteryStatsHelper mBatteryHelper;
     @Mock
@@ -148,6 +145,9 @@
     private TestFragment mFragment;
     private FakeFeatureFactory mFeatureFactory;
     private BatteryMeterView mBatteryMeterView;
+    private PowerGaugePreference mPreference;
+    private PowerGaugePreference mScreenUsagePref;
+    private PowerGaugePreference mLastFullChargePref;
 
     @Before
     public void setUp() {
@@ -158,6 +158,9 @@
         mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
         when(mContext.getSystemService(Context.POWER_SERVICE)).thenReturn(mPowerManager);
 
+        mPreference = new PowerGaugePreference(mRealContext);
+        mScreenUsagePref = new PowerGaugePreference(mRealContext);
+        mLastFullChargePref = new PowerGaugePreference(mRealContext);
         mFragment = spy(new TestFragment(mContext));
         mFragment.initFeatureProvider();
         mBatteryMeterView = new BatteryMeterView(mRealContext);
@@ -200,6 +203,7 @@
         when(mBatteryHelper.getUsageList()).thenReturn(mUsageList);
         mFragment.mScreenUsagePref = mScreenUsagePref;
         mFragment.mLastFullChargePref = mLastFullChargePref;
+        mFragment.mBatteryUtils = spy(new BatteryUtils(mRealContext));
 
         mBatteryInfo.batteryLevel = BATTERY_LEVEL;
     }
@@ -304,16 +308,21 @@
     public void testSetUsageSummary_timeLessThanOneMinute_DoNotSetSummary() {
         final long usageTimeMs = 59 * DateUtils.SECOND_IN_MILLIS;
 
-        mFragment.setUsageSummary(mPreference, "", usageTimeMs);
-        verify(mPreference, never()).setSummary(anyString());
+        mFragment.setUsageSummary(mPreference, usageTimeMs);
+        assertThat(mPreference.getSummary()).isNull();
     }
 
     @Test
     public void testSetUsageSummary_timeMoreThanOneMinute_setSummary() {
         final long usageTimeMs = 2 * DateUtils.MINUTE_IN_MILLIS;
+        doReturn(mRealContext.getText(R.string.battery_used_for)).when(mFragment).getText(
+                R.string.battery_used_for);
+        doReturn(mRealContext).when(mFragment).getContext();
+        final String expectedSummary = "Used for 2m";
 
-        mFragment.setUsageSummary(mPreference, "", usageTimeMs);
-        verify(mPreference).setSummary(anyString());
+        mFragment.setUsageSummary(mPreference, usageTimeMs);
+
+        assertThat(mPreference.getSummary().toString()).isEqualTo(expectedSummary);
     }
 
     @Test
@@ -380,32 +389,37 @@
 
     @Test
     public void testUpdateScreenPreference_showCorrectSummary() {
-        final String expectedUsedTime = Utils.formatElapsedTime(mRealContext, USAGE_TIME_MS, false);
         doReturn(mScreenBatterySipper).when(mFragment).findBatterySipperByType(any(), any());
         doReturn(mRealContext).when(mFragment).getContext();
+        final CharSequence expectedSummary = Utils.formatElapsedTime(mRealContext, USAGE_TIME_MS,
+                false);
 
         mFragment.updateScreenPreference();
 
-        verify(mScreenUsagePref).setSubtitle(expectedUsedTime);
+        assertThat(mScreenUsagePref.getSubtitle()).isEqualTo(expectedSummary);
     }
 
     @Test
     public void testUpdateLastFullChargePreference_showCorrectSummary() {
+        final CharSequence formattedString = mRealContext.getText(
+                R.string.power_last_full_charge_summary);
+        final CharSequence timeSequence = Utils.formatElapsedTime(mRealContext,
+                TIME_SINCE_LAST_FULL_CHARGE_MS, false);
+        final CharSequence expectedSummary = TextUtils.expandTemplate(
+                formattedString, timeSequence);
+        doReturn(formattedString).when(mFragment).getText(R.string.power_last_full_charge_summary);
         doReturn(mRealContext).when(mFragment).getContext();
-        final String expected = mRealContext.getString(R.string.power_last_full_charge_summary,
-                Utils.formatElapsedTime(mRealContext, TIME_SINCE_LAST_FULL_CHARGE_MS, false));
-        doReturn(expected).when(mFragment).getString(eq(R.string.power_last_full_charge_summary),
-                any());
 
         mFragment.updateLastFullChargePreference(TIME_SINCE_LAST_FULL_CHARGE_MS);
 
-        verify(mLastFullChargePref).setSubtitle(expected);
+        assertThat(mLastFullChargePref.getSubtitle()).isEqualTo(expectedSummary);
     }
 
     @Test
     public void testUpdatePreference_usageListEmpty_shouldNotCrash() {
         when(mBatteryHelper.getUsageList()).thenReturn(new ArrayList<BatterySipper>());
-        doReturn("").when(mFragment).getString(anyInt(), any());
+        doReturn(STUB_STRING).when(mFragment).getString(anyInt(), any());
+        doReturn(mRealContext).when(mFragment).getContext();
 
         // Should not crash when update
         mFragment.updateScreenPreference();
@@ -423,6 +437,33 @@
                 TIME_SINCE_LAST_FULL_CHARGE_MS);
     }
 
+    @Test
+    public void testNonIndexableKeys_MatchPreferenceKeys() {
+        final Context context = RuntimeEnvironment.application;
+        final List<String> niks = PowerUsageSummary.SEARCH_INDEX_DATA_PROVIDER
+                .getNonIndexableKeys(context);
+
+        final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context,
+                R.xml.power_usage_summary);
+
+        assertThat(keys).containsAllIn(niks);
+    }
+
+    @Test
+    public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
+        final Context context = RuntimeEnvironment.application;
+        final PowerUsageSummary fragment = new PowerUsageSummary();
+        final List<String> preferenceScreenKeys = XmlTestUtils.getKeysFromPreferenceXml(context,
+                fragment.getPreferenceScreenResId());
+        final List<String> preferenceKeys = new ArrayList<>();
+
+        for (PreferenceController controller : fragment.getPreferenceControllers(context)) {
+            preferenceKeys.add(controller.getPreferenceKey());
+        }
+
+        assertThat(preferenceScreenKeys).containsAllIn(preferenceKeys);
+    }
+
     public static class TestFragment extends PowerUsageSummary {
 
         private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceControllerTest.java
index 3256950..1332445 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceControllerTest.java
@@ -18,6 +18,8 @@
 
 
 import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -26,6 +28,7 @@
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.pm.PackageManager;
+import android.support.v4.text.BidiFormatter;
 import android.support.v7.preference.Preference;
 import android.view.inputmethod.InputMethodInfo;
 import android.view.inputmethod.InputMethodManager;
@@ -39,6 +42,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 
 import java.util.ArrayList;
@@ -96,4 +100,35 @@
 
         verify(mPreference).setSummary("label");
     }
+
+    @Test
+    public void updateState_multiImeWithMixedLocale_setImeLabelToSummary() {
+        final BidiFormatter formatter = BidiFormatter.getInstance();
+        final ComponentName componentName = new ComponentName("pkg", "cls");
+        final List<InputMethodInfo> imis = new ArrayList<>();
+        final String label1 = "label";
+        final String label2 = "Keyboard מִקְלֶדֶת";
+        imis.add(mock(InputMethodInfo.class));
+        imis.add(mock(InputMethodInfo.class));
+
+        when(mDpm.getPermittedInputMethodsForCurrentUser()).thenReturn(null);
+        when(mImm.getEnabledInputMethodList()).thenReturn(imis);
+        when(imis.get(0).getPackageName()).thenReturn(componentName.getPackageName());
+        when(imis.get(0).loadLabel(mPm)).thenReturn(label1);
+        when(imis.get(1).getPackageName()).thenReturn(componentName.getPackageName());
+        when(imis.get(1).loadLabel(mPm)).thenReturn(label2);
+        when(mContext.getString(eq(R.string.join_many_items_middle), anyString(), anyString()))
+                .thenAnswer(invocation -> {
+                    final Object[] args = invocation.getArguments();
+                    final String str1 = (String) args[1];
+                    final String str2 = (String) args[2];
+                    return RuntimeEnvironment.application.getString(R.string.join_many_items_middle,
+                            str1, str2);
+                });
+
+        mController.updateState(mPreference);
+
+        verify(mPreference).setSummary(
+                formatter.unicodeWrap(label1) + ", " + formatter.unicodeWrap(label2));
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/search/DataIntegrityTest.java b/tests/robotests/src/com/android/settings/search/DataIntegrityTest.java
new file mode 100644
index 0000000..f10752a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/search/DataIntegrityTest.java
@@ -0,0 +1,123 @@
+package com.android.settings.search;
+
+import android.content.Context;
+import android.provider.SearchIndexableResource;
+import android.util.ArraySet;
+import com.android.settings.DateTimeSettings;
+import com.android.settings.R;
+import com.android.settings.SecuritySettings;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.core.codeinspection.CodeInspector;
+import com.android.settings.datausage.DataUsageSummary;
+import com.android.settings.search2.DatabaseIndexingUtils;
+import com.android.settings.testutils.XmlTestUtils;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import static com.google.common.truth.Truth.assertThat;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+        assetDir = "/tests/robotests/assets")
+public class DataIntegrityTest {
+
+    @Test
+    @Config(shadows = {
+            SettingsShadowResources.class,
+            SettingsShadowResources.SettingsShadowTheme.class,
+    })
+    public void testIndexableResources_uniqueKeys() {
+        final Context context = RuntimeEnvironment.application;
+        // Aggregation of all keys
+        final Set<String> masterKeys = new ArraySet<>();
+        // Aggregation of the incorrectly duplicate keys
+        final Set<String> duplicateKeys = new ArraySet<>();
+        // Keys for a specific page
+        final Set<String> pageKeys = new ArraySet<>();
+        // List of all Xml preferences
+        final Set<Integer> xmlList = new ArraySet<>();
+        // Duplicates we know about.
+        List<String> grandfatheredKeys = new ArrayList<>();
+        CodeInspector.initializeGrandfatherList(grandfatheredKeys,
+                "whitelist_duplicate_index_key");
+
+        // Get a list of all Xml.
+        for (SearchIndexableResource val : SearchIndexableResources.values()) {
+            final int xmlResId = val.xmlResId;
+            if (xmlResId != 0) {
+                xmlList.add(xmlResId);
+            } else {
+                // Take class and get all keys
+                final Class clazz = DatabaseIndexingUtils.getIndexableClass(val.className);
+
+                // Skip classes that are invalid or cannot be mocked. Add them as special Xml below.
+                if (clazz == null
+                        || clazz == DateTimeSettings.class
+                        || clazz == DataUsageSummary.class
+                        || clazz == SecuritySettings.class) {
+                    continue;
+                }
+
+                Indexable.SearchIndexProvider provider = DatabaseIndexingUtils
+                        .getSearchIndexProvider(clazz);
+
+                if (provider == null) {
+                    continue;
+                }
+
+                List<SearchIndexableResource> subXml =
+                        provider.getXmlResourcesToIndex(context, true);
+
+                if (subXml == null) {
+                    continue;
+                }
+                for (SearchIndexableResource resource : subXml) {
+                    final int subXmlResId = resource.xmlResId;
+                    if (subXmlResId != 0) {
+                        xmlList.add(subXmlResId);
+                    }
+                }
+            }
+        }
+        addSpecialXml(xmlList);
+
+        // Get keys from all Xml and check for duplicates.
+        for (Integer xmlResId : xmlList) {
+            // Get all keys to be indexed
+            final List<String> prefKeys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlResId);
+
+            pageKeys.addAll(prefKeys);
+            // Remove grandfathered keys.
+            pageKeys.removeAll(grandfatheredKeys);
+            // Find all already-existing keys.
+            pageKeys.retainAll(masterKeys);
+            // Keep list of offending duplicate keys.
+            duplicateKeys.addAll(pageKeys);
+            // Add all keys to master key list.
+            masterKeys.addAll(prefKeys);
+            pageKeys.clear();
+        }
+        assertThat(duplicateKeys).isEmpty();
+    }
+
+    /**
+     * Add XML preferences from Fragments which have issues being instantiated in robolectric.
+     */
+    private void addSpecialXml(Set<Integer> xmlList) {
+        xmlList.add(R.xml.date_time_prefs);
+        xmlList.add(R.xml.data_usage);
+        xmlList.add(R.xml.data_usage_cellular);
+        xmlList.add(R.xml.data_usage_wifi);
+        xmlList.add(R.xml.security_settings_misc);
+    }
+
+
+}
diff --git a/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java b/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java
index 012d616..89afcaa 100644
--- a/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java
+++ b/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java
@@ -19,9 +19,7 @@
 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE;
 import static com.android.settings.search.SearchIndexableResources.NO_DATA_RES_ID;
 
-import static com.android.settings.search.SearchIndexableResources.sResMap;
 import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
 
 import android.annotation.DrawableRes;
@@ -35,12 +33,14 @@
 import com.android.settings.TestConfig;
 import com.android.settings.wifi.WifiSettings;
 
+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 java.util.HashMap;
+import java.util.Map;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@@ -51,6 +51,21 @@
     @DrawableRes
     private static final int ICON_RES_ID = R.drawable.ic_settings_language;
 
+    Map<String, SearchIndexableResource> sResMapCopy;
+
+    @Before
+    public void setUp() {
+        sResMapCopy = new HashMap<>(SearchIndexableResources.sResMap);
+    }
+
+    @After
+    public void cleanUp() {
+        SearchIndexableResources.sResMap.clear();
+        for (String key : sResMapCopy.keySet()) {
+            SearchIndexableResources.sResMap.put(key, sResMapCopy.get(key));
+        }
+    }
+
     @Test
     public void testAddIndex() {
         // Confirms that String.class isn't contained in SearchIndexableResources.
diff --git a/tests/robotests/src/com/android/settings/testutils/XmlTestUtils.java b/tests/robotests/src/com/android/settings/testutils/XmlTestUtils.java
new file mode 100644
index 0000000..20b3f89
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/XmlTestUtils.java
@@ -0,0 +1,57 @@
+package com.android.settings.testutils;
+
+import android.content.res.Resources;
+import android.content.res.XmlResourceParser;
+
+import android.content.Context;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.util.Xml;
+import com.android.settings.search2.XmlParserUtils;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Util class for parsing XML
+ */
+public class XmlTestUtils {
+
+    /**
+     * Parses a preference screen's xml, collects and returns all keys used by preferences
+     * on the screen.
+     *
+     * @param context of the preference screen.
+     * @param xmlId of the Preference Xml to be parsed.
+     * @return List of all keys in the preference Xml
+     */
+    public static List<String> getKeysFromPreferenceXml(Context context, int xmlId) {
+        final XmlResourceParser parser = context.getResources().getXml(xmlId);
+        final AttributeSet attrs = Xml.asAttributeSet(parser);
+        final List<String> keys = new ArrayList<>();
+        String key;
+        try {
+            while (parser.next() != XmlPullParser.END_DOCUMENT) {
+                try {
+                    key = XmlParserUtils.getDataKey(context, attrs);
+                    if (!TextUtils.isEmpty(key)) {
+                        keys.add(key);
+                    }
+                } catch (NullPointerException e) {
+                    continue;
+                } catch (Resources.NotFoundException e) {
+                    continue;
+                }
+            }
+        } catch (java.io.IOException e) {
+            return null;
+        } catch (XmlPullParserException e) {
+            return null;
+        }
+
+        return keys;
+    }
+
+}