Merge "Update settings tests to use new constructor."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 10b91cb..10c0bc2 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -272,7 +272,7 @@
                 android:configChanges="orientation|keyboardHidden|screenSize"
                 android:parentActivityName="Settings$WifiSettingsActivity">
             <intent-filter android:priority="1">
-                <action android:name="android.settings.CONFIGURE_WIFI_SETTINGS" />
+                <action android:name="android.settings.WIFI_IP_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter>
@@ -692,7 +692,7 @@
 
         <activity android:name=".inputmethod.UserDictionaryAddWordActivity"
                   android:label="@string/user_dict_settings_title"
-                  android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.NoActionBar"
+                  android:theme="@*android:style/Theme.DeviceDefault.Settings.Dialog.NoActionBar"
                   android:windowSoftInputMode="stateVisible"
                   android:noHistory="true"
                   android:excludeFromRecents="true">
@@ -727,6 +727,14 @@
                 <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
+            <intent-filter android:priority="1">
+                <action android:name="android.settings.ZEN_MODE_AUTOMATION_SETTINGS" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <intent-filter android:priority="1">
+                <action android:name="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.notification.ZenModeSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -759,25 +767,6 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$ZenModeAutomationSettingsActivity"
-                android:label="@string/zen_mode_automation_settings_title"
-                android:icon="@drawable/ic_settings_notifications"
-                android:exported="true"
-                android:taskAffinity="">
-            <intent-filter android:priority="1">
-                <action android:name="android.settings.ZEN_MODE_AUTOMATION_SETTINGS" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-            <intent-filter android:priority="1">
-                <action android:name="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                android:value="com.android.settings.notification.ZenModeAutomationSettings" />
-            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
-                android:value="true" />
-        </activity>
-
         <activity android:name="Settings$ZenModeAutomationSuggestionActivity"
                 android:label="@string/zen_mode_automation_settings_title"
                 android:icon="@drawable/ic_settings_notifications"
@@ -943,8 +932,6 @@
                 android:value="com.android.settings.category.ia.system" />
             <meta-data android:name="com.android.settings.title"
                 android:resource="@string/about_settings" />
-            <meta-data android:name="com.android.settings.summary"
-                android:resource="@string/summary_empty"/>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.DeviceInfoSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -1188,7 +1175,7 @@
         </activity>
 
         <activity android:name=".notification.ZenModeVoiceActivity"
-                android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.NoActionBar"
+                android:theme="@*android:style/Theme.DeviceDefault.Settings.Dialog.NoActionBar"
                 android:label="@string/zen_mode_settings_title">
             <intent-filter>
                 <action android:name="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE" />
@@ -1967,7 +1954,7 @@
 
         <activity android:name=".bluetooth.BluetoothPairingDialog"
                   android:excludeFromRecents="true"
-                  android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.NoActionBar">
+                  android:theme="@*android:style/Theme.DeviceDefault.Settings.Dialog.NoActionBar">
             <intent-filter android:priority="1">
                 <action android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1999,14 +1986,14 @@
                   android:excludeFromRecents="true"
                   android:exported="true"
                   android:permission="android.permission.MANAGE_USB"
-                  android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.NoActionBar">
+                  android:theme="@*android:style/Theme.DeviceDefault.Settings.Dialog.NoActionBar">
         </activity>
 
         <activity android:name=".RemoteBugreportActivity"
                   android:excludeFromRecents="true"
                   android:exported="true"
                   android:permission="android.permission.DUMP"
-                  android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.NoActionBar">
+                  android:theme="@*android:style/Theme.DeviceDefault.Settings.Dialog.NoActionBar">
             <intent-filter>
                 <action android:name="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2736,7 +2723,7 @@
         </activity>
 
         <activity android:name=".sim.SimPreferenceDialog"
-            android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.NoActionBar"
+            android:theme="@*android:style/Theme.DeviceDefault.Settings.Dialog.NoActionBar"
             android:excludeFromRecents="true">
         </activity>
 
@@ -2765,7 +2752,7 @@
         </activity>
 
         <activity android:name=".sim.SimDialogActivity"
-                android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.NoActionBar"
+                android:theme="@*android:style/Theme.DeviceDefault.Settings.Dialog.NoActionBar"
                 android:label="@string/sim_settings_title"
                 android:excludeFromRecents="true">
             <intent-filter>
diff --git a/res/layout-land/fingerprint_enroll_enrolling.xml b/res/layout-land/fingerprint_enroll_enrolling.xml
index 5c4e99b..b321519 100644
--- a/res/layout-land/fingerprint_enroll_enrolling.xml
+++ b/res/layout-land/fingerprint_enroll_enrolling.xml
@@ -66,14 +66,14 @@
                 android:layout_height="wrap_content">
 
                 <TextView
-                    style="@style/TextAppearance.FingerprintMessage"
+                    style="@style/SuwDescription.Glif"
                     android:id="@+id/start_message"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:text="@string/security_settings_fingerprint_enroll_start_message"/>
 
                 <TextView
-                    style="@style/TextAppearance.FingerprintMessage"
+                    style="@style/SuwDescription.Glif"
                     android:id="@+id/repeat_message"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
diff --git a/res/layout-land/fingerprint_enroll_find_sensor.xml b/res/layout-land/fingerprint_enroll_find_sensor.xml
index 3dadece..a43534f 100644
--- a/res/layout-land/fingerprint_enroll_find_sensor.xml
+++ b/res/layout-land/fingerprint_enroll_find_sensor.xml
@@ -65,7 +65,7 @@
                     android:layout_marginEnd="0dp" />
 
                 <TextView
-                    style="@style/TextAppearance.FingerprintMessage"
+                    style="@style/SuwDescription.Glif"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:text="@string/security_settings_fingerprint_enroll_find_sensor_message"/>
diff --git a/res/layout-land/fingerprint_enroll_finish.xml b/res/layout-land/fingerprint_enroll_finish.xml
index 5fc0d73..ca1a2d2 100644
--- a/res/layout-land/fingerprint_enroll_finish.xml
+++ b/res/layout-land/fingerprint_enroll_finish.xml
@@ -42,14 +42,14 @@
 
             <TextView
                 android:id="@+id/message"
-                style="@style/TextAppearance.FingerprintMessage"
+                style="@style/SuwDescription.Glif"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:text="@string/security_settings_fingerprint_enroll_finish_message"/>
 
             <TextView
                 android:id="@+id/message_secondary"
-                style="@style/TextAppearance.FingerprintMessage"
+                style="@style/SuwDescription.Glif"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="@dimen/suw_description_glif_margin_top"
diff --git a/res/layout/choose_lock_generic_fingerprint_header.xml b/res/layout/choose_lock_generic_fingerprint_header.xml
index 6a107bf..a92b68f 100644
--- a/res/layout/choose_lock_generic_fingerprint_header.xml
+++ b/res/layout/choose_lock_generic_fingerprint_header.xml
@@ -18,9 +18,9 @@
     android:id="@+id/fingerprint_header_description"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:gravity="center_vertical"
-    android:minHeight="56dp"
     android:paddingStart="?android:attr/listPreferredItemPaddingStart"
     android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+    android:paddingTop="@dimen/suw_description_glif_margin_top"
+    android:paddingBottom="@dimen/suw_description_glif_margin_bottom_lists"
     android:text="@string/lock_settings_picker_fingerprint_message"
-    style="@style/FingerprintHeaderStyle" />
+    style="@style/SuwDescription.Glif" />
diff --git a/res/layout/crypt_keeper_password_field.xml b/res/layout/crypt_keeper_password_field.xml
index 8102658..bf286c0 100644
--- a/res/layout/crypt_keeper_password_field.xml
+++ b/res/layout/crypt_keeper_password_field.xml
@@ -21,7 +21,8 @@
      switcher, if necessary. Assumed to be in a horizontal LinearLayout. -->
 <merge xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <EditText android:id="@+id/passwordEntry"
+    <!-- Note that crypt_keeper_pin_field.xml also has ImeAwareEditText with the same ID. -->
+    <com.android.settings.widget.ImeAwareEditText android:id="@+id/passwordEntry"
         android:layout_height="wrap_content"
         android:layout_width="0dip"
         android:layout_weight="1"
diff --git a/res/layout/crypt_keeper_pin_field.xml b/res/layout/crypt_keeper_pin_field.xml
index a13142e..b73b3d1 100644
--- a/res/layout/crypt_keeper_pin_field.xml
+++ b/res/layout/crypt_keeper_pin_field.xml
@@ -21,7 +21,8 @@
      switcher, if necessary. Assumed to be in a horizontal LinearLayout. -->
 <merge xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <EditText android:id="@+id/passwordEntry"
+    <!-- Note that crypt_keeper_password_field.xml also has ImeAwareEditText with the same ID. -->
+    <com.android.settings.widget.ImeAwareEditText android:id="@+id/passwordEntry"
         android:layout_height="wrap_content"
         android:layout_width="0dip"
         android:layout_weight="1"
diff --git a/res/layout/fingerprint_enroll_enrolling_base.xml b/res/layout/fingerprint_enroll_enrolling_base.xml
index bd1e2c2..7f8eb1b 100644
--- a/res/layout/fingerprint_enroll_enrolling_base.xml
+++ b/res/layout/fingerprint_enroll_enrolling_base.xml
@@ -38,14 +38,14 @@
             android:layout_marginTop="@dimen/suw_description_glif_margin_top">
 
             <TextView
-                style="@style/TextAppearance.FingerprintMessage"
+                style="@style/SuwDescription.Glif"
                 android:id="@+id/start_message"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:text="@string/security_settings_fingerprint_enroll_start_message"/>
 
             <TextView
-                style="@style/TextAppearance.FingerprintMessage"
+                style="@style/SuwDescription.Glif"
                 android:id="@+id/repeat_message"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
diff --git a/res/layout/fingerprint_enroll_find_sensor_base.xml b/res/layout/fingerprint_enroll_find_sensor_base.xml
index d38818b..60c8bc7 100644
--- a/res/layout/fingerprint_enroll_find_sensor_base.xml
+++ b/res/layout/fingerprint_enroll_find_sensor_base.xml
@@ -44,7 +44,7 @@
             android:clipChildren="false">
 
             <TextView
-                style="@style/TextAppearance.FingerprintMessage"
+                style="@style/SuwDescription.Glif"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="@dimen/suw_description_glif_margin_top"
diff --git a/res/layout/fingerprint_enroll_finish_base.xml b/res/layout/fingerprint_enroll_finish_base.xml
index 99c96ad..db099c3 100644
--- a/res/layout/fingerprint_enroll_finish_base.xml
+++ b/res/layout/fingerprint_enroll_finish_base.xml
@@ -32,7 +32,7 @@
 
         <TextView
             android:id="@+id/message"
-            style="@style/TextAppearance.FingerprintMessage"
+            style="@style/SuwDescription.Glif"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="@dimen/suw_description_glif_margin_top"
@@ -40,7 +40,7 @@
 
         <TextView
             android:id="@+id/message_secondary"
-            style="@style/TextAppearance.FingerprintMessage"
+            style="@style/SuwDescription.Glif"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="@dimen/suw_description_glif_margin_top"
diff --git a/res/layout/setup_choose_lock_generic_fingerprint_header.xml b/res/layout/setup_choose_lock_generic_fingerprint_header.xml
index b19bec1..4c696f3 100644
--- a/res/layout/setup_choose_lock_generic_fingerprint_header.xml
+++ b/res/layout/setup_choose_lock_generic_fingerprint_header.xml
@@ -16,14 +16,11 @@
 -->
 
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:gravity="center_vertical"
-        android:minHeight="56dp"
-        android:paddingBottom="@dimen/suw_description_glif_margin_bottom_lists"
-        android:paddingStart="?android:attr/listPreferredItemPaddingStart"
-        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-        android:paddingTop="@dimen/suw_description_glif_margin_top"
-        android:text="@string/setup_lock_settings_picker_fingerprint_message"
-        android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
-        android:textAppearance="?android:attr/textAppearanceListItem" />
+    style="@style/SuwDescription.Glif"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+    android:paddingTop="@dimen/suw_description_glif_margin_top"
+    android:paddingBottom="@dimen/suw_description_glif_margin_bottom_lists"
+    android:text="@string/setup_lock_settings_picker_fingerprint_message" />
diff --git a/res/layout/setup_choose_lock_generic_header.xml b/res/layout/setup_choose_lock_generic_header.xml
index 9a3547d..8875e1f 100644
--- a/res/layout/setup_choose_lock_generic_header.xml
+++ b/res/layout/setup_choose_lock_generic_header.xml
@@ -16,14 +16,11 @@
 -->
 
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:gravity="center_vertical"
-        android:minHeight="56dp"
-        android:paddingBottom="@dimen/suw_description_glif_margin_bottom_lists"
-        android:paddingStart="?android:attr/listPreferredItemPaddingStart"
-        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-        android:paddingTop="@dimen/suw_description_glif_margin_top"
-        android:text="@string/setup_lock_settings_picker_message"
-        android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
-        android:textAppearance="?android:attr/textAppearanceListItem" />
+    style="@style/SuwDescription.Glif"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+    android:paddingTop="@dimen/suw_description_glif_margin_top"
+    android:paddingBottom="@dimen/suw_description_glif_margin_bottom_lists"
+    android:text="@string/setup_lock_settings_picker_message" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ba919ce..26b70ba 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -721,7 +721,7 @@
     <!-- Text shown for title of settings checkbox to enable widgets [CHAR LIMIT=20]-->
     <string name="security_enable_widgets_title">Enable widgets</string>
     <!-- Summary for settings checkbox to disable widgets when the setting has been disabled by an installed device admin [CHAR LIMIT=50] -->
-    <string name="security_enable_widgets_disabled_summary">Disabled by administrator</string>
+    <string name="security_enable_widgets_disabled_summary">Disabled by admin</string>
     <!-- Text shown for summary of owner info setting (if none set) [CHAR LIMIT=40]-->
     <string name="owner_info_settings_summary">None</string>
     <!-- Description of how many characters are used in owner info [CHAR LIMIT=40]-->
@@ -744,10 +744,12 @@
     <string name="security_settings_title">Security &amp; screen lock</string>
     <!-- Security Settings screen setting option title for the item to take you to the encryption and credential screen -->
     <string name="encryption_and_credential_settings_title">Encryption &amp; credentials</string>
+    <!-- Security Settings screen Encryption and crendential summary -->
+    <string name="encryption_and_credential_settings_summary">Phone encrypted</string>
     <!-- Security Settings screen setting option title for the item to take you to the lock screen preference screen [CHAR LIMIT=60] -->
     <string name="lockscreen_settings_title">Lock screen preferences</string>
     <!-- Security Settings screen setting option summary for the item to take you to the lock screen preference screen -->
-    <string name="lockscreen_settings_summary">Access settings in lock screen</string>
+    <string name="lockscreen_settings_summary">Show all notification content</string>
 
     <!-- Main Settings screen setting option summary text for the item tot ake you to the security and location screen -->
     <string name="security_settings_summary">Set My Location, screen unlock, SIM card lock, credential storage lock</string>
@@ -756,7 +758,7 @@
     <!-- In the security screen, the header title for settings related to  Passwords-->
     <string name="security_passwords_title">Privacy</string>
     <!-- Summary for settings preference disabled by administrator [CHAR LIMIT=50] -->
-    <string name="disabled_by_administrator_summary">Disabled by administrator</string>
+    <string name="disabled_by_administrator_summary">Disabled by admin</string>
     <!-- In the security screen, the header title for security statuses -->
     <string name="security_status_title">Security status</string>
     <!-- Summary for Security settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
@@ -868,7 +870,11 @@
     <!-- Text shown in fingerprint settings explaining what the fingerprint can be used for. [CHAR LIMIT=NONE] -->
     <string name="security_settings_fingerprint_enroll_disclaimer">In addition to unlocking your phone, you can also use your fingerprint to authorize purchases and app access. <annotation id="url">Learn more</annotation></string>
     <!-- Text shown in fingerprint settings explaining what the fingerprint can be used for in the case unlocking is disabled [CHAR LIMIT=NONE] -->
-    <string name="security_settings_fingerprint_enroll_disclaimer_lockscreen_disabled">Screen lock option disabled. Contact your organization\'s administrator to learn more. <annotation id="admin_details">More details</annotation>\n\nYou can still use your fingerprint to authorize purchases and app access. <annotation id="url">Learn more</annotation></string>
+    <string name="security_settings_fingerprint_enroll_disclaimer_lockscreen_disabled">
+        The screen lock option is disabled. To learn more, contact your organization\'s admin.
+        <annotation id="admin_details">More details</annotation>\n\nYou can still use your
+        fingerprint to authorize purchases and app access.
+        <annotation id="url">Learn more</annotation></string>
     <!-- Text shown in fingerprint enroll when we didn't observe progress for a few seconds. [CHAR LIMIT=100] -->
     <string name="security_settings_fingerprint_enroll_lift_touch_again">Lift finger, then touch sensor again</string>
 
@@ -883,8 +889,11 @@
     <string name="fingerprint_last_delete_title">Remove all fingerprints?</string>
 
     <!-- Message shown in a dialog which asks the user to confirm when the last fingerprint gets deleted by him. [CHAR LIMIT=NONE]-->
-    <string name="fingerprint_last_delete_message">You won\'t be able to use your fingerprints to unlock your phone, authorize purchases, or sign in to apps with them.</string>
-    <string name="fingerprint_last_delete_message_profile_challenge">You won\'t be able to use your fingerprints to unlock your work profile, authorize purchases, or sign in to work apps.</string>
+    <string name="fingerprint_last_delete_message">You won\'t be able to use your fingerprints to
+        unlock your phone, authorize purchases, or sign in to apps with them</string>
+    <string name="fingerprint_last_delete_message_profile_challenge">You won\'t be able to use your
+        fingerprints to unlock your work profile, authorize purchases, or sign in to work
+        apps</string>
 
     <!-- Button to confirm the last removing the last fingerprint. [CHAR LIMIT=20]-->
     <string name="fingerprint_last_delete_confirm">Yes, remove</string>
@@ -1069,6 +1078,12 @@
     <!--  Title for PreferenceScreen to launch picker for security method when there is none [CHAR LIMIT=22] -->
     <string name="unlock_set_unlock_launch_picker_title">Screen lock</string>
 
+    <!--  Summary for PreferenceScreen to launch picker for security method when there is none [CHAR LIMIT=NONE] -->
+    <string name="unlock_set_unlock_launch_picker_summary_lock_immediately"><xliff:g id="unlock_method" example="PIN">%1$s</xliff:g> / Immediately after sleep</string>
+
+    <!--  Summary for PreferenceScreen to launch picker for security method when there is none [CHAR LIMIT=NONE] -->
+    <string name="unlock_set_unlock_launch_picker_summary_lock_after_timeout"><xliff:g id="unlock_method" example="PIN">%1$s</xliff:g> / <xliff:g id="timeout_string">%2$s</xliff:g> after sleep</string>
+
     <!--  Profile Security lock settings --><skip />
     <!--  Title for PreferenceScreen to launch picker for security method for the managed profile when there is none [CHAR LIMIT=22] -->
     <string name="unlock_set_unlock_launch_picker_title_profile">Work profile lock</string>
@@ -1129,7 +1144,8 @@
     <string name="fingerprint_unlock_title">You can unlock your phone using your fingerprint. For security, this option requires a backup screen lock.</string>
 
     <!-- Summary for preference that has been disabled by because of the DevicePolicyAdmin, or because device encryption is enabled, or because there are credentials in the credential storage [CHAR LIMIT=50] -->
-    <string name="unlock_set_unlock_disabled_summary">Disabled by administrator, encryption policy, or credential storage</string>
+    <string name="unlock_set_unlock_disabled_summary">Disabled by admin, encryption policy, or
+        credential storage</string>
 
     <!-- Summary for "Configure lockscreen" when lock screen is off [CHAR LIMIT=45] -->
     <string name="unlock_set_unlock_mode_off">None</string>
@@ -1223,15 +1239,17 @@
     <string name="lockpassword_continue_label">Continue</string>
 
     <!-- Error shown in popup when password is too long -->
-    <string name="lockpassword_password_too_long">Must be fewer than <xliff:g id="number" example="17">%d</xliff:g> characters.</string>
+    <string name="lockpassword_password_too_long">Must be fewer than
+        <xliff:g id="number" example="17">%d</xliff:g> characters</string>
     <!-- Error shown in popup when PIN is too long -->
-    <string name="lockpassword_pin_too_long">Must be fewer than <xliff:g id="number" example="17">%d</xliff:g> digits.</string>
+    <string name="lockpassword_pin_too_long">Must be fewer than
+        <xliff:g id="number" example="17">%d</xliff:g> digits</string>
 
     <!-- Error shown when in PIN mode and user enters a non-digit -->
-    <string name="lockpassword_pin_contains_non_digits">Must contain only digits 0-9.</string>
+    <string name="lockpassword_pin_contains_non_digits">Must contain only digits 0-9</string>
 
     <!-- Error shown when in PIN mode and PIN has been used recently. Please keep this string short! -->
-    <string name="lockpassword_pin_recently_used">Device administrator doesn\u2019t allow using a recent PIN.</string>
+    <string name="lockpassword_pin_recently_used">Device admin doesn\'t allow using a recent PIN</string>
 
     <!-- Error shown when in PASSWORD mode and user enters an invalid character -->
     <string name="lockpassword_illegal_character">This can\'t include an invalid character</string>
@@ -1282,10 +1300,12 @@
     </plurals>
 
     <!-- Error shown when in PASSWORD mode and password has been used recently. Please keep this string short! -->
-    <string name="lockpassword_password_recently_used">Device administrator doesn\u2019t allow using a recent password.</string>
+    <string name="lockpassword_password_recently_used">Device admin doesn\'t allow using a recent
+        password</string>
 
     <!-- [CHAR_LIMIT=NONE] Error shown when the user tries to set an ascending or descending sequence of digits -->
-    <string name="lockpassword_pin_no_sequential_digits">An ascending, descending or repeated sequence of digits is forbidden</string>
+    <string name="lockpassword_pin_no_sequential_digits">Ascending, descending, or repeated sequence
+        of digits isn\'t allowed</string>
 
     <!-- Label for ChoosePassword/PIN OK button -->
     <string name="lockpassword_ok_label">OK</string>
@@ -1302,13 +1322,13 @@
     <!-- Toast shown when lock pattern or password successfully setup. [CHAR LIMIT=64] -->
     <string name="lock_setup" msgid="5507462851158901718">Setup is complete.</string>
 
-    <!-- Title of preference to manage device admins -->
+    <!-- Title of preference to manage device admin apps, which are used by IT admins to manage devices -->
     <string name="manage_device_admin">Device admin apps</string>
 
-    <!-- Summary of preference to manage device administrators, informing the user that currently no device administrator apps are installed and active -->
+    <!-- Summary of preference to manage device admin apps, informing the user that currently no device admin apps are installed and active -->
     <string name="number_of_device_admins_none">No active apps</string>
 
-    <!-- Summary of preference to manage device administrators, informing the user how many device administrator apps are installed and active -->
+    <!-- Summary of preference to manage device admin apps, informing the user how many device admin apps are installed and active -->
     <plurals name="number_of_device_admins">
         <item quantity="one"><xliff:g id="count">%d</xliff:g> active app</item>
         <item quantity="other"><xliff:g id="count">%d</xliff:g> active apps</item>
@@ -1320,8 +1340,14 @@
     <!-- Summary shown when trust agent settings is disabled because the user hasn't set up primary security -->
     <string name="disabled_because_no_backup_security">To use, first set a screen lock</string>
 
-    <!-- Summary of preference to manage device policies -->
-    <string name="manage_trust_agents_summary">View or deactivate trust agents</string>
+    <!-- Summary of preference to manage device policies when there is no trust agents-->
+    <string name="manage_trust_agents_summary">None</string>
+
+    <!-- Summary of preference to manage device policies when there is trust agent-->
+    <plurals name="manage_trust_agents_summary_on">
+        <item quantity="one">1 active trust agent</item>
+        <item quantity="other"><xliff:g id="count" example="3">%d</xliff:g> active trust agents</item>
+    </plurals>
 
     <!-- Bluetooth settings -->
     <!-- Bluetooth settings check box title on Main Settings screen -->
@@ -1586,8 +1612,6 @@
     <string name="wifi_starting">Turning Wi\u2011Fi on\u2026</string>
     <!-- Summary text when turning Wi-Fi or bluetooth off -->
     <string name="wifi_stopping">Turning off Wi\u2011Fi\u2026</string>
-    <!-- Title of Button to show all Wi-Fi networks in the picker. [CHAR LIMIT=30] -->
-    <string name="wifi_see_all_networks_button_title">See all networks</string>
     <!-- Summary text when Wi-Fi or bluetooth has error -->
     <string name="wifi_error">Error</string>
     <!-- Summary text when wifi SoftAP started failed due to no legal usable channel allowed in this region by regulatory -->
@@ -2109,8 +2133,8 @@
          the same as the incoming call volume. -->
     <string name="checkbox_notification_same_as_incoming_call">Use incoming call volume for notifications</string>
 
-    <!-- Home settings screen, text indicating that a launcer does not support work profiles [CHAR LIMIT=100] -->
-    <string name="home_work_profile_not_supported">Doesn\u2019t support work profiles</string>
+    <!-- Home settings screen, text indicating that a launcher does not support work profiles [CHAR LIMIT=100] -->
+    <string name="home_work_profile_not_supported">Doesn\'t support work profiles</string>
 
     <!-- Sound settings screen, setting option title-->
     <string name="notification_sound_dialog_title">Default notification sound</string>
@@ -2223,11 +2247,44 @@
     <string name="auto_brightness_title">Adaptive brightness</string>
     <!-- Sound & display settings screen, setting option summary to enable adaptive brightness [CHAR LIMIT=100] -->
     <string name="auto_brightness_summary">Optimize brightness level for available light</string>
+    <!-- Sound & display settings screen, setting option summary when adaptive brightness is off [CHAR LIMIT=100] -->
+    <string name="auto_brightness_summary_off">Off</string>
+    <!-- Sound & display settings screen, setting option summary when preferred adaptive brightness is very low [CHAR LIMIT=100] -->
+    <string name="auto_brightness_summary_very_low">Preferred brightness is very low</string>
+    <!-- Sound & display settings screen, setting option summary when preferred adaptive brightness is low [CHAR LIMIT=100] -->
+    <string name="auto_brightness_summary_low">Preferred brightness is low</string>
+    <!-- Sound & display settings screen, setting option summary when preferred adaptive brightness is the default [CHAR LIMIT=100] -->
+    <string name="auto_brightness_summary_default">Preferred brightness is default</string>
+    <!-- Sound & display settings screen, setting option summary when preferred adaptive brightness is high [CHAR LIMIT=100] -->
+    <string name="auto_brightness_summary_high">Preferred brightness is high</string>
+    <!-- Sound & display settings screen, setting option summary when preferred adaptive brightness is very high [CHAR LIMIT=100] -->
+    <string name="auto_brightness_summary_very_high">Preferred brightness is very high</string>
+    <!-- Adaptive brightness settings screen, setting option to disable adaptive brightness [CHAR LIMIT=100] -->
+    <string name="auto_brightness_off_title">Off</string>
+    <!-- Adaptive brightness settings screen, setting option to enable adaptive brightness when user prefers very low brightness [CHAR LIMIT=100] -->
+    <string name="auto_brightness_very_low_title">Very low</string>
+    <!-- Adaptive brightness settings screen, setting option to enable adaptive brightness when user prefers low brightness [CHAR LIMIT=100] -->
+    <string name="auto_brightness_low_title">Low</string>
+    <!-- Adaptive brightness settings screen, setting option to enable adaptive brightness when user prefers default brightness [CHAR LIMIT=100] -->
+    <string name="auto_brightness_default_title">Default</string>
+    <!-- Adaptive brightness settings screen, setting option to enable adaptive brightness when user prefers high brightness [CHAR LIMIT=100] -->
+    <string name="auto_brightness_high_title">High</string>
+    <!-- Adaptive brightness settings screen, setting option to enable adaptive brightness when user prefers very high brightness [CHAR LIMIT=100] -->
+    <string name="auto_brightness_very_high_title">Very high</string>
+    <!-- Adaptive brightness settings screen, subtitle [CHAR LIMIT=100] -->
+    <string name="auto_brightness_subtitle">Your preferred brightness level</string>
+    <!-- Adaptive brightness settings screen, setting option summary to disable adaptive brightness [CHAR LIMIT=100] -->
+    <string name="auto_brightness_off_summary">Don\'t adjust for available light</string>
+    <!-- Adaptive brightness settings screen, setting option summary to enable adaptive brightness when user prefers very high brightness.
+         Meant to make it clear that preferring very high brightness uses more battery. [CHAR LIMIT=100] -->
+    <string name="auto_brightness_very_high_summary">Increased battery usage</string>
+    <!-- Adaptive brightness settings screen, disclaimer that explains in more detail about how adaptive brightness works [CHAR LIMIT=100] -->
+    <string name="auto_brightness_disclaimer">Optimize brightness level for available light. When this feature is on, you can still adjust brightness temporarily.</string>
 
-    <!-- Night display screen, setting option name to enable night display (renamed "Night Light" with title caps). [CHAR LIMIT=30] -->
-    <string name="night_display_title">Night Light</string>
-    <!-- Night display screen, description of night display feature (renamed "Night Light" with title caps). [CHAR LIMIT=NONE] -->
-    <string name="night_display_text">Night Light tints your screen amber. This makes it easier to look at your screen or read in dim light, and may help you fall asleep more easily.</string>
+    <!-- Night display screen, setting option name to enable night display. [CHAR LIMIT=30] -->
+    <string name="night_display_title">Night display</string>
+    <!-- Night display screen, description of night display feature. [CHAR LIMIT=NONE] -->
+    <string name="night_display_text">Night display tints your screen amber. This makes it easier to look at your screen or read in dim light, and may help you fall asleep more easily.</string>
     <!-- Night display screen, category title for settings to schedule when night display activates automatically. [CHAR LIMIT=30] -->
     <string name="night_display_category_schedule">Schedule</string>
     <!-- Night display screen, category title for settings to manually activate night display. [CHAR LIMIT=30] -->
@@ -2284,19 +2341,21 @@
     <!-- Display settings screen, trigger for screen saver options -->
     <string name="screensaver_settings_title">Screen saver</string>
     <!-- Display settings screen, summary fragment for screen saver options, activated when docked or asleep and charging -->
-    <string name="screensaver_settings_summary_either_long">When docked or asleep and charging</string>
+    <string name="screensaver_settings_summary_either_long">While charging or docked</string>
     <!-- Dream settings screen, dialog option, activated when docked or asleep and charging -->
     <string name="screensaver_settings_summary_either_short">Either</string>
     <!-- Display settings screen, summary fragment for screen saver options, activated when asleep and charging -->
     <string name="screensaver_settings_summary_sleep">While charging</string>
     <!-- Display settings screen, summary fragment for screen saver options, activated when docked  -->
     <string name="screensaver_settings_summary_dock">While docked</string>
+    <!-- Display settings screen, summary fragment for screen saver options, activated never  -->
+    <string name="screensaver_settings_summary_never">Never</string>
     <!-- Display settings screen, summary for screen saver options, screen saver is turned off -->
     <string name="screensaver_settings_summary_off">Off</string>
     <!-- Dream settings screen, caption for when dreams are disabled -->
     <string name="screensaver_settings_disabled_prompt">To control what happens when the phone is docked and/or sleeping, turn screen saver on.</string>
     <!-- Dream settings screen, action label, when to dream -->
-    <string name="screensaver_settings_when_to_dream">When to start screen saver</string>
+    <string name="screensaver_settings_when_to_dream">When to start</string>
     <!-- Dream settings screen, button label to start dreaming -->
     <string name="screensaver_settings_dream_start">Start now</string>
     <!-- Dream settings screen, button label for settings for a specific screensaver -->
@@ -2318,8 +2377,12 @@
 
     <!-- SIM lock settings title  [CHAR LIMIT=40] -->
     <string name="sim_lock_settings">SIM card lock settings</string>
-    <!-- Security & location settings screen, setting option name  [CHAR LIMIT=40] -->
-    <string name="sim_lock_settings_category">Set up SIM card lock</string>
+    <!-- Security & screen lock settings screen, SIM card lock setting option name  [CHAR LIMIT=40] -->
+    <string name="sim_lock_settings_category">SIM card lock</string>
+    <!-- Security & screen lock settings screen, SIM card lock setting summary when off [CHAR LIMIT=NONE] -->
+    <string name="sim_lock_settings_summary_off">Off</string>
+    <!-- Security & screen lock settings screen, SIM card lock setting summary when on [CHAR LIMIT=NONE] -->
+    <string name="sim_lock_settings_summary_on">Locked</string>
     <!-- Security & location settings screen, section heading for settings related to sim card locking  [CHAR LIMIT=40] -->
     <string name="sim_lock_settings_title">SIM card lock</string>
     <!-- SIM card lock settings screen, setting check box label  [CHAR LIMIT=40] -->
@@ -2906,6 +2969,10 @@
     <!-- APNs screen toast message to inform reset default APN settings is completed -->
     <string name="restore_default_apn_completed">Reset default APN settings completed.</string>
 
+
+    <!-- Title for a screen containing all device reset options [CHAR LIMIT=50] -->
+    <string name="reset_dashboard_title">Reset</string>
+
     <!-- Reset Network -->
     <!-- SD card & phone storage settings screen, setting option name under Backup & Restore heading -->
     <string name="reset_network_title">Network settings reset</string>
@@ -2927,6 +2994,12 @@
     <!-- Master Clear -->
     <!-- SD card & phone storage settings screen, setting option name under Internal phone storage heading -->
     <string name="master_clear_title">Factory data reset</string>
+    <!-- Summary text for factory data reset describing what will be reset [CHAR_LIMIT=NONE]-->
+    <plurals name="master_clear_with_account_summary">
+        <item quantity="one">1 account will be reset</item>
+        <item quantity="other"><xliff:g id="account_count">%1$d</xliff:g> accounts will be reset</item>
+    </plurals>
+    <string name="master_clear_summary">Internal storage &amp; all data will be reset</string>
     <!-- SD card & phone storage settings screen, message on screen after user selects Factory data reset [CHAR LIMIT=NONE] -->
     <string name="master_clear_desc" product="tablet">"This will erase all data from your tablet\u2019s <b>internal storage</b>, including:\n\n<li>Your Google account</li>\n<li>System and app data and settings</li>\n<li>Downloaded apps</li>"</string>
     <!-- SD card & phone storage settings screen, message on screen after user selects Factory data reset [CHAR LIMIT=NONE] -->
@@ -3432,11 +3505,11 @@
     <!-- Manage applications, individual application info screen,label under Storage heading.  The total storage space taken up by this app. -->
     <string name="total_size_label">Total</string>
     <!-- Manage applications, individual application info screen, label under Storage heading. The amount of space taken up by the application itself (for example, the java compield files and things like that) -->
-    <string name="application_size_label">App</string>
+    <string name="application_size_label">App size</string>
     <!--  Manage applications, individual application info screen, label under Storage heading.  The amount of space taken up by the app's code on USB storage [CHARSIZE=40] -->
     <string name="external_code_size_label">USB storage app</string>
     <!-- Manage applications, individual application info screen, label under Storage heading.  The amount of sapce taken up by the app's data (for example, downloaded emails or something like that) -->
-    <string name="data_size_label">Data</string>
+    <string name="data_size_label">User data</string>
     <!--  Manage applications, individual application info screen, label under Storage heading.  The amount of space taken up by the app's data on USB storage [CHARSIZE=40] -->
     <string name="external_data_size_label" product="nosdcard">USB storage data</string>
     <!--  Manage applications, individual application info screen, label under Storage heading.  The amount of space taken up by the app's data on the SD card [CHARSIZE=40] -->
@@ -3619,7 +3692,7 @@
     <string name="invalid_location">Install location isn\u2019t valid.</string>
     <string name="system_package">System updates can\u2019t be installed on external media.</string>
     <!-- Error message shown when trying to move device administrators to external disks, such as SD card [CHAR_LIMIT=none] -->
-    <string name="move_error_device_admin">Device Administrator can\u2019t be installed on external media.</string>
+    <string name="move_error_device_admin">Device admin app can\'t be installed on external media</string>
 
     <string name="force_stop_dlg_title">Force stop?</string>
     <!-- [CHAR LIMIT=200] Manage applications, text for dialog when killing persistent apps-->
@@ -3829,7 +3902,7 @@
     <!-- Title for the 'keyboard and input methods' preference category. [CHAR LIMIT=45] -->
     <string name="keyboard_and_input_methods_category">Keyboard &amp; inputs</string>
     <!-- Title for the 'virtual keyboard' preference sub-screen. [CHAR LIMIT=35] -->
-    <string name="virtual_keyboard_category">Virtual keyboards</string>
+    <string name="virtual_keyboard_category">Virtual keyboard</string>
     <!-- Title for the 'available virtual keyboard' preference sub-screen. [CHAR LIMIT=35] -->
     <string name="available_virtual_keyboard_category">Available virtual keyboard</string>
     <!-- Title for the button to trigger the 'Manage keyboards' preference sub-screen, where the user can turn on/off installed virtual keyboards.[CHAR LIMIT=35] -->
@@ -4049,14 +4122,32 @@
     <string name="accessibility_captioning_title">Captions</string>
     <!-- Title for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=35] -->
     <string name="accessibility_screen_magnification_title">Magnification</string>
+    <!-- Title for the accessibility preference screen to enable triple-tap gesture screen magnification. [CHAR LIMIT=35] -->
+    <string name="accessibility_screen_magnification_gestures_title">Magnify with triple-tap</string>
+    <!-- Title for the accessibility preference screen to enable navigation bar screen magnification. [CHAR LIMIT=35] -->
+    <string name="accessibility_screen_magnification_navbar_title">Magnify with button</string>
+    <!-- Summary for the accessibility magnification setting indicating both "Magnify with button" and "Magnify with triple-tap" are enabled [CHAR LIMIT=50] -->
+    <string name="accessibility_screen_magnification_state_navbar_gesture">Magnify with button &amp; triple-tap</string>
     <!-- Summary for the accessibility preference to enable screen magnification. [CHAR LIMIT=25] -->
     <string name="accessibility_preference_magnification_summary">Zoom in on screen</string>
     <!-- Short summary for Magnification gesture. Tells the user that this feature allows the user to magnify the screen by tapping 3 times. Appears in accessibility portion of setup wizard -->
     <string name="accessibility_screen_magnification_short_summary">Tap 3 times to zoom</string>
-    <!-- Summary for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=none] -->
-    <string name="accessibility_screen_magnification_summary"><b>To zoom</b>, quickly tap the screen 3 times with one finger.\n<ul><li>Drag 2 or more fingers to scroll</li>\n<li>Pinch 2 or more fingers together or apart to adjust zoom</li></ul>\n\n<b>To zoom temporarily</b>, quickly tap the screen 3 times and hold down your finger on the third tap.\n<ul><li>Drag your finger to move around the screen</li>\n<li>Lift your finger to zoom out</li></ul>\n\nYou can\'t zoom in on the keyboard and navigation bar.</string>
-    <!-- Title for the preference to enable the global geture that turns on accessibility. [CHAR LIMIT=35] -->
+    <!-- Short summary for nav bar Magnification. Tells the user that this feature allows the user to magnify the screen using a button in the nav bar -->
+    <string name="accessibility_screen_magnification_navbar_short_summary">Tap a button to zoom</string>
+    <!-- Summary for the accessibility preference screen to enable screen magnification gestures. [CHAR LIMIT=none] -->
+    <string name="accessibility_screen_magnification_summary"><b>To zoom</b>, quickly tap the screen 3 times.\n<ul><li>Drag 2 or more fingers to scroll</li>\n<li>Pinch 2 or more fingers to adjust zoom</li></ul>\n\n<b>To zoom temporarily</b>, quickly tap the screen 3 times and hold down your finger on the third tap.\n<ul><li>Drag to move around the screen</li>\n<li>Lift finger to zoom out</li></ul>\n\nYou can\'t zoom in on the keyboard and navigation bar.</string>
+    <!-- Summary for the accessibility preference screen to enable screen magnification via the nav bar. [CHAR LIMIT=none] -->
+    <string name="accessibility_screen_magnification_navbar_summary">When magnification is turned on, use the Accessibility button at the bottom of the screen to quickly magnify.\n\n<b>To zoom</b>, tap the Accessibility button, then tap anywhere on the screen.\n<ul><li>Drag 2 or more fingers to scroll</li>\n<li>Pinch 2 or more fingers to adjust zoom</li></ul>\n\n<b>To zoom temporarily</b>, tap the Accessibility button, then touch &amp; hold anywhere on the screen.\n<ul><li>Drag to move around the screen</li>\n<li>Lift finger to zoom out</li></ul>\n\nYou can’t zoom in on the keyboard or navigation bar.</string>
+    <!-- Summary text appearing on the accessibility preference screen to enable screen magnification from the nav bar when the feature is enabled, but the accessibility button is not configured correctly for the feature to be used [CHAR LIMIT=none] -->
+    <string name="accessibility_screen_magnification_navbar_configuration_warning">The Accessibility button is set to <xliff:g id="service" example="Select to Speak">%1$s</xliff:g>. To use magnification, touch &amp; hold the Accessibility button, then select magnification.</string>
+    <!-- Title for the preference to configure the accessibility shortcut. [CHAR LIMIT=35] -->
     <string name="accessibility_global_gesture_preference_title">Accessibility shortcut</string>
+    <!-- Title for the preference to choose the service that is turned on and off by the accessibility shortcut. [CHAR LIMIT=35] -->
+    <string name="accessibility_shortcut_service_title">Shortcut service</string>
+    <!-- Title for the switch preference that controls whether or not the accessibility shortcut works on the lock screen. [CHAR LIMIT=35] -->
+    <string name="accessibility_shortcut_service_on_lock_screen_title">Allow from lock screen</string>
+    <!-- Description of accessibility shortcut. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_shortcut_description">When the shortcut is on, you can press both volume buttons for 3 seconds to start an accessibility feature.</string>
     <!-- Title for the accessibility preference to high contrast text. [CHAR LIMIT=35] -->
     <string name="accessibility_toggle_high_text_contrast_preference_title">High contrast text</string>
     <!-- Title for the accessibility preference to auto update screen magnification. [CHAR LIMIT=35] -->
@@ -4084,6 +4175,13 @@
     <!-- Title for accessibility preference for configuring amount of time that has to pass after pointer stops moving before click action can be performed (if automatic click after pointer stops moving feature is enabled). [CHAR LIMIT=NONE] -->
     <string name="accessibility_autoclick_delay_preference_title">Delay before click</string>
 
+    <!-- Summary text for accessibility service preferences, or preferences including a short description (eg. "ON / High accuracy mode"). -->
+    <string name="accessibility_summary_default_combination"><xliff:g id="state" example="ON">%1$s</xliff:g> / <xliff:g id="description" example="High accuracy mode">%2$s</xliff:g></string>
+    <!-- Preference's state when enabled. Note: UPPERCASE -->
+    <string name="accessibility_summary_state_enabled">ON</string>
+    <!-- Preference's state when disabled. Note: UPPERCASE -->
+    <string name="accessibility_summary_state_disabled">OFF</string>
+
     <!-- Title for the preference to show a tile for a particular feature in the Quick Settings pane. [CHAR LIMIT=NONE] -->
     <string name="enable_quick_setting">Show in Quick Settings</string>
     <!-- Title for the preference to configure the type of color space correction to apply. [CHAR LIMIT=NONE] -->
@@ -4240,6 +4338,9 @@
     <!-- Title for the prompt shown as a placeholder if no accessibility services are installed. [CHAR LIMIT=50] -->
     <string name="accessibility_no_services_installed">No services installed</string>
 
+    <!-- Title for the acccessibility shortcut's summary if no service is selected for use with the shortcut. [CHAR LIMIT=50] -->
+    <string name="accessibility_no_service_selected">No service selected</string>
+
     <!-- Default description for an accessibility service if the latter doesn't provide one. [CHAR LIMIT=NONE] -->
     <string name="accessibility_service_default_description">No description provided.</string>
 
@@ -4253,12 +4354,12 @@
     <string name="print_settings">Printing</string>
 
     <!-- Print setting summary in settings screen [CHAR LIMIT=50] -->
-    <string name="print_settings_summary_no_service">No print service</string>
+    <string name="print_settings_summary_no_service">Off</string>
 
     <!-- Print setting summary in settings screen [CHAR LIMIT=50] -->
     <plurals name="print_settings_summary">
-        <item quantity="one">1 print service</item>
-        <item quantity="other"><xliff:g id="count">%1$d</xliff:g> print services</item>
+        <item quantity="one">1 print service on</item>
+        <item quantity="other"><xliff:g id="count">%1$d</xliff:g> print services on</item>
     </plurals>
 
     <!-- Title for print service settings screen [CHAR LIMIT=25] -->
@@ -4353,18 +4454,26 @@
     <string name="background_activity_title">Background activity</string>
     <!-- Summary for the background activity [CHAR_LIMIT=120] -->
     <string name="background_activity_summary">Allow the app to run in the background</string>
+    <!-- Summary for the background activity when it is on [CHAR_LIMIT=120] -->
+    <string name="background_activity_summary_on">App can run in the background when not in use</string>
+    <!-- Summary for the background activity when it is off [CHAR_LIMIT=120] -->
+    <string name="background_activity_summary_off">App\'s background activity is limited when not in use</string>
+    <!-- Summary for the background activity when it is disabled [CHAR_LIMIT=120] -->
+    <string name="background_activity_summary_disabled">App not allowed to run in background</string>
 
     <!-- Title for the screen usage in power use UI [CHAR_LIMIT=40] -->
-    <string name="device_screen_usage">Screen usage</string>
+    <string name="device_screen_usage">Screen usage since full charge</string>
     <!-- Title for the screen consumption in power use UI(i.e. Screen consumption: 30% of battery usage) [CHAR_LIMIT=40] -->
     <string name="device_screen_consumption">Screen consumption</string>
     <!-- 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 list of apps using battery in power use UI [CHAR_LIMIT=60] -->
-    <string name="power_usage_list_summary">App usage since last full charge</string>
+    <string name="power_usage_list_summary">App usage since full charge</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] -->
-    <string name="device_usage_list_summary">Device usage since last full charge</string>
+    <string name="device_usage_list_summary">Device usage since full charge</string>
     <!-- Battery usage since unplugged -->
     <string name="battery_since_unplugged">Battery use since unplugged</string>
     <!-- Battery usage since user reset the stats -->
@@ -4404,7 +4513,7 @@
     <string name="history_details_title">History details</string>
 
     <!-- Activity title for battery usage details for an app. or power consumer -->
-    <string name="details_title">Use details</string>
+    <string name="battery_details_title">Battery usage</string>
     <!-- Subtitle for application/subsystem details -->
     <string name="details_subtitle">Use details</string>
     <!-- Subtitle for possible options -->
@@ -4561,19 +4670,37 @@
 
     <!-- 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 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] -->
-    <string name="battery_overall_usage">%1$s of overall battery</string>
+    <string name="battery_overall_usage"><xliff:g id="percent">%1$s</xliff:g> of overall battery</string>
     <!-- Description for battery usage detail information since last full charge. [CHAR LIMIT=120] -->
-    <string name="battery_detail_since_full_charge">Usage breakdown since last full charge</string>
+    <string name="battery_detail_since_full_charge">Breakdown since last full charge</string>
+    <!-- Title for usage time since last full charge. [CHAR LIMIT=60] -->
+    <string name="battery_last_full_charge">Last full charge</string>
+    <!-- Description for text in battery footer. [CHAR LIMIT=120] -->
+    <string name="battery_footer_summary">Remaining battery time is approximate and can change based on usage</string>
+    <!-- Title for battery usage detail in foreground. [CHAR LIMIT=80] -->
+    <string name="battery_detail_foreground">While using app</string>
+    <!-- Title for battery usage detail in background. [CHAR LIMIT=80] -->
+    <string name="battery_detail_background">While in background</string>
+    <!-- Title for battery usage amount by this app. [CHAR LIMIT=80] -->
+    <string name="battery_detail_power_usage">Battery usage</string>
+    <!-- Description for battery usage amount, i.e. 16% of overall app usage(340 mAh). [CHAR LIMIT=120] -->
+    <string name="battery_detail_power_percentage"><xliff:g id="percent">%1$s</xliff:g> of total app usage (<xliff:g id="power">%2$d</xliff:g>mAh)</string>
+    <!-- Title for the battery usage group, which means all the battery data are calculated 'since full charge' [CHAR LIMIT=40] -->
+    <string name ="battery_detail_info_title">Since full charge</string>
+    <!-- Title for the battery management group [CHAR LIMIT=40] -->
+    <string name ="battery_detail_manage_title">Manage battery usage</string>
 
     <!-- Description for battery time left, i.e. 50min Estimated time left. [CHAR LIMIT=80]-->
     <string name="estimated_time_left">Estimated time left</string>
 
-    <!-- Description for charging time left, i.e. 50min Time to full charge. [CHAR LIMIT=80]-->
-    <string name="estimated_charging_time_left">Time to full charge</string>
+    <!-- Description for charging time left, i.e. 50min until fully charged [CHAR LIMIT=80]-->
+    <string name="estimated_charging_time_left">Until fully charged</string>
 
     <!-- Description for estimated time. [CHAR LIMIT=80]-->
-    <string name="estimated_time_description">Estimation may change based on usage</string>
+    <string name="estimated_time_description">Estimate may change based on usage</string>
 
     <!-- Menu label for viewing battery usage since unplugged -->
     <string name="menu_stats_unplugged"><xliff:g id="unplugged">%1$s</xliff:g> since unplugged</string>
@@ -4750,6 +4877,18 @@
     <!-- [CHAR LIMIT=50] Name for the button that goes to the voice selection screen. -->
     <string name="tts_install_voice_title">Voices</string>
 
+    <!-- The text for the settings to choose the language to use on TTS.-->
+    <string name="tts_spoken_language">Spoken Language</string>
+
+    <!-- Title of the pop-up to install 3P voices on first use. -->
+    <string name="tts_install_voices_title">Install Voices</string>
+    <!-- Text of the pop-up to install 3P voices on first use. -->
+    <string name="tts_install_voices_text">Continue to the <xliff:g id="tts_app_name">%s</xliff:g> app to install voices</string>
+    <!-- Text of the button on the pop-up to install 3P voices on first use to procedd to the 3p app. -->
+    <string name="tts_install_voices_open">Open App</string>
+    <!-- Text of the button on the pop-up to install 3P voices on first use to cancel the operation. -->
+    <string name="tts_install_voices_cancel">Cancel</string>
+
     <!-- Name for button that resets speech rate and pitch for synthesized voice to default values in the text to speech settings.-->
     <string name="tts_reset">Reset</string>
 
@@ -4881,7 +5020,7 @@
     <!-- Summary text of the "automatic restore" setting -->
     <string name="auto_restore_summary">When reinstalling an app, restore backed up settings and data</string>
     <!-- Title of the preference informing the user about the backup service being inactive [CHAR LIMIT=50]-->
-    <string name="backup_inactive_title">Backup service is inactive.</string>
+    <string name="backup_inactive_title">Backup service isn\'t active</string>
     <!-- Default summary text of the "Configure backup account" setting [CHAR LIMIT=80]-->
     <string name="backup_configure_account_default_summary">No account is currently storing backed up data</string>
 
@@ -4893,52 +5032,55 @@
     <string name="fullbackup_erase_dialog_message">Stop backing up device data (such as Wi-Fi passwords and call history) and app data (such as settings and files stored by apps), plus erase all copies on remote servers?</string>
     <!-- Summary for explanation of what full app data backup means. Manufacturers may wish to overlay this resource with their own text  -->
     <string name="fullbackup_data_summary">Automatically back up device data (such as Wi-Fi passwords and call history) and app data (such as settings and files stored by apps) remotely.\n\nWhen you turn on automatic backup, device and app data is periodically saved remotely. App data can be any data that an app has saved (based on developer settings), including potentially sensitive data such as contacts, messages, and photos.</string>
-    <!-- Device admin settings screen --><skip />
-    <!-- Device admin settings activity title -->
-    <string name="device_admin_settings_title">Device administration settings</string>
-    <!-- Label for screen showing the active device policy -->
-    <string name="active_device_admin_msg">Device administrator</string>
-    <!-- Label for button to remove the active device admin [CHAR LIMIT=80] -->
-    <string name="remove_device_admin">Deactivate this device administrator</string>
-    <!-- Label for button to uninstall the device admin application [CHAR LIMIT=80] -->
+    <!-- Device admin app settings screen --><skip />
+    <!-- Device admin app settings activity title -->
+    <string name="device_admin_settings_title">Device admin settings</string>
+    <!-- Label for screen showing the active device admin apps -->
+    <string name="active_device_admin_msg">Device admin app</string>
+    <!-- Label for button to remove the active device admin app [CHAR LIMIT=80] -->
+    <string name="remove_device_admin">Deactivate this device admin app</string>
+    <!-- Label for button to uninstall the device admin app [CHAR LIMIT=80] -->
     <string name="uninstall_device_admin">Uninstall app</string>
-    <!-- Label for button to deactivate and uninstall the device admin [CHAR_LIMIT=50]-->
-    <string name="remove_and_uninstall_device_admin">Deactivate and Uninstall</string>
-    <!-- Label for screen showing to select device policy -->
-    <string name="select_device_admin_msg">Device administrators</string>
-    <!-- Message when there are no available device admins to display -->
-    <string name="no_device_admins">No available device administrators</string>
-    <!-- Message displayed when the device admin can only be disabled by deleting the work profile [CHAR_LIMIT=120] -->
-    <!-- Title for personal device admins on the list [CHAR_LIMIT=25] -->
+    <!-- Label for button to deactivate and uninstall the device admin app [CHAR_LIMIT=50]-->
+    <string name="remove_and_uninstall_device_admin">Deactivate &amp; uninstall</string>
+    <!-- Label for screen showing to select device admin apps -->
+    <string name="select_device_admin_msg">Device admin apps</string>
+    <!-- Message when there are no available device admin apps to display -->
+    <string name="no_device_admins">No device admin apps available</string>
+    <!-- Title for personal device admin apps on the list [CHAR_LIMIT=25] -->
     <string name="personal_device_admin_title">Personal</string>
-    <!-- Title for managed device admins on the list [CHAR_LIMIT=25] -->
+    <!-- Title for managed device admin apps on the list [CHAR_LIMIT=25] -->
     <string name="managed_device_admin_title">Work</string>
 
     <!-- Message when there are no available trust agents to display -->
     <string name="no_trust_agents">No available trust agents</string>
 
-    <!-- Label for screen showing to add device policy -->
-    <string name="add_device_admin_msg">Activate device administrator?</string>
+    <!-- Title for screen to add a device admin app [CHAR LIMIT=40] -->
+    <string name="add_device_admin_msg">Activate device admin app?</string>
     <!-- Label for button to set the active device admin [CHAR_LIMIT=80] -->
-    <string name="add_device_admin">Activate this device administrator</string>
+    <string name="add_device_admin">Activate this device admin app</string>
     <!-- Device admin add activity title -->
-    <string name="device_admin_add_title">Device administrator</string>
+    <string name="device_admin_add_title">Device admin</string>
     <!-- Device admin warning message about policies an admin can use -->
-    <string name="device_admin_warning">Activating this administrator will allow
+    <string name="device_admin_warning">Activating this admin app will allow
         the app <xliff:g id="app_name">%1$s</xliff:g> to perform the
         following operations:</string>
     <!-- Device admin warning message about policies an admin can use -->
-    <string name="device_admin_status">This administrator is active and allows
+    <string name="device_admin_status">This admin app is active and allows
         the app <xliff:g id="app_name">%1$s</xliff:g> to perform the
         following operations:</string>
 
     <!-- Title for screen to set a profile owner [CHAR LIMIT=40] -->
     <string name="profile_owner_add_title">Activate Profile Manager?</string>
     <!-- Warning when trying to add a profile owner admin after setup has completed. [CHAR LIMIT=none] -->
-    <string name="adding_profile_owner_warning">By proceeding, your User will be managed by your Administrator which may also be able to store associated data, in addition to your personal data.\n\nYour Administrator has the ability to monitor and manage settings, access, apps, and data associated with this User, including network activity and your device\u2019s location information.</string>
+    <string name="adding_profile_owner_warning">By proceeding, your user will be managed by your
+        admin which may also be able to store associated data, in addition to your personal
+        data.\n\nYour admin has the ability to monitor and manage settings, access, apps,
+        and data associated with this user, including network activity and your device\'s location
+        information.</string>
 
     <!-- Message displayed to let the user know that some of the options are disabled by admin. [CHAR LIMIT=NONE] -->
-    <string name="admin_disabled_other_options">Other options are disabled by your administrator.</string>
+    <string name="admin_disabled_other_options">Other options are disabled by your admin</string>
     <string name="admin_more_details">More details</string>
 
     <!-- Name to assign to a Network Access Point that was saved without a name -->
@@ -5150,7 +5292,7 @@
     <!-- Remove account message in dialog [CHAR LIMIT=NONE] -->
     <string name="really_remove_account_message" product="default">Removing this account will delete all of its messages, contacts, and other data from the phone!</string>
     <!-- This is shown if the autheticator for a given account fails to remove it. [CHAR LIMIT=NONE] -->
-    <string name="remove_account_failed">This change isn\u2019t allowed by your administrator</string>
+    <string name="remove_account_failed">This change isn\'t allowed by your admin</string>
     <!-- What to show in messaging that refers to this provider, e.g. AccountSyncSettings -->
     <string name="provider_label">Push subscriptions</string>
     <!-- Formatter in AccountSyncSettings for each application we wish to synchronize, e.g. "Sync Calendar" -->
@@ -5431,16 +5573,26 @@
     <string name="vpn_no_ca_cert">(don\u2019t verify server)</string>
     <!-- Option to use the server certificate received from the VPN server. [CHAR LIMIT=40] -->
     <string name="vpn_no_server_cert">(received from server)</string>
-    <!-- Reason for Always-on VPN checkbox being disabled: the selected VPN type doesn't support always-on. [CHAR LIMIT=120] -->
-    <string name="vpn_always_on_invalid_reason_type">The selected VPN type can\u2019t be always on</string>
-    <!-- Reason for Always-on VPN checkbox being disabled: the server address is invalid. [CHAR LIMIT=120] -->
-    <string name="vpn_always_on_invalid_reason_server">Always-on VPN only supports numeric server addresses</string>
-    <!-- Reason for Always-on VPN checkbox being disabled: no DNS is found. [CHAR LIMIT=120] -->
-    <string name="vpn_always_on_invalid_reason_no_dns">A DNS server must be specified for always-on VPN</string>
-    <!-- Reason for Always-on VPN checkbox being disabled: DNS server addresses are invalid. [CHAR LIMIT=120] -->
-    <string name="vpn_always_on_invalid_reason_dns">DNS server addresses must be numeric for always-on VPN</string>
-    <!-- Reason for Always-on VPN checkbox being disabled: generic reason. [CHAR LIMIT=120] -->
-    <string name="vpn_always_on_invalid_reason_other">The information entered doesn\u2019t support always-on VPN</string>
+    <!-- Error message displayed below the always-on VPN checkbox when the checkbox is disabled:
+        the selected VPN type doesn't support always-on. [CHAR LIMIT=120] -->
+    <string name="vpn_always_on_invalid_reason_type">This VPN type can\'t stay connected at all
+        times</string>
+    <!-- Error message displayed below the always-on VPN checkbox when the checkbox is disabled:
+        the server address is not in numeric form (e.g. 8.8.8.8). [CHAR LIMIT=120] -->
+    <string name="vpn_always_on_invalid_reason_server">Always-on VPN only supports numeric server
+        addresses</string>
+    <!-- Error message displayed below the always-on VPN checkbox when the checkbox is disabled:
+        no DNS is found. [CHAR LIMIT=120] -->
+    <string name="vpn_always_on_invalid_reason_no_dns">A DNS server must be specified for always-on
+        VPN</string>
+    <!-- Error message displayed below the always-on VPN checkbox when the checkbox is disabled:
+        DNS server addresses are not in numeric form (e.g. 8.8.8.8). [CHAR LIMIT=120] -->
+    <string name="vpn_always_on_invalid_reason_dns">DNS server addresses must be numeric for
+        always-on VPN</string>
+    <!-- Error message displayed below the always-on VPN checkbox when the checkbox is disabled:
+        generic error. [CHAR LIMIT=120] -->
+    <string name="vpn_always_on_invalid_reason_other">The information entered doesn\'t support
+        always-on VPN</string>
 
     <!-- Button label to cancel changing a VPN profile. [CHAR LIMIT=40] -->
     <string name="vpn_cancel">Cancel</string>
@@ -5459,7 +5611,7 @@
     <!-- Dialog title to connect to a VPN profile. [CHAR LIMIT=40] -->
     <string name="vpn_connect_to">Connect to <xliff:g id="profile" example="School">%s</xliff:g></string>
     <!-- Dialog message body to disconnect from a VPN profile. -->
-    <string name="vpn_disconnect_confirm">Disconnect this VPN.</string>
+    <string name="vpn_disconnect_confirm">Disconnect this VPN?</string>
     <!-- Button label to disconnect from a VPN profile. [CHAR LIMIT=40] -->
     <string name="vpn_disconnect">Disconnect</string>
     <!-- Field label to show the version number for a VPN app. [CHAR LIMIT=40] -->
@@ -5483,7 +5635,7 @@
     <!-- Dialog mesage title when the user can't connect an always-on vpn [CHAR LIMIT=NONE] -->
     <string name="vpn_cant_connect_title"><xliff:g id="vpn_name" example="OpenVPN">%1$s</xliff:g> can\'t connect</string>
     <!-- Dialog message subtitle when the user can't connect an always-on vpn [CHAR LIMIT=NONE] -->
-    <string name="vpn_cant_connect_message">This app doesn\'t support always-on VPN.</string>
+    <string name="vpn_cant_connect_message">This app doesn\'t support always-on VPN</string>
     <!-- Preference title for VPN settings. [CHAR LIMIT=40] -->
     <string name="vpn_title">VPN</string>
     <!-- Preference title to create a new VPN profile. [CHAR LIMIT=40] -->
@@ -5495,21 +5647,17 @@
     <!-- Menu item to select always-on VPN profile. [CHAR LIMIT=40] -->
     <string name="vpn_menu_lockdown">Always-on VPN</string>
     <!-- Placeholder when VPN settings is open but no VPNs have been created. [CHAR LIMIT=100] -->
-    <string name="vpn_no_vpns_added">No VPNs added.</string>
-    <!-- Preference summary for active always-on vpn [CHAR LIMIT=40] -->
-    <string name="vpn_always_on_active">Always-on active</string>
-    <!-- Preference summary for inactive always-on vpn [CHAR LIMIT=40] -->
-    <string name="vpn_always_on_inactive">Always-on inactive</string>
-    <!-- Preference summary for app not supporting always-on vpn [CHAR LIMIT=NONE] -->
-    <string name="vpn_not_supported_by_this_app">Not supported by this app</string>
-    <!-- Preference title for forcing all network connections to go through VPN. -->
-    <string name="vpn_require_connection">Only allow connections through VPN</string>
-    <!-- Dialog message title to confirm forcing all network connections to go through VPN. [CHAR LIMIT=40] -->
+    <string name="vpn_no_vpns_added">No VPNs added</string>
+    <!-- Preference summary for always-on VPN checkbox. [CHAR LIMIT=40] -->
+    <string name="vpn_always_on_summary">Stay connected to VPN at all times</string>
+    <!-- Preference summary for app not supporting always-on VPN [CHAR LIMIT=40] -->
+    <string name="vpn_always_on_summary_not_supported">Not supported by this app</string>
+    <!-- Preference title for the toggle that controls whether to force all network connections to
+        go through VPN. [CHAR LIMIT=40] -->
+    <string name="vpn_require_connection">Block connections without VPN</string>
+    <!-- Dialog message title to confirm forcing all network connections to go through VPN.
+        [CHAR LIMIT=40] -->
     <string name="vpn_require_connection_title">Require VPN connection?</string>
-    <!-- Preference summary when the preference to force all network connections to go through a VPN is enabled, blocking all other network traffic. In this case apps must use the VPN for all connections. -->
-    <string name="vpn_lockdown_active">Lockdown active</string>
-    <!-- Preference summary when the preference to force all network connections to go through a VPN is disabled. In this case use of the VPN is optional for apps. -->
-    <string name="vpn_lockdown_inactive">Lockdown inactive</string>
 
     <!-- Summary describing the always-on VPN feature. [CHAR LIMIT=NONE] -->
     <string name="vpn_lockdown_summary">Select a VPN profile to always remain connected to. Network traffic will only be allowed when connected to this VPN.</string>
@@ -5525,7 +5673,7 @@
     <!-- Seting subtext indicating the device is not currently connected to any VPN [CHAR LIMIT=40]-->
     <string name="vpn_disconnected_summary">None</string>
     <!-- Toast message when a certificate is missing. [CHAR LIMIT=100] -->
-    <string name="vpn_missing_cert">A certificate is missing. Please edit the profile.</string>
+    <string name="vpn_missing_cert">A certificate is missing. Try editing the profile.</string>
 
     <!-- Tab label for built-in system CA certificates. -->
     <string name="trusted_credentials_system_tab">System</string>
@@ -5557,9 +5705,11 @@
     <!-- Item found in thee PKCS12 keystore being investigated [CHAR LIMIT=NONE]-->
     <string name="n_cacrts">%d CA certificates</string>
     <!-- Alert dialog when viewing a set of user credentials. -->
-    <string name="user_credential_title">Credential Details</string>
+    <string name="user_credential_title">Credential details</string>
     <!-- Announcement to confirm a user credential being removed. [CHAR LIMIT=NONE] -->
     <string name="user_credential_removed">Removed credential: <xliff:g id="credential_name" example="signing key">%s</xliff:g></string>
+    <!-- Placeholder for the list of installed user credentials (private keys) when the list is empty. [CHAR LIMIT=120] -->
+    <string name="user_credential_none_installed">No user credentials installed</string>
 
     <!--  Title for spell checker settings -->
     <string name="spellcheckers_settings_title">Spell checker</string>
@@ -6253,9 +6403,6 @@
     <!-- Sound: Other sounds: Title for the option enabling boot sounds. [CHAR LIMIT=30] -->
     <string name="boot_sounds_title">Power on sounds</string>
 
-    <!-- Sound: Title for the Do not Disturb option and associated settings page. [CHAR LIMIT=50]-->
-    <string name="zen_mode_settings_title">Do Not Disturb preferences</string>
-
     <!-- Sound: Summary for the Do not Disturb option when there is no automatic rules turned on. [CHAR LIMIT=NONE]-->
     <string name="zen_mode_settings_summary_off">No automatic rules turned on</string>
 
@@ -6265,17 +6412,20 @@
         <item quantity="other"><xliff:g id="on_count" example="10">%d</xliff:g> automatic rules turned on</item>
     </plurals>
 
+    <!-- Sound: Title for the Do not Disturb option and associated settings page. [CHAR LIMIT=50]-->
+    <string name="zen_mode_settings_title">Do Not Disturb preferences</string>
+
     <!-- Do not disturb: Title for the Priority interruptions option and associated settings page. [CHAR LIMIT=30] -->
     <string name="zen_mode_priority_settings_title">Priority only allows</string>
 
-    <!--  Do not disturb: Title for the zen mode automation option and associated settings page. [CHAR LIMIT=30] -->
+    <!--  Do not disturb: Title for the zen mode automation listing. [CHAR LIMIT=30] -->
     <string name="zen_mode_automation_settings_title">Automatic rules</string>
 
     <!--  Do not disturb: Title for the zen mode automation option Suggestion. [CHAR LIMIT=30] -->
-    <string name="zen_mode_automation_suggestion_title">Set Do Not Disturb schedule</string>
+    <string name="zen_mode_automation_suggestion_title">Set Do Not Disturb rules</string>
 
     <!--  Do not disturb: Summary for the zen mode automation option Suggestion. [CHAR LIMIT=30] -->
-    <string name="zen_mode_automation_suggestion_summary">Silence your device at certain times</string>
+    <string name="zen_mode_automation_suggestion_summary">Limit sounds &amp; vibrations at certain times</string>
 
     <!--  Do not disturb: Zen mode option: Important interruptions [CHAR LIMIT=60] -->
     <string name="zen_mode_option_important_interruptions">Priority only</string>
@@ -6335,7 +6485,7 @@
     <string name="other_sound_category_preference_title">Other sounds and vibrations</string>
 
     <!-- Configure Notifications Settings title. [CHAR LIMIT=30] -->
-    <string name="configure_notification_settings">Notification preferences</string>
+    <string name="configure_notification_settings">Notifications</string>
 
     <!-- Configure Notifications: Advanced section header [CHAR LIMIT=30] -->
     <string name="advanced_section_header">Advanced</string>
@@ -6344,7 +6494,7 @@
     <string name="profile_section_header">Work notifications</string>
 
     <!-- Configure Notifications: Title for the pulse notification light option. [CHAR LIMIT=30] -->
-    <string name="notification_pulse_title">Pulse notification light</string>
+    <string name="notification_pulse_title">Blink light</string>
 
     <!-- Configure Notifications: Title for the option controlling notifications on the lockscreen. [CHAR LIMIT=30] -->
     <string name="lock_screen_notifications_title">On the lock screen</string>
@@ -6392,44 +6542,41 @@
     <!-- Notification Settings: Title for the option managing notifications per application. [CHAR LIMIT=30] -->
     <string name="app_notifications_title">Notifications</string>
 
-    <!-- Notification Settings: Summary for managing notifications when notifications is on for all apps. [CHAR LIMIT=60] -->
-    <string name="app_notifications_summary_on">On for all apps</string>
-
-    <!-- Notification Settings: Summary for managing notifications when notifications is off for some apps. [CHAR LIMIT=60] -->
-    <plurals name="app_notifications_summary_off">
-        <item quantity="one">Off for 1 app</item>
-        <item quantity="other">Off for <xliff:g id="off_count" example="10">%d</xliff:g> apps</item>
-    </plurals>
-
     <!-- [CHAR LIMIT=100] Notification importance slider title -->
     <string name="notification_importance_title">Importance</string>
 
-    <!-- [CHAR LIMIT=100] Notification Importance slider: unset importance level description -->
-    <string name="notification_importance_none">Not set</string>
-
-    <!-- [CHAR LIMIT=100] Notification Importance slider: unspecified importance level description -->
+    <!-- [CHAR LIMIT=100] Notification Importance: unspecified importance level description -->
     <string name="notification_importance_unspecified">Let the app decide</string>
 
-    <!-- [CHAR LIMIT=100] Notification Importance slider: blocked importance level description -->
+    <!-- [CHAR LIMIT=100] Notification Importance: blocked importance level description -->
     <string name="notification_importance_blocked">Never show notifications</string>
 
-    <!-- [CHAR LIMIT=100] Notification Importance slider: min importance level description -->
+    <!-- [CHAR LIMIT=100] Notification Importance: min importance level description -->
     <string name="notification_importance_min">No sound or visual interruption</string>
 
-    <!-- [CHAR LIMIT=100] Notification Importance slider: low importance level description -->
-    <string name="notification_importance_low">Show silently</string>
+    <!-- [CHAR LIMIT=100] Notification Importance: low importance level description -->
+    <string name="notification_importance_low">No sound</string>
 
-    <!-- [CHAR LIMIT=100] Notification Importance slider: normal importance level description -->
+    <!-- [CHAR LIMIT=100] Notification Importance: normal importance level description -->
     <string name="notification_importance_default">Make sound</string>
 
-    <!-- [CHAR LIMIT=100] Notification Importance slider: high importance level description -->
+    <!-- [CHAR LIMIT=100] Notification Importance: high importance level description -->
     <string name="notification_importance_high">Make sound and pop on screen</string>
 
-    <!-- [CHAR LIMIT=60] Notification importance reset button -->
-    <string name="importance_reset">Reset</string>
+    <!-- [CHAR LIMIT=100] Notification Importance summary: min importance level description -->
+    <string name="notification_importance_min_summary">Low: No sound or visual interruption</string>
+
+    <!-- [CHAR LIMIT=100] Notification Importance summary: low importance level description -->
+    <string name="notification_importance_low_summary">Medium: No sound</string>
+
+    <!-- [CHAR LIMIT=100] Notification Importance summary: normal importance level description -->
+    <string name="notification_importance_default_summary">High: Make sound</string>
+
+    <!-- [CHAR LIMIT=100] Notification Importance summary: high importance level description -->
+    <string name="notification_importance_high_summary">Urgent: Make sound and pop on screen</string>
 
     <!-- [CHAR LIMIT=40] Notification importance title -->
-    <string name="show_silently">Show silently</string>
+    <string name="allow_sound">Allow Sound</string>
 
     <!-- [CHAR LIMIT=180] Notification importance summary -->
     <string name="show_silently_summary">Don\'t make sound, vibrate, or peek these notifications into view on the current screen.</string>
@@ -6543,12 +6690,29 @@
     <!-- [CHAR LIMIT=NONE] App notification settings: link to app notification settings-->
     <string name="app_settings_link">Additional settings in the app</string>
 
+    <!-- [CHAR LIMIT=45] App notification listing summary, blocked apps -->
+    <string name="app_notification_listing_summary_zero">Turned on for all apps</string>
+    <!-- [CHAR LIMIT=45] App notification listing summary, blocked apps -->
+    <plurals name="app_notification_listing_summary_others">
+        <item quantity="one">Turned off for <xliff:g id="count" example="1">%d</xliff:g> app</item>
+        <item quantity="other">Turned off for <xliff:g id="count" example="10">%d</xliff:g> apps</item>
+    </plurals>
+
     <!-- [CHAR LIMIT=NONE] Footer listing a count of deleted channels. -->
     <plurals name="deleted_channels">
-        <item quantity="one">%d category deleted</item>
-        <item quantity="other">%d categories deleted</item>
+        <item quantity="one"><xliff:g id="count" example="1">%d</xliff:g> category deleted</item>
+        <item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> categories deleted</item>
     </plurals>
 
+    <!-- [CHAR LIMIT=45\ Global notification badge setting -->
+    <string name="notification_badges">Notification badges</string>
+
+    <!-- [CHAR LIMIT=NONE] App notification settings: notifications enabled-->
+    <string name="notification_toggle_on">On</string>
+
+    <!-- [CHAR LIMIT=NONE] App notification settings: notifications disabled-->
+    <string name="notification_toggle_off">Off</string>
+
     <!-- [CHAR LIMIT=NONE] App notification settings: Block option title -->
     <string name="app_notification_block_title">Block all</string>
 
@@ -6562,7 +6726,7 @@
     <string name="notification_content_block_summary">Never show notifications in the shade or on peripheral devices</string>
 
     <!-- [CHAR LIMIT=NONE] Channel notification settings: Badging option title -->
-    <string name="notification_badge_title">Show badge</string>
+    <string name="notification_badge_title">Badge app icon</string>
 
     <!-- [CHAR LIMIT=NONE] Channel notification settings: Badge option description-->
     <string name="notification_badge_summary">Show notifications as badges on the Home app, if supported.</string>
@@ -6592,10 +6756,19 @@
     <string name="app_notification_importance_title">Importance</string>
 
     <!-- [CHAR LIMIT=180] Notification settings: lights -->
-    <string name="notification_show_lights_title">Always pulse notification light</string>
+    <string name="notification_show_lights_title">Blink light</string>
 
     <!-- [CHAR LIMIT=180] Notification settings: vibration -->
-    <string name="notification_vibrate_title">Always vibrate</string>
+    <string name="notification_vibrate_title">Vibrate</string>
+
+    <!-- [CHAR LIMIT=180] Notification settings: sound -->
+    <string name="notification_channel_sound_title">Sound</string>
+
+    <!-- [CHAR LIMIT=40] Zen mode settings: Rule delete button -->
+    <string name="zen_mode_rule_delete_button">Delete</string>
+
+    <!-- [CHAR LIMIT=40] Zen mode settings: Rule name edit button -->
+    <string name="zen_mode_rule_rename_button">Rename</string>
 
     <!-- [CHAR LIMIT=40] Zen mode settings: Rule name option and edit dialog title -->
     <string name="zen_mode_rule_name">Rule name</string>
@@ -6607,7 +6780,7 @@
     <string name="zen_mode_rule_name_warning">Rule name already in use</string>
 
     <!-- [CHAR LIMIT=40] Zen mode settings: Add rule menu option name -->
-    <string name="zen_mode_add_rule">Add rule</string>
+    <string name="zen_mode_add_rule">Add more</string>
 
     <!-- [CHAR LIMIT=40] Zen mode settings: Delete rule menu option name -->
     <string name="zen_mode_delete_rule">Delete rule</string>
@@ -6824,7 +6997,7 @@
     <string name="oem_preferred_feedback_reporter" translatable="false"></string>
 
     <!-- PIN entry dialog title for entering the administrator PIN [CHAR LIMIT=none] -->
-    <string name="restr_pin_enter_admin_pin">Enter administrator PIN</string>
+    <string name="restr_pin_enter_admin_pin">Enter admin PIN</string>
 
     <!-- Switch On/Off  -->
     <string name="switch_on_text">On</string>
@@ -6964,11 +7137,13 @@
    <string name="change_storage">Change storage</string>
 
    <!-- Label for notification settings for an specific app [CHAR LIMIT=40] -->
-   <string name="notifications_label">Notifications</string>
-   <!-- App notification summary with notifications enabled [CHAR LIMIT=40] -->
-   <string name="notifications_enabled">Normal</string>
-   <!-- App notification summary with notifications disabled [CHAR LIMIT=40] -->
-   <string name="notifications_disabled">Blocked</string>
+     <string name="notifications_label">App notifications</string>
+    <!-- App notification summary with notifications enabled [CHAR LIMIT=40] -->
+    <string name="notifications_enabled">On</string>
+    <!-- Label for showing apps with blocked notifications in list [CHAR LIMIT=30] -->
+    <string name="notifications_disabled">Everything turned off</string>
+    <!-- Label for showing apps with some blocked notifications in list [CHAR LIMIT=30] -->
+    <string name="notifications_partly_blocked"><xliff:g id="count" example="1">%1$d</xliff:g> of <xliff:g id="count" example="10">%2$d</xliff:g> categories turned off</string>
     <!-- App notification summary with notifications silenced [CHAR LIMIT=40] -->
     <string name="notifications_silenced">Silenced</string>
     <!-- App notification summary with notifications redacted [CHAR LIMIT=70] -->
@@ -6981,12 +7156,15 @@
     <string name="notifications_summary_divider">\u00A0/\u00A0</string>
     <!-- App notification summary for advanced controls -->
     <string name="notification_summary_level">Level %d</string>
+    <!-- App notification summary channel divider-->
+    <string name="notification_summary_channel"><xliff:g id="channel_name">%1$s</xliff:g> \u2022 <xliff:g id="group_name">%2$s</xliff:g></string>
+
 
    <!-- Permissions preference summary [CHAR LIMIT=40] -->
-   <plurals name="permissions_summary">
+    <plurals name="permissions_summary">
        <item quantity="one"><xliff:g id="count" example="1">%d</xliff:g> permission granted</item>
        <item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> permissions granted</item>
-   </plurals>
+    </plurals>
 
    <!-- Runtime permissions preference summary [CHAR LIMIT=40] -->
    <plurals name="runtime_permissions_summary">
@@ -7016,8 +7194,19 @@
     <string name="filter_personal_apps">Personal</string>
     <!-- Label for showing work apps in list [CHAR LIMIT=30] -->
     <string name="filter_work_apps">Work</string>
+
     <!-- Label for showing apps with blocked notifications in list [CHAR LIMIT=30] -->
-    <string name="filter_notif_blocked_apps">Blocked</string>
+    <string name="filter_notif_all_apps">Apps: All</string>
+    <!-- Label for showing apps with blocked notifications in list [CHAR LIMIT=30] -->
+    <string name="filter_notif_blocked_apps">Apps: Turned off</string>
+    <!-- Label for showing categories with urgent notifications in list [CHAR LIMIT=30] -->
+    <string name="filter_notif_urgent_channels">Categories: Urgent importance</string>
+    <!-- Label for showing categories with low importance notifications in list [CHAR LIMIT=30] -->
+    <string name="filter_notif_low_channels">Categories: Low importance</string>
+    <!-- Label for showing categories with blocked notifications in list [CHAR LIMIT=30] -->
+    <string name="filter_notif_blocked_channels">Categories: Turned off</string>
+    <!-- Label for showing categories with notifications that override dnd in list [CHAR LIMIT=30] -->
+    <string name="filter_notif_dnd_channels">Categories: Overrides Do Not Disturb</string>
 
     <!-- Title for advanced application management settings [CHAR LIMIT=30] -->
     <string name="advanced_apps">Advanced</string>
@@ -7198,13 +7387,12 @@
     <string name="high_power_desc">Don\u2019t apply battery optimization. May drain your battery more quickly.</string>
 
     <!-- Title of prompt dialog app can invoke to turn off optimization [CHAR LIMIT=NONE] -->
-    <string name="high_power_prompt_title">Ignore battery optimizations?</string>
+    <string name="high_power_prompt_title">Let app always run in background?</string>
 
     <!-- Body text of prompt dialog app can invoke to turn off optimization [CHAR LIMIT=NONE] -->
-    <string name="high_power_prompt_body">Let app
-        <xliff:g id="app_name" example="Settings">%1$s</xliff:g> stay connected in the
-        background?  This may use more battery.</string>
-
+    <string name="high_power_prompt_body">
+        Allowing <xliff:g id="app_name" example="Settings">%1$s</xliff:g> to always run in the background may reduce battery life.
+        \n\nYou can change this later from Settings > Apps &amp; notifications.</string>
     <!-- Summary of power usage for an app [CHAR LIMIT=NONE] -->
     <string name="battery_summary"><xliff:g id="percentage" example="2">%1$d</xliff:g>%% use since last full charge</string>
 
@@ -7242,7 +7430,7 @@
     <!-- Title of one of the choices in a dialog (with title defined in usb_use) that lets the user
          select what the USB connection for this device should be used for. This choice
          is for charging only. -->
-    <string name="usb_use_charging_only">Charge this device</string>
+    <string name="usb_use_charging_only">Charging this device</string>
     <!-- Decription of one of the choices in a dialog (with title defined in usb_use) that lets the
          user select what the USB connection for this device should be used for. This choice
          is for charging only. -->
@@ -7250,7 +7438,7 @@
     <!-- Title of one of the choices in a dialog (with title defined in usb_use) that lets the user
          select what the USB connection for this device should be used for. This choice
          is for powering the other device only. -->
-    <string name="usb_use_power_only">Supply power</string>
+    <string name="usb_use_power_only">Supplying power</string>
     <!-- Decription of one of the choices in a dialog (with title defined in usb_use) that lets the
          user select what the USB connection for this device should be used for. This choice
          is for powering the other device. -->
@@ -7404,7 +7592,8 @@
     <string name="app_list_preference_none">None</string>
 
     <!-- Warning message about disabling usage access on profile owner [CHAR LIMIT=NONE] -->
-    <string name="work_profile_usage_access_warning">Turning off usage access for this app doesn\u2019t prevent your administrator tracking data usage for apps in your work profile.</string>
+    <string name="work_profile_usage_access_warning">Turning off usage access for this app doesn\'t
+        prevent your admin from tracking data usage for apps in your work profile</string>
 
     <!-- Number of characters used for lock screen text [CHAR LIMIT=NONE] -->
     <string name="accessibility_lock_screen_progress"><xliff:g id="count" example="1">%1$d</xliff:g> of <xliff:g id="count" example="1">%2$d</xliff:g> characters used</string>
@@ -7538,12 +7727,12 @@
 
     <!-- Summary of notifications [CHAR LIMIT=NONE] -->
     <plurals name="notification_summary">
-        <item quantity="one"><xliff:g id="count" example="1">%d</xliff:g> app blocked from sending</item>
-        <item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> apps blocked from sending</item>
+        <item quantity="one">Off for 1 app</item>
+        <item quantity="other">Off for <xliff:g id="count" example="10">%d</xliff:g> apps</item>
     </plurals>
 
     <!-- Summary of notifications when no apps are blocked [CHAR LIMIT=NONE] -->
-    <string name="notification_summary_none">All apps allowed to send</string>
+    <string name="notification_summary_none">On for all apps</string>
 
     <!-- Summary of apps [CHAR LIMIT=NONE] -->
     <string name="apps_summary"><xliff:g id="count" example="24">%1$d</xliff:g> apps installed</string>
@@ -7551,7 +7740,10 @@
     <string name="apps_summary_example">24 apps installed</string>
 
     <!-- Summary of storage usage [CHAR LIMIT=NONE] -->
-    <string name="storage_summary">Internal storage: <xliff:g id="percentage" example="54%">%1$s</xliff:g> used - <xliff:g id="free_space" example="32GB">%2$s</xliff:g> free</string>
+    <string name="storage_summary"><xliff:g id="percentage" example="54%">%1$s</xliff:g> used - <xliff:g id="free_space" example="32GB">%2$s</xliff:g> free</string>
+
+    <!-- Summary of storage usage when there is SD card [CHAR LIMIT=NONE] -->
+    <string name="storage_summary_with_sdcard">Internal storage: <xliff:g id="percentage" example="54%">%1$s</xliff:g> used - <xliff:g id="free_space" example="32GB">%2$s</xliff:g> free</string>
 
     <!-- Summary of display with screen sleep timeout [CHAR LIMIT=NONE] -->
     <string name="display_summary">Sleep after <xliff:g id="timeout_description" example="10 minutes">%1$s</xliff:g> of inactivity</string>
@@ -7597,15 +7789,22 @@
     <!-- Title for dialog displayed to tell user that screenshots are disabled by an admin [CHAR LIMIT=50] -->
     <string name="disabled_by_policy_title_screen_capture">Screenshot not allowed</string>
     <!-- Shown when the user tries to change a settings locked by an admin [CHAR LIMIT=200] -->
-    <string name="default_admin_support_msg">This action is disabled. Contact your organization\'s administrator to learn more.</string>
+    <string name="default_admin_support_msg">This action is disabled. To learn more, contact your
+        organization\'s admin.</string>
     <!-- Shown in dialog to allow user to see more information about the device admin [CHAR LIMIT=30] -->
     <string name="admin_support_more_info">More details</string>
     <!-- Shown in admin details page to warn user about policies the admin can set in a work profile. [CHAR LIMIT=NONE] -->
-    <string name="admin_profile_owner_message">Your administrator can monitor and manage apps and data associated with your work profile, including settings, permissions, corporate access, network activity, and the device\'s location information.</string>
+    <string name="admin_profile_owner_message">Your admin can monitor and manage apps and data
+        associated with your work profile, including settings, permissions, corporate access,
+        network activity, and the device\'s location information.</string>
     <!-- Shown in admin details page to warn user about policies the admin can set on a user. [CHAR LIMIT=NONE] -->
-    <string name="admin_profile_owner_user_message">Your administrator can monitor and manage apps and data associated with this user, including settings, permissions, corporate access, network activity, and the device\'s location information.</string>
+    <string name="admin_profile_owner_user_message">Your admin can monitor and manage apps and data
+        associated with this user, including settings, permissions, corporate access,
+        network activity, and the device\'s location information.</string>
     <!-- Shown in admin details page to warn user about policies the admin can set on a device. [CHAR LIMIT=NONE] -->
-    <string name="admin_device_owner_message">Your administrator can monitor and manage apps and data associated with this device, including settings, permissions, corporate access, network activity, and the device\'s location information.</string>
+    <string name="admin_device_owner_message">Your admin can monitor and manage apps and data
+        associated with this device, including settings, permissions, corporate access,
+        network activity, and the device\'s location information.</string>
 
     <!-- Turn off a conditional state of the device (e.g. airplane mode, or hotspot) [CHAR LIMIT=30] -->
     <string name="condition_turn_off">Turn off</string>
@@ -7658,10 +7857,16 @@
     <!-- Summary of condition that work mode is off [CHAR LIMIT=NONE] -->
     <string name="condition_work_summary">Apps, background sync, and other features related to your work profile are turned off.</string>
 
-    <!-- Title of condition that night display is on (renamed "Night Light" with title caps) [CHAR LIMIT=30] -->
-    <string name="condition_night_display_title">Night Light is on</string>
+    <!--  Night display: Title for the night display option Suggestion. [CHAR LIMIT=NONE] -->
+    <string name="night_display_suggestion_title">Set night display schedule</string>
 
-    <!-- Summary of condition that night display is on (renamed "Night Light" with title caps) [CHAR LIMIT=NONE] -->
+    <!--  Night display: Summary for the night display option Suggestion. [CHAR LIMIT=30] -->
+    <string name="night_display_suggestion_summary">Tint screen amber to help you fall asleep</string>
+
+    <!-- Title of condition that night display is on [CHAR LIMIT=30] -->
+    <string name="condition_night_display_title">Night display is on</string>
+
+    <!-- Summary of condition that night display is on [CHAR LIMIT=NONE] -->
     <string name="condition_night_display_summary">Screen is tinted amber. This may help you fall asleep.</string>
 
     <!-- Title for the suggestions section on the dashboard [CHAR LIMIT=30] -->
@@ -7913,7 +8118,13 @@
     <string name="notification_log_details_ranking_none">Ranking object doesn\'t contain this key.</string>
 
     <!-- [CHAR_LIMIT=60] Label for special access screen -->
-    <string name="special_access">Special access</string>
+    <string name="special_access">Special app access</string>
+
+    <!-- Summary for special access settings [CHAR_LIMIT=NONE] -->
+    <plurals name="special_access_summary">
+        <item quantity="one">1 app can use unrestricted data</item>
+        <item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> apps can use unrestricted data</item>
+    </plurals>
 
     <!-- Developer option to convert to file encryption - final warning -->
     <string name="confirm_convert_to_fbe_warning">Really wipe user data and convert to file encryption?</string>
@@ -7953,9 +8164,12 @@
     <!-- Title of screen controlling which apps have access to send premium SMS messages [CHAR LIMIT=60] -->
     <string name="premium_sms_access">Premium SMS access</string>
 
-    <!-- Bluetooth is disabled. -->
+    <!-- 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>
+
     <!-- [CHAR LIMIT=60] Name of dev option called "System UI demo mode" -->
     <string name="demo_mode">System UI demo mode</string>
 
@@ -8253,9 +8467,9 @@
     <!-- Label explaining that the admin can see apps installed on the device. [CHAR LIMIT=NONE] -->
     <string name="enterprise_privacy_installed_packages">List of apps on your device</string>
     <!-- Label explaining that the admin can see app usage statistics. [CHAR LIMIT=NONE] -->
-    <string name="enterprise_privacy_usage_stats">Time and data spent in each app on your device</string>
+    <string name="enterprise_privacy_usage_stats">Amount of time and data spent in each app</string>
     <!-- Label explaining that the admin can retrieve network logs on the device. [CHAR LIMIT=NONE] -->
-    <string name="enterprise_privacy_network_logs">Network traffic logs on your device</string>
+    <string name="enterprise_privacy_network_logs">Most recent network traffic log</string>
     <!-- Label explaining that the admin can request bug reports on the device. [CHAR LIMIT=NONE] -->
     <string name="enterprise_privacy_bug_reports">Most recent bug report</string>
     <!-- Label explaining that the admin can retrieve security on from the device. [CHAR LIMIT=NONE] -->
@@ -8264,6 +8478,8 @@
     <string name="enterprise_privacy_none">None</string>
     <!-- Label indicating that the admin installed one or more apps on the device. -->
     <string name="enterprise_privacy_enterprise_installed_packages">Apps installed</string>
+    <!-- Label explaining that the the number of apps is an estimation. [CHAR LIMIT=NONE] -->
+    <string name="enterprise_privacy_apps_count_estimation_info">Number of apps is estimated. It may not include apps installed outside of the Play Store.</string>
     <!-- Summary indicating the number of apps that a label (e.g. installed apps or apps granted a particular permission) refers to. The number shown is a minimum as there may be additional apps we do not know about. [CHAR LIMIT=NONE] -->
     <plurals name="enterprise_privacy_number_packages_lower_bound">
         <item quantity="one">Minimum <xliff:g id="count">%d</xliff:g> app</item>
@@ -8323,6 +8539,33 @@
     <!-- Message indicating that the device is enterprise-managed: Link to learn more about what a Device Owner app can do [CHAR LIMIT=NONE] -->
     <string name="do_disclosure_learn_more">Learn more</string>
 
+    <!-- Strings for displaying which applications were set as default for specific actions. -->
+    <!-- Title for the apps that have been set as default handlers of camera-related intents. [CHAR LIMIT=30] -->
+    <plurals name="default_camera_app_title">
+        <item quantity="one">Camera app</item>
+        <item quantity="other">Camera apps</item>
+    </plurals>
+    <!-- Title for the app that has been set as default handler of calendar-related intents. [CHAR LIMIT=30] -->
+    <string name="default_calendar_app_title">Calendar app</string>
+    <!-- Title for the app that has been set as default handler of contacts-related intents. [CHAR LIMIT=30] -->
+    <string name="default_contacts_app_title">Contacts app</string>
+    <!-- Title for the apps that have been set as default handlers of new email intents. [CHAR LIMIT=30] -->
+    <plurals name="default_email_app_title">
+        <item quantity="one">Email client app</item>
+        <item quantity="other">Email client apps</item>
+    </plurals>
+    <!-- Title for the app that has been set as default handler of geo-related intents. [CHAR LIMIT=30] -->
+    <string name="default_map_app_title">Map app</string>
+    <!-- Title for the apps that have been set as default handlers of call-related intents. [CHAR LIMIT=30] -->
+    <plurals name="default_phone_app_title">
+        <item quantity="one">Phone app</item>
+        <item quantity="other">Phone apps</item>
+    </plurals>
+    <!-- Template for concatenating two app names -->
+    <string name="app_names_concatenation_template_2"><xliff:g id="first_app_name">%1$s</xliff:g>, <xliff:g id="second_app_name">%2$s</xliff:g></string>
+    <!-- Template for concatenating three app names -->
+    <string name="app_names_concatenation_template_3"><xliff:g id="first_app_name">%1$s</xliff:g>, <xliff:g id="second_app_name">%2$s</xliff:g>, <xliff:g id="third_app_name">%3$s</xliff:g></string>
+
     <!-- Preference label for the Photos & Videos storage section. [CHAR LIMIT=50] -->
     <string name="storage_photos_videos">Photos &amp; videos</string>
 
@@ -8393,4 +8636,10 @@
     <!-- Warning for when the automatic storage manager is turned off. [CHAR LIMIT=NONE] -->
     <string name="automatic_storage_manager_deactivation_warning">Turn off the storage manager?</string>
 
+    <!-- Preference label for the Movies & TV apps section [CHAR LIMIT=50] -->
+    <string name="storage_movies_tv">Movie &amp; TV apps</string>
+
+    <!-- Title for the installed app info storage page. The total storage space taken up by this app. [CHAR LIMIT=40]-->
+    <string name="app_info_storage_title">Space used</string>
+
 </resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 0cb2249..e9d25ff 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -319,22 +319,6 @@
         <item name="android:textSize">14sp</item>
     </style>
 
-    <style name="TextAppearance.FingerprintMessage"
-        parent="android:TextAppearance.Material.Subhead">
-        <item name="android:lineSpacingExtra">@dimen/suw_description_line_spacing_extra</item>
-    </style>
-
-    <style name="Button.FingerprintButton"
-        parent="android:Widget.Material.Button.Borderless">
-        <item name="android:lineSpacingExtra">@dimen/suw_description_line_spacing_extra</item>
-        <item name="android:textColor">?android:attr/colorAccent</item>
-    </style>
-
-    <style name="TextAppearance.FingerprintLink"
-           parent="TextAppearance.FingerprintMessage">
-        <item name="android:textColor">?android:attr/colorAccent</item>
-    </style>
-
     <style name="TextAppearance.FingerprintErrorText"
         parent="android:TextAppearance.Material.Body1">
         <item name="android:textColor">?android:attr/colorError</item>
diff --git a/res/xml/accessibility_magnification_settings.xml b/res/xml/accessibility_magnification_settings.xml
new file mode 100644
index 0000000..0f3c119
--- /dev/null
+++ b/res/xml/accessibility_magnification_settings.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:title="@string/accessibility_screen_magnification_title">
+    <Preference
+        android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
+        android:key="screen_magnification_gestures_preference_screen"
+        android:title="@string/accessibility_screen_magnification_gestures_title"/>
+    <Preference
+        android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
+        android:key="screen_magnification_navbar_preference_screen"
+        android:title="@string/accessibility_screen_magnification_navbar_title"/>
+</PreferenceScreen>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 5c67d6e..48e11af 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -18,8 +18,9 @@
         android:title="@string/accessibility_settings"
         android:persistent="true">
 
-    <ListPreference
+    <Preference
             android:key="accessibility_shortcut_preference"
+            android:fragment="com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment"
             android:title="@string/accessibility_global_gesture_preference_title"/>
 
     <PreferenceCategory
@@ -51,9 +52,9 @@
                 android:title="@string/screen_zoom_title"/>
 
         <Preference
-                android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
-                android:key="screen_magnification_preference_screen"
-                android:title="@string/accessibility_screen_magnification_title" />
+            android:fragment="com.android.settings.accessibility.MagnificationPreferenceFragment"
+            android:key="magnification_preference_screen"
+            android:title="@string/accessibility_screen_magnification_title"/>
 
         <Preference
                 android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
diff --git a/res/xml/accessibility_settings_for_setup_wizard.xml b/res/xml/accessibility_settings_for_setup_wizard.xml
index 42b137b..c1141ab 100644
--- a/res/xml/accessibility_settings_for_setup_wizard.xml
+++ b/res/xml/accessibility_settings_for_setup_wizard.xml
@@ -26,10 +26,10 @@
 
     <Preference
         android:fragment=
-                "com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragmentForSetupWizard"
+                "com.android.settings.accessibility.MagnificationPreferenceFragment"
         android:key="screen_magnification_preference"
         android:title="@string/accessibility_screen_magnification_title"
-        android:summary="@string/accessibility_screen_magnification_short_summary" />
+        android:summary="@string/accessibility_preference_magnification_summary" />
 
     <Preference
         android:fragment=
diff --git a/res/xml/accessibility_shortcut_settings.xml b/res/xml/accessibility_shortcut_settings.xml
new file mode 100644
index 0000000..1245050
--- /dev/null
+++ b/res/xml/accessibility_shortcut_settings.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:title="@string/accessibility_global_gesture_preference_title" >
+
+    <Preference
+            android:key="accessibility_shortcut_service"
+            android:title="@string/accessibility_shortcut_service_title"
+            android:fragment="com.android.settings.accessibility.ShortcutServicePickerFragment"/>
+
+    <SwitchPreference
+            android:key="accessibility_shortcut_on_lock_screen"
+            android:title="@string/accessibility_shortcut_service_on_lock_screen_title"/>
+</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index b4ab7df..71825b1 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -14,115 +14,116 @@
      limitations under the License.
 -->
 
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-                  xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
-        android:title="@string/display_settings"
-        settings:keywords="@string/keywords_display">
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+    android:title="@string/display_settings"
+    settings:keywords="@string/keywords_display">
 
-        <Preference
-                android:key="brightness"
-                android:title="@string/brightness"
-                settings:keywords="@string/keywords_display_brightness_level">
-            <intent android:action="android.intent.action.SHOW_BRIGHTNESS_DIALOG" />
-        </Preference>
+    <Preference
+        android:key="brightness"
+        android:title="@string/brightness"
+        settings:keywords="@string/keywords_display_brightness_level">
+        <intent android:action="com.android.intent.action.SHOW_BRIGHTNESS_DIALOG" />
+    </Preference>
 
-        <com.android.settingslib.RestrictedPreference
-            android:key="wallpaper"
-            android:title="@string/wallpaper_settings_title"
-            settings:keywords="@string/keywords_display_wallpaper"
-            settings:useAdminDisabledSummary="true" >
-                <intent
-                    android:targetPackage="@string/config_wallpaper_picker_package"
-                    android:targetClass="@string/config_wallpaper_picker_class" />
-        </com.android.settingslib.RestrictedPreference>
+    <com.android.settingslib.RestrictedPreference
+        android:key="wallpaper"
+        android:title="@string/wallpaper_settings_title"
+        settings:keywords="@string/keywords_display_wallpaper"
+        settings:useAdminDisabledSummary="true">
+        <intent
+            android:targetPackage="@string/config_wallpaper_picker_package"
+            android:targetClass="@string/config_wallpaper_picker_class" />
+    </com.android.settingslib.RestrictedPreference>
 
-        <com.android.settings.display.NightDisplayPreference
-            android:key="night_display"
-            android:title="@string/night_display_title"
-            android:fragment="com.android.settings.display.NightDisplaySettings"
-            settings:widgetLayout="@null"
-            settings:keywords="@string/keywords_display_night_display" />
+    <com.android.settings.display.NightDisplayPreference
+        android:key="night_display"
+        android:title="@string/night_display_title"
+        android:fragment="com.android.settings.display.NightDisplaySettings"
+        settings:widgetLayout="@null"
+        settings:keywords="@string/keywords_display_night_display" />
 
-        <com.android.settings.TimeoutListPreference
-            android:key="screen_timeout"
-            android:title="@string/screen_timeout"
-            android:summary="@string/screen_timeout_summary"
-            android:entries="@array/screen_timeout_entries"
-            android:entryValues="@array/screen_timeout_values" />
+    <com.android.settings.TimeoutListPreference
+        android:key="screen_timeout"
+        android:title="@string/screen_timeout"
+        android:summary="@string/screen_timeout_summary"
+        android:entries="@array/screen_timeout_entries"
+        android:entryValues="@array/screen_timeout_values" />
 
-        <DropDownPreference
-            android:key="auto_rotate"
-            android:summary="%s"
-            android:title="@string/display_auto_rotate_title" />
+    <DropDownPreference
+        android:key="auto_rotate"
+        android:summary="%s"
+        android:title="@string/display_auto_rotate_title" />
 
-        <SwitchPreference
-            android:key="auto_brightness"
-            android:title="@string/auto_brightness_title"
-            settings:keywords="@string/keywords_display_auto_brightness"
-            android:summary="@string/auto_brightness_summary" />
+    <SwitchPreference
+        android:key="auto_brightness"
+        android:title="@string/auto_brightness_title"
+        settings:keywords="@string/keywords_display_auto_brightness"
+        android:summary="@string/auto_brightness_summary" />
 
-        <Preference
-            android:key="font_size"
-            android:title="@string/title_font_size"
-            android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
-            settings:keywords="@string/keywords_display_font_size" />
+    <Preference
+        android:key="font_size"
+        android:title="@string/title_font_size"
+        android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
+        settings:keywords="@string/keywords_display_font_size" />
 
-        <com.android.settings.display.ScreenZoomPreference
-            android:key="screen_zoom"
-            android:title="@string/screen_zoom_title"
-            settings:keywords="@string/screen_zoom_keywords" />
+    <com.android.settings.display.ScreenZoomPreference
+        android:key="screen_zoom"
+        android:title="@string/screen_zoom_title"
+        settings:keywords="@string/screen_zoom_keywords" />
 
-        <Preference
-            android:key="screensaver"
-            android:title="@string/screensaver_settings_title"
-            android:fragment="com.android.settings.DreamSettings" />
+    <Preference
+        android:key="screensaver"
+        android:title="@string/screensaver_settings_title"
+        android:fragment="com.android.settings.DreamSettings" />
 
-        <!-- Hide night mode for now
-        <ListPreference
-            android:key="night_mode"
-            android:title="@string/night_mode_title"
-            settings:keywords="@string/keywords_display_night_mode"
-            android:summary="@string/night_mode_summary"
-            android:entries="@array/night_mode_entries"
-            android:entryValues="@array/night_mode_values" /> -->
+    <!-- Hide night mode for now
+    <ListPreference
+        android:key="night_mode"
+        android:title="@string/night_mode_title"
+        settings:keywords="@string/keywords_display_night_mode"
+        android:summary="@string/night_mode_summary"
+        android:entries="@array/night_mode_entries"
+        android:entryValues="@array/night_mode_values" /> -->
 
-        <SwitchPreference
-            android:key="camera_gesture"
-            android:title="@string/camera_gesture_title"
-            android:summary="@string/camera_gesture_desc" />
+    <SwitchPreference
+        android:key="camera_gesture"
+        android:title="@string/camera_gesture_title"
+        android:summary="@string/camera_gesture_desc" />
 
-        <SwitchPreference
-            android:key="lift_to_wake"
-            android:title="@string/lift_to_wake_title" />
+    <SwitchPreference
+        android:key="lift_to_wake"
+        android:title="@string/lift_to_wake_title" />
 
-        <Preference
-            android:key="gesture_double_tap_screen"
-            android:title="@string/ambient_display_title"
-            android:fragment="com.android.settings.gestures.DoubleTapScreenSettings"/>
+    <Preference
+        android:key="gesture_double_tap_screen"
+        android:title="@string/ambient_display_title"
+        android:fragment="com.android.settings.gestures.DoubleTapScreenSettings" />
 
-        <Preference
-            android:key="gesture_pick_up"
-            android:title="@string/ambient_display_pickup_title"
-            android:fragment="com.android.settings.gestures.PickupGestureSettings"/>
+    <Preference
+        android:key="gesture_pick_up"
+        android:title="@string/ambient_display_pickup_title"
+        android:fragment="com.android.settings.gestures.PickupGestureSettings" />
 
-        <SwitchPreference
-            android:key="doze"
-            android:title="@string/doze_title"
-            android:summary="@string/doze_summary" />
+    <SwitchPreference
+        android:key="doze"
+        android:title="@string/doze_title"
+        android:summary="@string/doze_summary" />
 
-        <SwitchPreference
-            android:key="tap_to_wake"
-            android:title="@string/tap_to_wake"
-            android:summary="@string/tap_to_wake_summary" />
+    <SwitchPreference
+        android:key="tap_to_wake"
+        android:title="@string/tap_to_wake"
+        android:summary="@string/tap_to_wake_summary" />
 
-        <ListPreference
-            android:key="theme"
-            android:title="@string/device_theme"
-            android:summary="%s" />
+    <ListPreference
+        android:key="theme"
+        android:title="@string/device_theme"
+        android:summary="%s" />
 
-        <DropDownPreference
-            android:key="vr_display_pref"
-            android:summary="%s"
-            android:title="@string/display_vr_pref_title" />
+    <Preference
+        android:key="vr_display_pref"
+        android:title="@string/display_vr_pref_title"
+        android:fragment="com.android.settings.display.VrDisplayPreferencePicker" />
 
 </PreferenceScreen>
diff --git a/res/xml/enterprise_privacy_settings.xml b/res/xml/enterprise_privacy_settings.xml
index e6246c2..aee897d 100644
--- a/res/xml/enterprise_privacy_settings.xml
+++ b/res/xml/enterprise_privacy_settings.xml
@@ -27,21 +27,19 @@
 
     <PreferenceCategory android:title="@string/enterprise_privacy_exposure_category">
         <com.android.settings.DividerPreference
-                android:key="enterprise_data"
                 android:layout_height="wrap_content"
                 android:title="@string/enterprise_privacy_enterprise_data"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
-                android:key="installed_packages"
                 android:title="@string/enterprise_privacy_installed_packages"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
-                android:key="usage_stats"
                 android:title="@string/enterprise_privacy_usage_stats"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
                 android:key="network_logs"
                 android:title="@string/enterprise_privacy_network_logs"
+                android:visibility="gone"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
                 android:key="bug_reports"
@@ -50,6 +48,7 @@
         <com.android.settings.DividerPreference
                 android:key="security_logs"
                 android:title="@string/enterprise_privacy_security_logs"
+                android:visibility="gone"
                 settings:multiLine="true"/>
     </PreferenceCategory>
 
@@ -57,58 +56,70 @@
         <com.android.settings.DividerPreference
                 android:key="number_enterprise_installed_packages"
                 android:title="@string/enterprise_privacy_enterprise_installed_packages"
+                android:visibility="gone"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
                 android:key="enterprise_privacy_number_location_access_packages"
                 android:title="@string/enterprise_privacy_location_access"
+                android:visibility="gone"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
                 android:key="enterprise_privacy_number_microphone_access_packages"
                 android:title="@string/enterprise_privacy_microphone_access"
+                android:visibility="gone"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
                 android:key="enterprise_privacy_number_camera_access_packages"
                 android:title="@string/enterprise_privacy_camera_access"
+                android:visibility="gone"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
                 android:key="number_enterprise_set_default_apps"
                 android:title="@string/enterprise_privacy_enterprise_set_default_apps"
+                android:visibility="gone"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
                 android:key="always_on_vpn_primary_user"
+                android:visibility="gone"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
                 android:key="always_on_vpn_managed_profile"
                 android:title="@string/enterprise_privacy_always_on_vpn_work"
+                android:visibility="gone"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
                 android:key="input_method"
                 android:title="@string/enterprise_privacy_input_method"
+                android:visibility="gone"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
                 android:key="global_http_proxy"
                 android:title="@string/enterprise_privacy_global_http_proxy"
+                android:visibility="gone"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
                 android:key="ca_certs"
                 android:title="@string/enterprise_privacy_ca_certs"
+                android:visibility="gone"
                 settings:multiLine="true"/>
     </PreferenceCategory>
 
     <PreferenceCategory android:title="@string/enterprise_privacy_device_access_category">
         <com.android.settings.DividerPreference
-                android:key="lock_device"
                 android:title="@string/enterprise_privacy_lock_device"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
-                android:key="wipe_device"
                 android:title="@string/enterprise_privacy_wipe_device"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
                 android:key="failed_password_wipe_primary_user"
+                android:title="@string/enterprise_privacy_failed_password_wipe_device"
+                android:visibility="gone"
                 settings:multiLine="true"/>
         <com.android.settings.DividerPreference
                 android:key="failed_password_wipe_managed_profile"
+                android:title="@string/enterprise_privacy_failed_password_wipe_work"
+                android:visibility="gone"
                 settings:multiLine="true"/>
     </PreferenceCategory>
 </PreferenceScreen>
diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml
index 79f441f..17bd576 100644
--- a/res/xml/language_and_input.xml
+++ b/res/xml/language_and_input.xml
@@ -28,10 +28,13 @@
     <PreferenceCategory
         android:title="@string/keyboard_and_input_methods_category">
         <Preference
+            android:key="virtual_keyboard_pref"
             android:title="@string/virtual_keyboard_category"
             android:fragment="com.android.settings.inputmethod.VirtualKeyboardFragment"/>
         <Preference
+            android:key="physical_keyboard_pref"
             android:title="@string/physical_keyboard_title"
+            android:summary="@string/summary_placeholder"
             android:fragment="com.android.settings.inputmethod.PhysicalKeyboardFragment"/>
     </PreferenceCategory>
 
diff --git a/res/xml/power_usage_detail_ia.xml b/res/xml/power_usage_detail_ia.xml
new file mode 100644
index 0000000..cfaa712
--- /dev/null
+++ b/res/xml/power_usage_detail_ia.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2017 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <com.android.settings.applications.LayoutPreference
+        android:key="header_view"
+        android:layout="@layout/app_details"
+        android:selectable="false"
+        android:order="-10000"/>
+
+    <com.android.settings.applications.LayoutPreference
+        android:key="action_buttons"
+        android:layout="@layout/app_action_buttons"
+        android:selectable="false"
+        android:order="-9999"/>
+
+    <PreferenceCategory
+        android:title="@string/battery_detail_info_title">
+
+        <Preference
+            android:key="app_usage_foreground"
+            android:title="@string/battery_detail_foreground"/>
+
+        <Preference
+            android:key="app_usage_background"
+            android:title="@string/battery_detail_background"/>
+
+        <Preference
+            android:key="app_power_usage"
+            android:title="@string/battery_detail_power_usage"/>
+
+    </PreferenceCategory>
+
+    <PreferenceCategory
+        android:title="@string/battery_detail_manage_title">
+
+        <SwitchPreference
+            android:key="background_activity"
+            android:title="@string/background_activity_title"
+            android:selectable="true"/>
+
+        <Preference
+            android:key="battery_optimization"
+            android:title="@string/battery_detail_background"
+            android:summary="@string/high_power_off"
+            android:selectable="true"/>
+
+    </PreferenceCategory>
+
+</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/reset_dashboard_fragment.xml b/res/xml/reset_dashboard_fragment.xml
new file mode 100644
index 0000000..02328af
--- /dev/null
+++ b/res/xml/reset_dashboard_fragment.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2017 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+    android:title="@string/reset_dashboard_title">
+
+    <!-- Network reset -->
+    <Preference
+        android:key="network_reset_pref"
+        android:title="@string/reset_network_title"
+        android:fragment="com.android.settings.ResetNetwork" />
+
+    <!-- Reset app preferences -->
+    <Preference
+        android:key="reset_app_prefs"
+        android:title="@string/reset_app_preferences" />
+
+    <!-- Factory reset -->
+    <com.android.settingslib.RestrictedPreference
+        android:key="factory_reset"
+        android:title="@string/master_clear_title"
+        android:summary="@string/master_clear_summary"
+        settings:keywords="@string/keywords_factory_data_reset"
+        settings:userRestriction="no_factory_reset"
+        settings:useAdminDisabledSummary="true"
+        android:fragment="com.android.settings.MasterClear" />
+</PreferenceScreen>
diff --git a/res/xml/security_settings_password_sub.xml b/res/xml/security_settings_password_sub.xml
index 25d00bc..46c4999 100644
--- a/res/xml/security_settings_password_sub.xml
+++ b/res/xml/security_settings_password_sub.xml
@@ -15,25 +15,24 @@
   ~ limitations under the License
   -->
 
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-                  xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
-                  android:title="@string/settings_label">
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:title="@string/settings_label">
 
-        <com.android.settings.TimeoutListPreference
-                android:key="lock_after_timeout"
-                android:title="@string/lock_after_timeout"
-                android:summary="@string/lock_after_timeout_summary"
-                android:entries="@array/lock_after_timeout_entries"
-                android:entryValues="@array/lock_after_timeout_values" />
+    <com.android.settings.TimeoutListPreference
+        android:key="lock_after_timeout"
+        android:title="@string/lock_after_timeout"
+        android:summary="@string/lock_after_timeout_summary"
+        android:entries="@array/lock_after_timeout_entries"
+        android:entryValues="@array/lock_after_timeout_values" />
 
-        <SwitchPreference
-                android:key="power_button_instantly_locks"
-                android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
+    <SwitchPreference
+        android:key="power_button_instantly_locks"
+        android:title="@string/lockpattern_settings_enable_power_button_instantly_locks" />
 
-        <com.android.settings.SingleLineSummaryPreference
-                android:key="owner_info_settings"
-                android:title="@string/owner_info_settings_title"
-                android:summary="@string/owner_info_settings_summary"/>
-
+    <com.android.settingslib.RestrictedPreference
+        android:key="owner_info_settings"
+        android:title="@string/owner_info_settings_title"
+        android:summary="@string/owner_info_settings_summary" />
 
 </PreferenceScreen>
diff --git a/res/xml/security_settings_pattern_sub.xml b/res/xml/security_settings_pattern_sub.xml
index dcc1b64..f0a7c9b 100644
--- a/res/xml/security_settings_pattern_sub.xml
+++ b/res/xml/security_settings_pattern_sub.xml
@@ -15,29 +15,28 @@
   ~ limitations under the License
   -->
 
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-                  xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
-                  android:title="@string/settings_label">
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:title="@string/settings_label">
 
-        <SwitchPreference
-                android:key="visiblepattern"
-                android:title="@string/lockpattern_settings_enable_visible_pattern_title"/>
+    <SwitchPreference
+        android:key="visiblepattern"
+        android:title="@string/lockpattern_settings_enable_visible_pattern_title" />
 
-        <com.android.settings.TimeoutListPreference
-                android:key="lock_after_timeout"
-                android:title="@string/lock_after_timeout"
-                android:summary="@string/lock_after_timeout_summary"
-                android:entries="@array/lock_after_timeout_entries"
-                android:entryValues="@array/lock_after_timeout_values" />
+    <com.android.settings.TimeoutListPreference
+        android:key="lock_after_timeout"
+        android:title="@string/lock_after_timeout"
+        android:summary="@string/lock_after_timeout_summary"
+        android:entries="@array/lock_after_timeout_entries"
+        android:entryValues="@array/lock_after_timeout_values" />
 
-        <SwitchPreference
-                android:key="power_button_instantly_locks"
-                android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
+    <SwitchPreference
+        android:key="power_button_instantly_locks"
+        android:title="@string/lockpattern_settings_enable_power_button_instantly_locks" />
 
-        <com.android.settings.SingleLineSummaryPreference
-                android:key="owner_info_settings"
-                android:title="@string/owner_info_settings_title"
-                android:summary="@string/owner_info_settings_summary"/>
-
+    <com.android.settingslib.RestrictedPreference
+        android:key="owner_info_settings"
+        android:title="@string/owner_info_settings_title"
+        android:summary="@string/owner_info_settings_summary" />
 
 </PreferenceScreen>
diff --git a/res/xml/security_settings_pin_sub.xml b/res/xml/security_settings_pin_sub.xml
index 25d00bc..46c4999 100644
--- a/res/xml/security_settings_pin_sub.xml
+++ b/res/xml/security_settings_pin_sub.xml
@@ -15,25 +15,24 @@
   ~ limitations under the License
   -->
 
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-                  xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
-                  android:title="@string/settings_label">
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:title="@string/settings_label">
 
-        <com.android.settings.TimeoutListPreference
-                android:key="lock_after_timeout"
-                android:title="@string/lock_after_timeout"
-                android:summary="@string/lock_after_timeout_summary"
-                android:entries="@array/lock_after_timeout_entries"
-                android:entryValues="@array/lock_after_timeout_values" />
+    <com.android.settings.TimeoutListPreference
+        android:key="lock_after_timeout"
+        android:title="@string/lock_after_timeout"
+        android:summary="@string/lock_after_timeout_summary"
+        android:entries="@array/lock_after_timeout_entries"
+        android:entryValues="@array/lock_after_timeout_values" />
 
-        <SwitchPreference
-                android:key="power_button_instantly_locks"
-                android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
+    <SwitchPreference
+        android:key="power_button_instantly_locks"
+        android:title="@string/lockpattern_settings_enable_power_button_instantly_locks" />
 
-        <com.android.settings.SingleLineSummaryPreference
-                android:key="owner_info_settings"
-                android:title="@string/owner_info_settings_title"
-                android:summary="@string/owner_info_settings_summary"/>
-
+    <com.android.settingslib.RestrictedPreference
+        android:key="owner_info_settings"
+        android:title="@string/owner_info_settings_title"
+        android:summary="@string/owner_info_settings_summary" />
 
 </PreferenceScreen>
diff --git a/res/xml/security_settings_slide_sub.xml b/res/xml/security_settings_slide_sub.xml
index 1efb370..88eba8b 100644
--- a/res/xml/security_settings_slide_sub.xml
+++ b/res/xml/security_settings_slide_sub.xml
@@ -15,13 +15,13 @@
   ~ limitations under the License
   -->
 
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-                  xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
-                  android:title="@string/settings_label">
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:title="@string/settings_label">
 
-        <com.android.settings.SingleLineSummaryPreference
-            android:key="owner_info_settings"
-            android:title="@string/owner_info_settings_title"
-            android:summary="@string/owner_info_settings_summary"/>
+    <com.android.settingslib.RestrictedPreference
+        android:key="owner_info_settings"
+        android:title="@string/owner_info_settings_title"
+        android:summary="@string/owner_info_settings_summary" />
 
 </PreferenceScreen>
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index 0aaaff1..d288a9d 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -56,38 +56,34 @@
                 android:title="@string/zen_mode_settings_title"
                 settings:useAdminDisabledSummary="true"
                 settings:keywords="@string/keywords_sounds_and_notifications_interruptions"
-                android:fragment="com.android.settings.notification.ZenModeSettings" />
+                android:fragment="com.android.settings.notification.ZenModeSettings"
+                settings:allowDividerAbove="true" />
 
-        <PreferenceCategory
-          android:key="ringtones_preferecence_category"
-          android:title="@string/ringtones_category_preference_title" >
+        <!-- Phone ringtone -->
+        <com.android.settings.DefaultRingtonePreference
+            android:key="ringtone"
+            android:title="@string/ringtone_title"
+            android:dialogTitle="@string/ringtone_title"
+            android:summary="@string/summary_placeholder"
+            android:ringtoneType="ringtone"
+            settings:allowDividerAbove="true" />
 
-                <!-- Phone ringtone -->
-                <com.android.settings.DefaultRingtonePreference
-                    android:key="ringtone"
-                    android:title="@string/ringtone_title"
-                    android:dialogTitle="@string/ringtone_title"
-                    android:summary="@string/summary_placeholder"
-                    android:ringtoneType="ringtone" />
+        <!-- Default notification ringtone -->
+        <com.android.settings.DefaultRingtonePreference
+            android:key="notification_ringtone"
+            android:title="@string/notification_ringtone_title"
+            android:dialogTitle="@string/notification_ringtone_title"
+            android:summary="@string/summary_placeholder"
+            android:ringtoneType="notification" />
 
-                <!-- Default notification ringtone -->
-                <com.android.settings.DefaultRingtonePreference
-                    android:key="notification_ringtone"
-                    android:title="@string/notification_ringtone_title"
-                    android:dialogTitle="@string/notification_ringtone_title"
-                    android:summary="@string/summary_placeholder"
-                    android:ringtoneType="notification" />
-
-                <!-- Default alarm ringtone -->
-                <com.android.settings.DefaultRingtonePreference
-                    android:key="alarm_ringtone"
-                    android:title="@string/alarm_ringtone_title"
-                    android:dialogTitle="@string/alarm_ringtone_title"
-                    android:summary="@string/summary_placeholder"
-                    android:persistent="false"
-                    android:ringtoneType="alarm" />
-
-        </PreferenceCategory>
+        <!-- Default alarm ringtone -->
+        <com.android.settings.DefaultRingtonePreference
+            android:key="alarm_ringtone"
+            android:title="@string/alarm_ringtone_title"
+            android:dialogTitle="@string/alarm_ringtone_title"
+            android:summary="@string/summary_placeholder"
+            android:persistent="false"
+            android:ringtoneType="alarm" />
 
         <!-- Other sounds -->
         <PreferenceCategory
@@ -144,7 +140,8 @@
         <com.android.settingslib.RestrictedPreference
           android:key="cell_broadcast_settings"
           android:title="@string/cell_broadcast_settings"
-          settings:useAdminDisabledSummary="true">
+          settings:useAdminDisabledSummary="true"
+          settings:allowDividerAbove="true" >
                 <intent
                   android:action="android.intent.action.MAIN"
                   android:targetPackage="com.android.cellbroadcastreceiver"
diff --git a/res/xml/storage_profile_fragment.xml b/res/xml/storage_profile_fragment.xml
index c675744..98cb1dc 100644
--- a/res/xml/storage_profile_fragment.xml
+++ b/res/xml/storage_profile_fragment.xml
@@ -20,22 +20,27 @@
     android:title="@string/storage_settings">
     <com.android.settings.deviceinfo.StorageItemPreference
         android:key="pref_photos_videos"
-        android:title="@string/storage_photos_videos">
-    </com.android.settings.deviceinfo.StorageItemPreference>
+        android:title="@string/storage_photos_videos"
+        android:icon="@drawable/ic_photo_library_vd_theme_24"
+        android:order="2" />
     <com.android.settings.deviceinfo.StorageItemPreference
         android:key="pref_music_audio"
-        android:title="@string/storage_music_audio">
-    </com.android.settings.deviceinfo.StorageItemPreference>
+        android:title="@string/storage_music_audio"
+        android:icon="@drawable/ic_music_note_vd_theme_24"
+        android:order="3" />
     <com.android.settings.deviceinfo.StorageItemPreference
         android:key="pref_games"
-        android:title="@string/storage_games">
-    </com.android.settings.deviceinfo.StorageItemPreference>
+        android:title="@string/storage_games"
+        android:icon="@drawable/ic_videogame_vd_theme_24"
+        android:order="4" />
     <com.android.settings.deviceinfo.StorageItemPreference
         android:key="pref_other_apps"
-        android:title="@string/storage_other_apps">
-    </com.android.settings.deviceinfo.StorageItemPreference>
+        android:title="@string/storage_other_apps"
+        android:icon="@drawable/ic_apps_vd_theme_24"
+        android:order="5" />
     <com.android.settings.deviceinfo.StorageItemPreference
         android:key="pref_files"
-        android:title="@string/storage_files">
-    </com.android.settings.deviceinfo.StorageItemPreference>
+        android:title="@string/storage_files"
+        android:icon="@drawable/ic_folder_vd_theme_24"
+        android:order="6" />
 </PreferenceScreen>
diff --git a/res/xml/system_dashboard_fragment.xml b/res/xml/system_dashboard_fragment.xml
index b03fab6..1186e78 100644
--- a/res/xml/system_dashboard_fragment.xml
+++ b/res/xml/system_dashboard_fragment.xml
@@ -16,7 +16,6 @@
 
 <PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
     android:title="@string/header_category_system">
 
     <!-- System updates -->
@@ -26,7 +25,7 @@
         android:summary="@string/summary_placeholder"
         android:icon="@drawable/ic_system_update"
         android:order="-30">
-        <intent android:action="android.settings.SYSTEM_UPDATE_SETTINGS"/>
+        <intent android:action="android.settings.SYSTEM_UPDATE_SETTINGS" />
     </Preference>
 
     <Preference
@@ -35,17 +34,14 @@
         android:order="-31">
         <intent android:action="android.intent.action.MAIN"
                 android:targetPackage="@string/additional_system_update"
-                android:targetClass="@string/additional_system_update_menu"/>
+                android:targetClass="@string/additional_system_update_menu" />
     </Preference>
 
-    <!-- Factory reset -->
-    <com.android.settingslib.RestrictedPreference
-        android:key="factory_reset"
-        android:title="@string/master_clear_title"
+    <Preference
+        android:key="reset_dashboard"
+        android:title="@string/reset_dashboard_title"
         android:icon="@drawable/ic_restore"
         android:order="-20"
-        settings:keywords="@string/keywords_factory_data_reset"
-        settings:userRestriction="no_factory_reset"
-        settings:useAdminDisabledSummary="true"
-        android:fragment="com.android.settings.MasterClear" />
+        android:fragment="com.android.settings.system.ResetDashboardFragment" />
+
 </PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/vpn_app_management.xml b/res/xml/vpn_app_management.xml
index 1b6f37b..c044a58 100644
--- a/res/xml/vpn_app_management.xml
+++ b/res/xml/vpn_app_management.xml
@@ -27,8 +27,7 @@
                 android:key="always_on_vpn"
                 android:title="@string/vpn_menu_lockdown"
                 android:defaultValue="false"
-                android:summaryOn="@string/vpn_always_on_active"
-                android:summaryOff="@string/vpn_always_on_inactive"
+                android:summary="@string/vpn_always_on_summary"
                 settings:userRestriction="no_config_vpn"
                 settings:useAdditionalSummary="true"
                 settings:restrictedSwitchSummary="@string/disabled_by_admin_summary_text" />
@@ -37,8 +36,6 @@
                 android:key="lockdown_vpn"
                 android:title="@string/vpn_require_connection"
                 android:defaultValue="false"
-                android:summaryOn="@string/vpn_lockdown_active"
-                android:summaryOff="@string/vpn_lockdown_inactive"
                 android:dependency="always_on_vpn"
                 settings:userRestriction="no_config_vpn"
                 settings:useAdditionalSummary="true"
diff --git a/res/xml/zen_mode_automation_settings.xml b/res/xml/zen_mode_automation_settings.xml
deleted file mode 100644
index 7cfffd4..0000000
--- a/res/xml/zen_mode_automation_settings.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2015 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-    android:key="zen_mode_settings"
-    android:title="@string/zen_mode_automation_settings_title" >
-
-    <!-- Rules added at runtime -->
-</PreferenceScreen>
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index b22ad6a..5fc72aa 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -25,15 +25,14 @@
             android:title="@string/zen_mode_priority_settings_title"
             android:fragment="com.android.settings.notification.ZenModePrioritySettings" />
 
-    <!-- Automated rules -->
-    <Preference
-            android:key="automation_settings"
-            android:title="@string/zen_mode_automation_settings_title"
-            android:fragment="com.android.settings.notification.ZenModeAutomationSettings" />
-
     <!-- Visual interruptions -->
     <Preference
             android:key="visual_interruptions_settings"
             android:title="@string/zen_mode_visual_interruptions_settings_title"
             android:fragment="com.android.settings.notification.ZenModeVisualInterruptionSettings" />
+
+    <!-- Automatic rules -->
+    <PreferenceCategory
+        android:key="automatic_rules"
+        android:title="@string/zen_mode_automation_settings_title" />
 </PreferenceScreen>
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index 94ea2e7..99c6e8b 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -57,7 +57,6 @@
 import android.view.inputmethod.InputMethodManager;
 import android.view.inputmethod.InputMethodSubtype;
 import android.widget.Button;
-import android.widget.EditText;
 import android.widget.ProgressBar;
 import android.widget.TextView;
 
@@ -66,6 +65,7 @@
 import com.android.internal.widget.LockPatternView;
 import com.android.internal.widget.LockPatternView.Cell;
 import com.android.internal.widget.LockPatternView.DisplayMode;
+import com.android.settings.widget.ImeAwareEditText;
 
 import java.util.List;
 
@@ -122,7 +122,7 @@
     private boolean mCooldown = false;
 
     PowerManager.WakeLock mWakeLock;
-    private EditText mPasswordEntry;
+    private ImeAwareEditText mPasswordEntry;
     private LockPatternView mLockPatternView;
     /** Number of calls to {@link #notifyUser()} to ignore before notifying. */
     private int mNotificationCountdown = 0;
@@ -277,9 +277,7 @@
             // Reenable the password entry
             if (mPasswordEntry != null) {
                 mPasswordEntry.setEnabled(true);
-                final InputMethodManager imm = (InputMethodManager) getSystemService(
-                        Context.INPUT_METHOD_SERVICE);
-                imm.showSoftInput(mPasswordEntry, 0);
+                mPasswordEntry.scheduleShowSoftInput();
                 setBackFunctionality(true);
             }
         }
@@ -744,7 +742,7 @@
 
      private void passwordEntryInit() {
         // Password/pin case
-        mPasswordEntry = (EditText) findViewById(R.id.passwordEntry);
+        mPasswordEntry = (ImeAwareEditText) findViewById(R.id.passwordEntry);
         if (mPasswordEntry != null){
             mPasswordEntry.setOnEditorActionListener(this);
             mPasswordEntry.requestFocus();
@@ -797,16 +795,13 @@
             }
         }
 
-        // Asynchronously throw up the IME, since there are issues with requesting it to be shown
-        // immediately.
+        // Make sure that the IME is shown when everything becomes ready.
         if (mLockPatternView == null && !mCooldown) {
             getWindow().setSoftInputMode(
                                 WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
-            mHandler.postDelayed(new Runnable() {
-                @Override public void run() {
-                    imm.showSoftInputUnchecked(0, null);
-                }
-            }, 0);
+            if (mPasswordEntry != null) {
+                mPasswordEntry.scheduleShowSoftInput();
+            }
         }
 
         updateEmergencyCallButtonState();
diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java
index b1c9e2c..109fb0e 100644
--- a/src/com/android/settings/DeviceInfoSettings.java
+++ b/src/com/android/settings/DeviceInfoSettings.java
@@ -26,6 +26,7 @@
 import com.android.settings.core.PreferenceController;
 import com.android.settings.core.lifecycle.Lifecycle;
 import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.dashboard.SummaryLoader;
 import com.android.settings.deviceinfo.AdditionalSystemUpdatePreferenceController;
 import com.android.settings.deviceinfo.BasebandVersionPreferenceController;
 import com.android.settings.deviceinfo.BuildNumberPreferenceController;
@@ -86,6 +87,31 @@
                 getLifecycle());
     }
 
+    private static class SummaryProvider implements SummaryLoader.SummaryProvider {
+
+        private final SummaryLoader mSummaryLoader;
+
+        public SummaryProvider(SummaryLoader summaryLoader) {
+            mSummaryLoader = summaryLoader;
+        }
+
+        @Override
+        public void setListening(boolean listening) {
+            if (listening) {
+                mSummaryLoader.setSummary(this, DeviceModelPreferenceController.getDeviceModel());
+            }
+        }
+    }
+
+    public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
+            = new SummaryLoader.SummaryProviderFactory() {
+        @Override
+        public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
+                SummaryLoader summaryLoader) {
+            return new SummaryProvider(summaryLoader);
+        }
+    };
+
     private static List<PreferenceController> buildPreferenceControllers(Context context,
             Activity activity, Fragment fragment, Lifecycle lifecycle) {
         final List<PreferenceController> controllers = new ArrayList<>();
diff --git a/src/com/android/settings/SingleLineSummaryPreference.java b/src/com/android/settings/SingleLineSummaryPreference.java
deleted file mode 100644
index 822b0e6..0000000
--- a/src/com/android/settings/SingleLineSummaryPreference.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings;
-
-import android.content.Context;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.text.TextUtils.TruncateAt;
-import android.util.AttributeSet;
-import android.widget.TextView;
-
-import com.android.settingslib.RestrictedPreference;
-
-public class SingleLineSummaryPreference extends RestrictedPreference {
-
-    public SingleLineSummaryPreference(Context context, AttributeSet attrs) {
-        super(context, attrs);
-    }
-
-    @Override
-    public void onBindViewHolder(PreferenceViewHolder view) {
-        super.onBindViewHolder(view);
-
-        final TextView summaryView = (TextView) view.findViewById(
-                com.android.internal.R.id.summary);
-        summaryView.setSingleLine();
-        summaryView.setEllipsize(TruncateAt.END);
-    }
-
-}
diff --git a/src/com/android/settings/TetherSettings.java b/src/com/android/settings/TetherSettings.java
index 61cad39..5d797a7 100644
--- a/src/com/android/settings/TetherSettings.java
+++ b/src/com/android/settings/TetherSettings.java
@@ -142,7 +142,7 @@
         setIfOnlyAvailableForAdmins(true);
         if (isUiRestricted()) {
             mUnavailable = true;
-            setPreferenceScreen(new PreferenceScreen(getPrefContext(), null));
+            getPreferenceScreen().removeAll();
             return;
         }
 
diff --git a/src/com/android/settings/UserCredentialsSettings.java b/src/com/android/settings/UserCredentialsSettings.java
index ea9eee9..6cf1ae0 100644
--- a/src/com/android/settings/UserCredentialsSettings.java
+++ b/src/com/android/settings/UserCredentialsSettings.java
@@ -37,20 +37,18 @@
 import android.security.KeyChain;
 import android.security.KeyChain.KeyChainConnection;
 import android.security.KeyStore;
+import android.support.v7.widget.RecyclerView;
 import android.util.Log;
 import android.util.SparseArray;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
 import android.widget.TextView;
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.SettingsPreferenceFragment;
 import com.android.settingslib.RestrictedLockUtils;
 import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
 
@@ -63,11 +61,10 @@
 import static android.view.View.GONE;
 import static android.view.View.VISIBLE;
 
-public class UserCredentialsSettings extends OptionsMenuFragment implements OnItemClickListener {
+public class UserCredentialsSettings extends SettingsPreferenceFragment
+        implements View.OnClickListener {
     private static final String TAG = "UserCredentialsSettings";
 
-    private ListView mListView;
-
     @Override
     public int getMetricsCategory() {
         return MetricsEvent.USER_CREDENTIALS;
@@ -80,27 +77,18 @@
     }
 
     @Override
-    public View onCreateView(
-            LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
-        final View rootView = inflater.inflate(R.layout.user_credentials, parent, false);
-
-        // Set up an OnItemClickListener for the credential list.
-        mListView = (ListView) rootView.findViewById(R.id.credential_list);
-        mListView.setOnItemClickListener(this);
-
-        return rootView;
-    }
-
-    @Override
-    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-        final Credential item = (Credential) parent.getItemAtPosition(position);
-        CredentialDialogFragment.show(this, item);
+    public void onClick(final View view) {
+        final Credential item = (Credential) view.getTag();
+        if (item != null) {
+            CredentialDialogFragment.show(this, item);
+        }
     }
 
     protected void announceRemoval(String alias) {
-        if (isAdded()) {
-            mListView.announceForAccessibility(getString(R.string.user_credential_removed, alias));
+        if (!isAdded()) {
+            return;
         }
+        getListView().announceForAccessibility(getString(R.string.user_credential_removed, alias));
     }
 
     protected void refreshItems() {
@@ -288,25 +276,60 @@
 
         @Override
         protected void onPostExecute(List<Credential> credentials) {
-            final Credential[] credentialArray = credentials.toArray(new Credential[0]);
-            mListView.setAdapter(new CredentialAdapter(getContext(), credentialArray));
+            if (!isAdded()) {
+                return;
+            }
+
+            if (credentials == null || credentials.size() == 0) {
+                // Create a "no credentials installed" message for the empty case.
+                TextView emptyTextView = (TextView) getActivity().findViewById(android.R.id.empty);
+                emptyTextView.setText(R.string.user_credential_none_installed);
+                setEmptyView(emptyTextView);
+            } else {
+                setEmptyView(null);
+            }
+
+            getListView().setAdapter(
+                    new CredentialAdapter(credentials, UserCredentialsSettings.this));
         }
     }
 
     /**
      * Helper class to display {@link Credential}s in a list.
      */
-    private static class CredentialAdapter extends ArrayAdapter<Credential> {
+    private static class CredentialAdapter extends RecyclerView.Adapter<ViewHolder> {
         private static final int LAYOUT_RESOURCE = R.layout.user_credential_preference;
 
-        public CredentialAdapter(Context context, final Credential[] objects) {
-            super(context, LAYOUT_RESOURCE, objects);
+        private final List<Credential> mItems;
+        private final View.OnClickListener mListener;
+
+        public CredentialAdapter(List<Credential> items, @Nullable View.OnClickListener listener) {
+            mItems = items;
+            mListener = listener;
         }
 
         @Override
-        public View getView(int position, @Nullable View view, ViewGroup parent) {
-            return getCredentialView(getItem(position), LAYOUT_RESOURCE, view, parent,
-                    /* expanded */ false);
+        public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+            final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
+            return new ViewHolder(inflater.inflate(LAYOUT_RESOURCE, parent, false));
+        }
+
+        @Override
+        public void onBindViewHolder(ViewHolder h, int position) {
+            getCredentialView(mItems.get(position), LAYOUT_RESOURCE, h.itemView, null, false);
+            h.itemView.setTag(mItems.get(position));
+            h.itemView.setOnClickListener(mListener);
+        }
+
+        @Override
+        public int getItemCount() {
+            return mItems.size();
+        }
+    }
+
+    private static class ViewHolder extends RecyclerView.ViewHolder {
+        public ViewHolder(View item) {
+            super(item);
         }
     }
 
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 909ddfe..4c8fb2d 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -74,6 +74,7 @@
 import android.provider.ContactsContract.RawContacts;
 import android.provider.Settings;
 import android.service.persistentdata.PersistentDataBlockManager;
+import android.support.annotation.StringRes;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceGroup;
 import android.support.v7.preference.PreferenceManager;
@@ -1241,6 +1242,17 @@
         return isVolumeValid(volume) ? volume : null;
     }
 
+    /**
+     * Return the resource id to represent the install status for an app
+     */
+    @StringRes
+    public static int getInstallationStatus(ApplicationInfo info) {
+        if ((info.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
+            return R.string.not_installed;
+        }
+        return info.enabled ? R.string.installed : R.string.disabled;
+    }
+
     private static boolean isVolumeValid(VolumeInfo volume) {
         return (volume != null) && (volume.getType() == VolumeInfo.TYPE_PRIVATE)
                 && volume.isMountedReadable();
diff --git a/src/com/android/settings/accessibility/AccessibilityServiceWarning.java b/src/com/android/settings/accessibility/AccessibilityServiceWarning.java
index 3a84d74..71cafba 100644
--- a/src/com/android/settings/accessibility/AccessibilityServiceWarning.java
+++ b/src/com/android/settings/accessibility/AccessibilityServiceWarning.java
@@ -78,9 +78,16 @@
         return StorageManager.isNonDefaultBlockEncrypted();
     }
 
-    private static View createEnableDialogContentView(Activity parentActivity,
+    /**
+     * Get a content View for a dialog to confirm that they want to enable a service.
+     *
+     * @param context A valid context
+     * @param info The info about a service
+     * @return A content view suitable for viewing
+     */
+    private static View createEnableDialogContentView(Context context,
             AccessibilityServiceInfo info) {
-        LayoutInflater inflater = (LayoutInflater) parentActivity.getSystemService(
+        LayoutInflater inflater = (LayoutInflater) context.getSystemService(
                 Context.LAYOUT_INFLATER_SERVICE);
 
         View content = inflater.inflate(R.layout.enable_accessibility_service_dialog_content,
@@ -89,8 +96,8 @@
         TextView encryptionWarningView = (TextView) content.findViewById(
                 R.id.encryption_warning);
         if (isFullDiskEncrypted()) {
-            String text = parentActivity.getString(R.string.enable_service_encryption_warning,
-                    info.getResolveInfo().loadLabel(parentActivity.getPackageManager()));
+            String text = context.getString(R.string.enable_service_encryption_warning,
+                    info.getResolveInfo().loadLabel(context.getPackageManager()));
             encryptionWarningView.setText(text);
             encryptionWarningView.setVisibility(View.VISIBLE);
         } else {
@@ -99,8 +106,8 @@
 
         TextView capabilitiesHeaderView = (TextView) content.findViewById(
                 R.id.capabilities_header);
-        capabilitiesHeaderView.setText(parentActivity.getString(R.string.capabilities_list_title,
-                info.getResolveInfo().loadLabel(parentActivity.getPackageManager())));
+        capabilitiesHeaderView.setText(context.getString(R.string.capabilities_list_title,
+                info.getResolveInfo().loadLabel(context.getPackageManager())));
 
         LinearLayout capabilitiesView = (LinearLayout) content.findViewById(R.id.capabilities);
 
@@ -110,21 +117,21 @@
 
         ImageView imageView = (ImageView) capabilityView.findViewById(
                 com.android.internal.R.id.perm_icon);
-        imageView.setImageDrawable(parentActivity.getDrawable(
+        imageView.setImageDrawable(context.getDrawable(
                 com.android.internal.R.drawable.ic_text_dot));
 
         TextView labelView = (TextView) capabilityView.findViewById(
                 com.android.internal.R.id.permission_group);
-        labelView.setText(parentActivity.getString(
+        labelView.setText(context.getString(
                 R.string.capability_title_receiveAccessibilityEvents));
 
         TextView descriptionView = (TextView) capabilityView.findViewById(
                 com.android.internal.R.id.permission_list);
         descriptionView.setText(
-                parentActivity.getString(R.string.capability_desc_receiveAccessibilityEvents));
+                context.getString(R.string.capability_desc_receiveAccessibilityEvents));
 
         List<AccessibilityServiceInfo.CapabilityInfo> capabilities =
-                info.getCapabilityInfos(parentActivity);
+                info.getCapabilityInfos(context);
 
         capabilitiesView.addView(capabilityView);
 
@@ -138,16 +145,16 @@
 
             imageView = (ImageView) capabilityView.findViewById(
                     com.android.internal.R.id.perm_icon);
-            imageView.setImageDrawable(parentActivity.getDrawable(
+            imageView.setImageDrawable(context.getDrawable(
                     com.android.internal.R.drawable.ic_text_dot));
 
             labelView = (TextView) capabilityView.findViewById(
                     com.android.internal.R.id.permission_group);
-            labelView.setText(parentActivity.getString(capability.titleResId));
+            labelView.setText(context.getString(capability.titleResId));
 
             descriptionView = (TextView) capabilityView.findViewById(
                     com.android.internal.R.id.permission_list);
-            descriptionView.setText(parentActivity.getString(capability.descResId));
+            descriptionView.setText(context.getString(capability.descResId));
 
             capabilitiesView.addView(capabilityView);
         }
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index eaadf13..760755c 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -17,11 +17,9 @@
 package com.android.settings.accessibility;
 
 import android.accessibilityservice.AccessibilityServiceInfo;
-import android.app.Dialog;
 import android.app.admin.DevicePolicyManager;
 import android.content.ComponentName;
 import android.content.Context;
-import android.content.DialogInterface;
 import android.content.pm.PackageManager;
 import android.content.pm.ServiceInfo;
 import android.content.res.Resources;
@@ -49,13 +47,13 @@
 import com.android.internal.view.RotationPolicy.RotationPolicyListener;
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.SingleLineSummaryPreference;
 import com.android.settings.Utils;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
 import com.android.settings.search.SearchIndexableRaw;
 import com.android.settingslib.RestrictedLockUtils;
 import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import com.android.settingslib.RestrictedPreference;
 import com.android.settingslib.accessibility.AccessibilityUtils;
 
 import java.util.ArrayList;
@@ -105,7 +103,7 @@
     private static final String CAPTIONING_PREFERENCE_SCREEN =
             "captioning_preference_screen";
     private static final String DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN =
-            "screen_magnification_preference_screen";
+            "magnification_preference_screen";
     private static final String FONT_SIZE_PREFERENCE_SCREEN =
             "font_size_preference_screen";
     private static final String AUTOCLICK_PREFERENCE_SCREEN =
@@ -121,6 +119,8 @@
     static final String EXTRA_SETTINGS_TITLE = "settings_title";
     static final String EXTRA_COMPONENT_NAME = "component_name";
     static final String EXTRA_SETTINGS_COMPONENT_NAME = "settings_component_name";
+    static final String EXTRA_VIDEO_RAW_RESOURCE_ID = "video_resource";
+    static final String EXTRA_LAUNCHED_FROM_SUW = "from_suw";
 
     // Timeout before we update the services if packages are added/removed
     // since the AccessibilityManagerService has to do that processing first
@@ -128,9 +128,6 @@
     // presentation.
     private static final long DELAY_UPDATE_SERVICES_MILLIS = 1000;
 
-    // ID for dialog that confirms shortcut capabilities
-    private static final int DIALOG_ID_ADD_SHORTCUT_WARNING = 1;
-
     private final Map<String, String> mLongPressTimeoutValueToTitleMap = new HashMap<>();
 
     private final Handler mHandler = new Handler();
@@ -203,7 +200,7 @@
     private Preference mDisplayMagnificationPreferenceScreen;
     private Preference mFontSizePreferenceScreen;
     private Preference mAutoclickPreferenceScreen;
-    private ListPreference mAccessibilityShortcutPreference;
+    private Preference mAccessibilityShortcutPreferenceScreen;
     private Preference mDisplayDaltonizerPreferenceScreen;
     private SwitchPreference mToggleInversionPreference;
 
@@ -262,9 +259,6 @@
         } else if (mToggleInversionPreference == preference) {
             handleToggleInversionPreferenceChange((Boolean) newValue);
             return true;
-        } else if (mAccessibilityShortcutPreference == preference) {
-            handleAccessibilityShortcutPreferenceChange((String) newValue);
-            return true;
         }
         return false;
     }
@@ -281,58 +275,6 @@
                 Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, (checked ? 1 : 0));
     }
 
-    private void handleAccessibilityShortcutPreferenceChange(String serviceComponentName) {
-        // When assigning a service to the shortcut the user must explicitly agree to the same
-        // capabilities that are present if the service were being enabled.
-        // No need if clearing the setting or the service is already enabled.
-        if (TextUtils.isEmpty(serviceComponentName)
-                || AccessibilityUtils.getEnabledServicesFromSettings(getActivity())
-                        .contains(ComponentName.unflattenFromString(serviceComponentName))) {
-            Settings.Secure.putString(getContentResolver(),
-                    Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE, serviceComponentName);
-            updateAccessibilityShortcut();
-            return;
-        }
-        if (!serviceComponentName.equals(mAccessibilityShortcutPreference.getValue())) {
-            showDialog(DIALOG_ID_ADD_SHORTCUT_WARNING);
-        }
-    }
-
-    @Override
-    public Dialog onCreateDialog(int dialogId) {
-        switch (dialogId) {
-            case DIALOG_ID_ADD_SHORTCUT_WARNING: {
-                DialogInterface.OnClickListener listener =
-                        (DialogInterface dialogInterface, int buttonId) -> {
-                            if (buttonId == DialogInterface.BUTTON_POSITIVE) {
-                                Settings.Secure.putString(getContentResolver(),
-                                        Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE,
-                                        mAccessibilityShortcutPreference.getValue());
-                            }
-                            updateAccessibilityShortcut();
-                        };
-                AccessibilityServiceInfo info = AccessibilityManager.getInstance(getActivity())
-                        .getInstalledServiceInfoWithComponentName(
-                                ComponentName.unflattenFromString(
-                                        mAccessibilityShortcutPreference.getValue()));
-                if (info == null) {
-                    return null;
-                }
-                return AccessibilityServiceWarning
-                        .createCapabilitiesDialog(getActivity(), info, listener);
-            }
-            default: {
-                throw new IllegalArgumentException();
-            }
-        }
-    }
-
-    @Override
-    public int getDialogMetricsCategory(int dialogId) {
-        // The only dialog is the one that confirms the properties for the accessibility shortcut
-        return MetricsEvent.ACCESSIBILITY_TOGGLE_GLOBAL_GESTURE;
-    }
-
     @Override
     public boolean onPreferenceTreeClick(Preference preference) {
         if (mToggleHighTextContrastPreference == preference) {
@@ -350,9 +292,6 @@
         } else if (mToggleMasterMonoPreference == preference) {
             handleToggleMasterMonoPreferenceClick();
             return true;
-        } else if (mDisplayMagnificationPreferenceScreen == preference) {
-            handleDisplayMagnificationPreferenceScreenClick();
-            return true;
         }
         return super.onPreferenceTreeClick(preference);
     }
@@ -387,17 +326,6 @@
                 mToggleMasterMonoPreference.isChecked() ? 1 : 0, UserHandle.USER_CURRENT);
     }
 
-    private void handleDisplayMagnificationPreferenceScreenClick() {
-        Bundle extras = mDisplayMagnificationPreferenceScreen.getExtras();
-        extras.putString(EXTRA_TITLE, getString(
-                R.string.accessibility_screen_magnification_title));
-        extras.putCharSequence(EXTRA_SUMMARY, getActivity().getResources().getText(
-                R.string.accessibility_screen_magnification_summary));
-        extras.putBoolean(EXTRA_CHECKED, Settings.Secure.getInt(getContentResolver(),
-                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1);
-        super.onPreferenceTreeClick(mDisplayMagnificationPreferenceScreen);
-    }
-
     private void initializeAllPreferences() {
         for (int i = 0; i < CATEGORIES.length; i++) {
             PreferenceCategory prefCategory = (PreferenceCategory) findPreference(CATEGORIES[i]);
@@ -470,9 +398,7 @@
         mDisplayDaltonizerPreferenceScreen = findPreference(DISPLAY_DALTONIZER_PREFERENCE_SCREEN);
 
         // Accessibility shortcut
-        mAccessibilityShortcutPreference =
-                (ListPreference) findPreference(ACCESSIBILITY_SHORTCUT_PREFERENCE);
-        mAccessibilityShortcutPreference.setOnPreferenceChangeListener(this);
+        mAccessibilityShortcutPreferenceScreen = findPreference(ACCESSIBILITY_SHORTCUT_PREFERENCE);
     }
 
     private void updateAllPreferences() {
@@ -524,8 +450,8 @@
         for (int i = 0, count = installedServices.size(); i < count; ++i) {
             AccessibilityServiceInfo info = installedServices.get(i);
 
-            SingleLineSummaryPreference preference =
-                    new SingleLineSummaryPreference(downloadedServicesCategory.getContext(), null);
+            RestrictedPreference preference =
+                    new RestrictedPreference(downloadedServicesCategory.getContext());
             String title = info.getResolveInfo().loadLabel(getPackageManager()).toString();
 
             Drawable icon = info.getResolveInfo().loadIcon(getPackageManager());
@@ -544,12 +470,15 @@
             preference.setIcon(icon);
             final boolean serviceEnabled = accessibilityEnabled
                     && enabledServices.contains(componentName);
-            String serviceState = serviceEnabled ?
-                    getString(R.string.accessibility_feature_state_on) :
-                    getString(R.string.accessibility_feature_state_off);
-            String serviceSummary = info.loadSummary(getPackageManager());
-            serviceSummary = (TextUtils.isEmpty(serviceSummary)) ? serviceState :
-                    serviceSummary;
+            final String serviceState = serviceEnabled ?
+                    getString(R.string.accessibility_summary_state_enabled) :
+                    getString(R.string.accessibility_summary_state_disabled);
+            final String serviceSummary = info.loadSummary(getPackageManager());
+            final String stateSummaryCombo = getString(
+                    R.string.accessibility_summary_default_combination,
+                    serviceState, serviceSummary);
+            preference.setSummary((TextUtils.isEmpty(serviceSummary)) ? serviceState
+                    : stateSummaryCombo);
 
             // Disable all accessibility services that are not permitted.
             boolean serviceAllowed =
@@ -566,7 +495,6 @@
                 preference.setEnabled(true);
             }
 
-            preference.setSummary(serviceSummary);
             preference.setFragment(ToggleAccessibilityServicePreferenceFragment.class.getName());
             preference.setPersistent(true);
 
@@ -656,16 +584,35 @@
 
         updateFeatureSummary(Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED,
                 mCaptioningPreferenceScreen);
-        updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
-                mDisplayMagnificationPreferenceScreen);
         updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
                 mDisplayDaltonizerPreferenceScreen);
 
+        updateMagnificationSummary(mDisplayMagnificationPreferenceScreen);
+
         updateFontSizeSummary(mFontSizePreferenceScreen);
 
         updateAutoclickSummary(mAutoclickPreferenceScreen);
 
-        updateAccessibilityShortcut();
+        updateAccessibilityShortcut(mAccessibilityShortcutPreferenceScreen);
+    }
+
+    private void updateMagnificationSummary(Preference pref) {
+        final boolean tripleTapEnabled = Settings.Secure.getInt(getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1;
+        final boolean buttonEnabled = Settings.Secure.getInt(getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0) == 1;
+
+        int summaryResId = 0;
+        if (!tripleTapEnabled && !buttonEnabled) {
+            summaryResId = R.string.accessibility_feature_state_off;
+        } else if (!tripleTapEnabled && buttonEnabled) {
+            summaryResId = R.string.accessibility_screen_magnification_navbar_title;
+        } else if (tripleTapEnabled && !buttonEnabled) {
+            summaryResId = R.string.accessibility_screen_magnification_gestures_title;
+        } else {
+            summaryResId = R.string.accessibility_screen_magnification_state_navbar_gesture;
+        }
+        pref.setSummary(summaryResId);
     }
 
     private void updateFeatureSummary(String prefKey, Preference pref) {
@@ -714,35 +661,21 @@
         mToggleMasterMonoPreference.setChecked(masterMono);
     }
 
-    private void updateAccessibilityShortcut() {
-        String currentShortcutNameString =
-                AccessibilityUtils.getShortcutTargetServiceComponentNameString(getActivity(),
-                        UserHandle.myUserId());
-        final PackageManager pm = getPackageManager();
-        final AccessibilityManager accessibilityManager = getActivity()
-                .getSystemService(AccessibilityManager.class);
-        final List<AccessibilityServiceInfo> installedServices =
-                accessibilityManager.getInstalledAccessibilityServiceList();
-        final int numInstalledServices = installedServices.size();
-
-        CharSequence[] entries = new CharSequence[numInstalledServices + 1];
-        CharSequence[] entryValues = new CharSequence[numInstalledServices + 1];
-        int currentSettingIndex = numInstalledServices;
-        for (int i = 0; i < numInstalledServices; i++) {
-            AccessibilityServiceInfo installedService = installedServices.get(i);
-            entries[i] = installedService.getResolveInfo().loadLabel(pm);
-            entryValues[i] = installedService.getComponentName().flattenToShortString();
-            if (installedService.getId().equals(currentShortcutNameString)) {
-                currentSettingIndex = i;
-            }
+    private void updateAccessibilityShortcut(Preference preference) {
+        if (AccessibilityManager.getInstance(getActivity())
+                .getInstalledAccessibilityServiceList().isEmpty()) {
+            mAccessibilityShortcutPreferenceScreen
+                    .setSummary(getString(R.string.accessibility_no_services_installed));
+            mAccessibilityShortcutPreferenceScreen.setEnabled(false);
+        } else {
+            mAccessibilityShortcutPreferenceScreen.setEnabled(true);
+            boolean shortcutEnabled =
+                    AccessibilityUtils.isShortcutEnabled(getContext(), UserHandle.myUserId());
+            CharSequence summary = shortcutEnabled
+                    ? AccessibilityShortcutPreferenceFragment.getServiceName(getContext())
+                    : getString(R.string.accessibility_feature_state_off);
+            mAccessibilityShortcutPreferenceScreen.setSummary(summary);
         }
-        entries[numInstalledServices] =
-                getString(com.android.internal.R.string.disable_accessibility_shortcut);
-        entryValues[numInstalledServices] = "";
-        mAccessibilityShortcutPreference.setEntryValues(entryValues);
-        mAccessibilityShortcutPreference.setEntries(entries);
-        mAccessibilityShortcutPreference.setSummary(entries[currentSettingIndex]);
-        mAccessibilityShortcutPreference.setValueIndex(currentSettingIndex);
     }
 
     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
index b8f3af5..8c76fb7 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
@@ -96,13 +96,7 @@
     public boolean onPreferenceTreeClick(Preference preference) {
         if (mDisplayMagnificationPreference == preference) {
             Bundle extras = mDisplayMagnificationPreference.getExtras();
-            extras.putString(AccessibilitySettings.EXTRA_TITLE,
-                    getString(R.string.accessibility_screen_magnification_title));
-            extras.putCharSequence(AccessibilitySettings.EXTRA_SUMMARY,
-                    getText(R.string.accessibility_screen_magnification_summary));
-            extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED,
-                    Settings.Secure.getInt(getContentResolver(),
-                    Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1);
+            extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, true);
         }
 
         return super.onPreferenceTreeClick(preference);
diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
new file mode 100644
index 0000000..6ed06da
--- /dev/null
+++ b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
@@ -0,0 +1,140 @@
+/*
+ * 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.accessibility;
+
+import android.accessibilityservice.AccessibilityServiceInfo;
+import android.content.ComponentName;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.UserHandle;
+import android.provider.Settings;
+import android.support.v14.preference.SwitchPreference;
+import android.support.v7.preference.Preference;
+import android.text.TextUtils;
+import android.view.accessibility.AccessibilityManager;
+import android.widget.Switch;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settingslib.accessibility.AccessibilityUtils;
+
+/**
+ * Settings page for accessibility shortcut
+ */
+public class AccessibilityShortcutPreferenceFragment extends ToggleFeaturePreferenceFragment
+        implements Indexable {
+
+    public static final String SHORTCUT_SERVICE_KEY = "accessibility_shortcut_service";
+    public static final String ON_LOCK_SCREEN_KEY = "accessibility_shortcut_on_lock_screen";
+    // ID for dialog that confirms shortcut capabilities
+    private static final int DIALOG_ID_ADD_SHORTCUT_WARNING = 1;
+
+    private Preference mServicePreference;
+    private SwitchPreference mOnLockScreenSwitchPreference;
+    private String mSelectedServiceComponentNameString;
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsEvent.ACCESSIBILITY_TOGGLE_GLOBAL_GESTURE;
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        addPreferencesFromResource(R.xml.accessibility_shortcut_settings);
+        mServicePreference = findPreference(SHORTCUT_SERVICE_KEY);
+        mOnLockScreenSwitchPreference = (SwitchPreference) findPreference(ON_LOCK_SCREEN_KEY);
+        mOnLockScreenSwitchPreference.setOnPreferenceChangeListener((Preference p, Object o) -> {
+            Settings.Secure.putInt(getContentResolver(),
+                    Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN,
+                    ((Boolean) o) ? 1 : 0);
+            return true;
+        });
+        mFooterPreferenceMixin.createFooterPreference()
+                .setTitle(R.string.accessibility_shortcut_description);
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        updatePreferences();
+    }
+
+    @Override
+    protected void onInstallSwitchBarToggleSwitch() {
+        super.onInstallSwitchBarToggleSwitch();
+        mSwitchBar.addOnSwitchChangeListener((Switch switchView, boolean enabled) -> {
+            onPreferenceToggled(Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, enabled);
+        });
+    }
+
+    @Override
+    protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
+        Settings.Secure.putInt(getContentResolver(), preferenceKey, enabled ? 1 : 0);
+    }
+
+    private void updatePreferences() {
+        ContentResolver cr = getContentResolver();
+        boolean isEnabled = Settings.Secure
+                .getInt(cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, 1) == 1;
+        mToggleSwitch.setChecked(isEnabled);
+        CharSequence serviceName = getServiceName(getContext());
+        mServicePreference.setSummary(serviceName);
+        mOnLockScreenSwitchPreference.setChecked(Settings.Secure.getInt(
+                cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, 1) == 1);
+        if (TextUtils.equals(serviceName, getString(R.string.accessibility_no_service_selected))) {
+            // If there's no service configured, enabling the shortcut will have no effect
+            // It should already be disabled, but force the switch to off just in case
+            mToggleSwitch.setChecked(false);
+            mToggleSwitch.setEnabled(false);
+            mSwitchBar.setEnabled(false);
+        } else {
+            mToggleSwitch.setEnabled(true);
+            mSwitchBar.setEnabled(true);
+        }
+    }
+
+    /**
+     * Get the user-visible name of the service currently selected for the shortcut.
+     *
+     * @param context The current context
+     * @return The name of the service or a string saying that none is selected.
+     */
+    public static CharSequence getServiceName(Context context) {
+        ComponentName shortcutServiceName = ComponentName.unflattenFromString(
+                AccessibilityUtils.getShortcutTargetServiceComponentNameString(
+                        context, UserHandle.myUserId()));
+        AccessibilityServiceInfo shortcutServiceInfo = AccessibilityManager.getInstance(context)
+                .getInstalledServiceInfoWithComponentName(shortcutServiceName);
+        if (shortcutServiceInfo != null) {
+            return shortcutServiceInfo.getResolveInfo().loadLabel(context.getPackageManager());
+        }
+        return context.getString(R.string.accessibility_no_service_selected);
+    }
+
+    public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider() {
+                // This fragment is for details of the shortcut. Only the shortcut itself needs
+                // to be indexed.
+                protected boolean isPageSearchEnabled(Context context) {
+                    return false;
+                }
+            };
+}
diff --git a/src/com/android/settings/accessibility/MagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/MagnificationPreferenceFragment.java
new file mode 100644
index 0000000..22706d7
--- /dev/null
+++ b/src/com/android/settings/accessibility/MagnificationPreferenceFragment.java
@@ -0,0 +1,201 @@
+/*
+ * 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.accessibility;
+
+import android.accessibilityservice.AccessibilityServiceInfo;
+import android.content.ComponentName;
+import android.content.Context;
+import android.os.Bundle;
+import android.provider.SearchIndexableResource;
+import android.provider.Settings;
+import android.support.v7.preference.Preference;
+import android.text.TextUtils;
+import android.view.View;
+import android.view.accessibility.AccessibilityManager;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+
+import java.util.Arrays;
+import java.util.List;
+
+public final class MagnificationPreferenceFragment extends SettingsPreferenceFragment implements
+        Indexable {
+
+    // Settings App preference keys
+    private static final String MAGNIFICATION_GESTURES_PREFERENCE_SCREEN_KEY =
+            "screen_magnification_gestures_preference_screen";
+    private static final String MAGNIFICATION_NAVBAR_PREFERENCE_SCREEN_KEY =
+            "screen_magnification_navbar_preference_screen";
+
+    // Pseudo ComponentName used to represent navbar magnification in Settings.Secure.
+    private static final String MAGNIFICATION_COMPONENT_ID =
+            "com.android.server.accessibility.MagnificationController";
+
+    private Preference mMagnificationGesturesPreference;
+    private Preference mMagnificationNavbarPreference;
+
+    private boolean mLaunchedFromSuw = false;
+
+    @Override
+    public void onCreatePreferences(Bundle bundle, String s) {
+        addPreferencesFromResource(R.xml.accessibility_magnification_settings);
+        mMagnificationGesturesPreference = findPreference(
+                MAGNIFICATION_GESTURES_PREFERENCE_SCREEN_KEY);
+        mMagnificationNavbarPreference = findPreference(MAGNIFICATION_NAVBAR_PREFERENCE_SCREEN_KEY);
+    }
+
+    @Override
+    public void onViewCreated(View view, Bundle savedInstanceState) {
+        super.onViewCreated(view, savedInstanceState);
+
+        final Bundle args = getArguments();
+        if ((args != null) && args.containsKey(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW)) {
+            mLaunchedFromSuw = args.getBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW);
+        }
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        getActivity().setTitle(R.string.accessibility_screen_magnification_title);
+        updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
+                mMagnificationGesturesPreference);
+        updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
+                mMagnificationNavbarPreference);
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsEvent.ACCESSIBILITY_SCREEN_MAGNIFICATION_SETTINGS;
+    }
+
+    @Override
+    public boolean onPreferenceTreeClick(Preference preference) {
+        if (mLaunchedFromSuw) {
+            // If invoked from SUW, redirect to fragment instrumented for Vision Settings metrics
+            preference.setFragment(
+                    ToggleScreenMagnificationPreferenceFragmentForSetupWizard.class.getName());
+        }
+        if (mMagnificationGesturesPreference == preference) {
+            handleMagnificationGesturesPreferenceScreenClick();
+            super.onPreferenceTreeClick(mMagnificationGesturesPreference);
+            return true;
+        } else if (mMagnificationNavbarPreference == preference) {
+            handleMagnificationNavbarPreferenceScreenClick();
+            super.onPreferenceTreeClick(mMagnificationNavbarPreference);
+            return true;
+        }
+        return super.onPreferenceTreeClick(preference);
+    }
+
+    private void updateFeatureSummary(String prefKey, Preference pref) {
+        if (!mLaunchedFromSuw) {
+            final boolean enabled = Settings.Secure.getInt(getContentResolver(), prefKey, 0) == 1;
+            pref.setSummary(enabled ? R.string.accessibility_feature_state_on
+                    : R.string.accessibility_feature_state_off);
+        } else {
+            if (Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED.equals(prefKey)) {
+                pref.setSummary(R.string.accessibility_screen_magnification_short_summary);
+            } else if (Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED.equals(
+                    prefKey)) {
+                pref.setSummary(R.string.accessibility_screen_magnification_navbar_short_summary);
+            }
+        }
+    }
+
+    private void handleMagnificationGesturesPreferenceScreenClick() {
+        Bundle extras = mMagnificationGesturesPreference.getExtras();
+        extras.putString(AccessibilitySettings.EXTRA_PREFERENCE_KEY,
+                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED);
+        extras.putString(AccessibilitySettings.EXTRA_TITLE, getString(
+                R.string.accessibility_screen_magnification_gestures_title));
+        extras.putCharSequence(AccessibilitySettings.EXTRA_SUMMARY,
+                getActivity().getResources().getText(
+                        R.string.accessibility_screen_magnification_summary));
+        extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED,
+                Settings.Secure.getInt(getContentResolver(),
+                        Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1);
+        extras.putInt(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID,
+                R.raw.accessibility_screen_magnification);
+        extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, mLaunchedFromSuw);
+    }
+
+    private void handleMagnificationNavbarPreferenceScreenClick() {
+        Bundle extras = mMagnificationNavbarPreference.getExtras();
+        extras.putString(AccessibilitySettings.EXTRA_PREFERENCE_KEY,
+                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED);
+        extras.putString(AccessibilitySettings.EXTRA_TITLE, getString(
+                R.string.accessibility_screen_magnification_navbar_title));
+        extras.putCharSequence(AccessibilitySettings.EXTRA_SUMMARY,
+                getActivity().getResources().getText(
+                        R.string.accessibility_screen_magnification_navbar_summary));
+        extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED,
+                Settings.Secure.getInt(getContentResolver(),
+                        Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0)
+                        == 1);
+        extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, mLaunchedFromSuw);
+    }
+
+    static CharSequence getConfigurationWarningStringForSecureSettingsKey(String key,
+            Context context) {
+        if (!Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED.equals(key)) {
+            return null;
+        }
+        if (Settings.Secure.getInt(context.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0) == 0) {
+            return null;
+        }
+        final AccessibilityManager am = (AccessibilityManager) context.getSystemService(
+                Context.ACCESSIBILITY_SERVICE);
+        final String assignedId = Settings.Secure.getString(context.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT);
+        if (!TextUtils.isEmpty(assignedId) && !MAGNIFICATION_COMPONENT_ID.equals(assignedId)) {
+            final ComponentName assignedComponentName = ComponentName.unflattenFromString(
+                    assignedId);
+            final List<AccessibilityServiceInfo> activeServices =
+                    am.getEnabledAccessibilityServiceList(
+                            AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
+            final int serviceCount = activeServices.size();
+            for (int i = 0; i < serviceCount; i++) {
+                final AccessibilityServiceInfo info = activeServices.get(i);
+                if (info.getComponentName().equals(assignedComponentName)) {
+                    final CharSequence assignedServiceName = info.getResolveInfo().loadLabel(
+                            context.getPackageManager());
+                    return context.getString(
+                            R.string.accessibility_screen_magnification_navbar_configuration_warning,
+                            assignedServiceName);
+                }
+            }
+        }
+        return null;
+    }
+
+    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider() {
+                @Override
+                public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+                        boolean enabled) {
+                    final SearchIndexableResource sir = new SearchIndexableResource(context);
+                    sir.xmlResId = R.xml.accessibility_magnification_settings;
+                    return Arrays.asList(sir);
+                }
+            };
+}
diff --git a/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java b/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
new file mode 100644
index 0000000..8b6d52a
--- /dev/null
+++ b/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
@@ -0,0 +1,157 @@
+/*
+ * 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.accessibility;
+
+import android.accessibilityservice.AccessibilityServiceInfo;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.app.Fragment;
+import android.content.ComponentName;
+import android.content.DialogInterface;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageParser;
+import android.os.Bundle;
+import android.os.UserHandle;
+import android.provider.Settings;
+import android.support.v7.preference.Preference;
+import android.text.TextUtils;
+import android.view.accessibility.AccessibilityManager;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.DialogCreatable;
+import com.android.settings.applications.defaultapps.DefaultAppInfo;
+import com.android.settings.applications.defaultapps.DefaultAppPickerFragment;
+import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.widget.RadioButtonPreference;
+import com.android.settingslib.accessibility.AccessibilityUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Fragment for picking accessibility shortcut service
+ */
+public class ShortcutServicePickerFragment extends DefaultAppPickerFragment {
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsEvent.ACCESSIBILITY_TOGGLE_GLOBAL_GESTURE;
+    }
+
+    @Override
+    protected List<? extends DefaultAppInfo> getCandidates() {
+        final AccessibilityManager accessibilityManager = getContext()
+                .getSystemService(AccessibilityManager.class);
+        final List<AccessibilityServiceInfo> installedServices =
+                accessibilityManager.getInstalledAccessibilityServiceList();
+        final int numInstalledServices = installedServices.size();
+
+        List<DefaultAppInfo> candidates = new ArrayList<>(numInstalledServices);
+        for (int i = 0; i < numInstalledServices; i++) {
+            AccessibilityServiceInfo installedServiceInfo = installedServices.get(i);
+            candidates.add(new DefaultAppInfo(mPm,
+                    UserHandle.myUserId(),
+                    installedServiceInfo.getComponentName(),
+                    installedServiceInfo.loadSummary(mPm.getPackageManager()),
+                    true /* enabled */));
+        }
+
+        return candidates;
+    }
+
+    @Override
+    protected String getDefaultKey() {
+        String shortcutServiceString = AccessibilityUtils
+                .getShortcutTargetServiceComponentNameString(getContext(), UserHandle.myUserId());
+        if (shortcutServiceString != null) {
+            ComponentName shortcutName = ComponentName.unflattenFromString(shortcutServiceString);
+            if (shortcutName != null) {
+                return shortcutName.flattenToString();
+            }
+        }
+        return null;
+    }
+
+    @Override
+    protected boolean setDefaultKey(String key) {
+        Settings.Secure.putString(getContext().getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE, key);
+        return true;
+    }
+
+    @Override
+    public void onRadioButtonClicked(RadioButtonPreference selected) {
+        final String selectedKey = selected.getKey();
+
+        final Activity activity = getActivity();
+        if (TextUtils.isEmpty(selectedKey)) {
+            super.onRadioButtonClicked(selected);
+        } else if (activity != null) {
+            final DialogFragment fragment = ConfirmationDialogFragment.newInstance(
+                    this, selectedKey);
+            fragment.show(activity.getFragmentManager(), ConfirmationDialogFragment.TAG);
+        }
+    }
+
+    private void onServiceConfirmed(String serviceKey) {
+        onRadioButtonConfirmed(serviceKey);
+    }
+
+    public static class ConfirmationDialogFragment extends InstrumentedDialogFragment
+            implements DialogInterface.OnClickListener {
+        private static final String EXTRA_KEY = "extra_key";
+        private static final String TAG = "ConfirmationDialogFragment";
+
+        public static ConfirmationDialogFragment newInstance(ShortcutServicePickerFragment parent,
+                String key) {
+            final ConfirmationDialogFragment fragment = new ConfirmationDialogFragment();
+            final Bundle argument = new Bundle();
+            argument.putString(EXTRA_KEY, key);
+            fragment.setArguments(argument);
+            fragment.setTargetFragment(parent, 0);
+            return fragment;
+        }
+
+        @Override
+        public int getMetricsCategory() {
+            return MetricsEvent.ACCESSIBILITY_TOGGLE_GLOBAL_GESTURE;
+        }
+
+        @Override
+        public Dialog onCreateDialog(Bundle savedInstanceState) {
+            final Bundle bundle = getArguments();
+            final String key = bundle.getString(EXTRA_KEY);
+            final ComponentName serviceComponentName = ComponentName.unflattenFromString(key);
+            final AccessibilityManager accessibilityManager = getActivity()
+                    .getSystemService(AccessibilityManager.class);
+            AccessibilityServiceInfo info = accessibilityManager
+                    .getInstalledServiceInfoWithComponentName(serviceComponentName);
+            return AccessibilityServiceWarning.createCapabilitiesDialog(getActivity(), info, this);
+        }
+
+        @Override
+        public void onClick(DialogInterface dialog, int which) {
+            final Fragment fragment = getTargetFragment();
+            if (fragment instanceof DefaultAppPickerFragment) {
+                final Bundle bundle = getArguments();
+                ((ShortcutServicePickerFragment) fragment).onServiceConfirmed(
+                        bundle.getString(EXTRA_KEY));
+            }
+        }
+    }
+}
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 8f13e08..c6dc7a7 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -20,29 +20,28 @@
 import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.Point;
-import android.os.Bundle;
-import android.provider.Settings;
-
 import android.media.MediaPlayer;
 import android.media.MediaPlayer.OnPreparedListener;
 import android.net.Uri;
+import android.os.Bundle;
+import android.provider.Settings;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceScreen;
 import android.support.v7.preference.PreferenceViewHolder;
 import android.view.Display;
-import android.view.ViewTreeObserver;
 import android.view.ViewTreeObserver.OnGlobalLayoutListener;
 import android.view.WindowManager;
 import android.widget.ImageView;
-import android.widget.MediaController;
 import android.widget.RelativeLayout.LayoutParams;
+import android.widget.Switch;
 import android.widget.VideoView;
+
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
-import com.android.settings.widget.ToggleSwitch;
-import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
+import com.android.settings.widget.SwitchBar;
 
-public class ToggleScreenMagnificationPreferenceFragment extends ToggleFeaturePreferenceFragment {
+public class ToggleScreenMagnificationPreferenceFragment extends
+        ToggleFeaturePreferenceFragment implements SwitchBar.OnSwitchChangeListener {
 
     protected class VideoPreference extends Preference {
         private ImageView mVideoBackgroundView;
@@ -77,10 +76,15 @@
                 }
             });
 
-            videoView.setVideoURI(Uri.parse(String.format("%s://%s/%s",
-                    ContentResolver.SCHEME_ANDROID_RESOURCE,
-                    getPrefContext().getPackageName(),
-                    R.raw.accessibility_screen_magnification)));
+            // Resolve and set the video content
+            Bundle args = getArguments();
+            if ((args != null) && args.containsKey(
+                    AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID)) {
+                videoView.setVideoURI(Uri.parse(String.format("%s://%s/%s",
+                        ContentResolver.SCHEME_ANDROID_RESOURCE,
+                        getPrefContext().getPackageName(),
+                        args.getInt(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID))));
+            }
             // Make sure video controls (e.g. for pausing) are not displayed.
             videoView.setMediaController(null);
 
@@ -112,6 +116,10 @@
     }
 
     protected VideoPreference mVideoPreference;
+    protected Preference mConfigWarningPreference;
+
+    private boolean mLaunchFromSuw = false;
+    private boolean mInitialSetting = false;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
@@ -122,66 +130,99 @@
         mVideoPreference.setPersistent(false);
         mVideoPreference.setLayoutResource(R.layout.magnification_video_preference);
 
+        mConfigWarningPreference = new Preference(getPrefContext());
+        mConfigWarningPreference.setSelectable(false);
+        mConfigWarningPreference.setPersistent(false);
+        mConfigWarningPreference.setVisible(false);
+        mConfigWarningPreference.setIcon(R.drawable.ic_warning_24dp);
+
         final PreferenceScreen preferenceScreen = getPreferenceManager().getPreferenceScreen();
         preferenceScreen.setOrderingAsAdded(false);
         mVideoPreference.setOrder(0);
         mSummaryPreference.setOrder(1);
+        mConfigWarningPreference.setOrder(2);
         preferenceScreen.addPreference(mVideoPreference);
-    }
-
-    @Override
-    protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
-        // Do nothing.
-    }
-
-    @Override
-    protected void onInstallSwitchBarToggleSwitch() {
-        super.onInstallSwitchBarToggleSwitch();
-        mToggleSwitch.setOnBeforeCheckedChangeListener(new OnBeforeCheckedChangeListener() {
-            @Override
-            public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
-                mSwitchBar.setCheckedInternal(checked);
-                getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, checked);
-                onPreferenceToggled(mPreferenceKey, checked);
-                return false;
-            }
-        });
+        preferenceScreen.addPreference(mConfigWarningPreference);
     }
 
     @Override
     public void onResume() {
         super.onResume();
 
-        // Temporarily enable Magnification on this screen if it's disabled.
-        if (Settings.Secure.getInt(getContentResolver(),
-                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 0) {
-            setMagnificationEnabled(1);
-        }
-
         VideoView videoView = (VideoView) getView().findViewById(R.id.video);
         if (videoView != null) {
             videoView.start();
         }
-    }
 
-    @Override
-    public void onPause() {
-        super.onPause();
-        if (!mToggleSwitch.isChecked()) {
-            setMagnificationEnabled(0);
-        }
-    }
-
-    private void setMagnificationEnabled(int enabled) {
-        Settings.Secure.putInt(getContentResolver(),
-                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, enabled);
+        updateConfigurationWarningIfNeeded();
     }
 
     @Override
     public int getMetricsCategory() {
+        // TODO: Distinguish between magnification modes
         return MetricsEvent.ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION;
     }
 
+    @Override
+    public void onSwitchChanged(Switch switchView, boolean isChecked) {
+        onPreferenceToggled(mPreferenceKey, isChecked);
+    }
+
+    @Override
+    protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
+        Settings.Secure.putInt(getContentResolver(), preferenceKey, enabled ? 1 : 0);
+        updateConfigurationWarningIfNeeded();
+    }
+
+    @Override
+    protected void onInstallSwitchBarToggleSwitch() {
+        super.onInstallSwitchBarToggleSwitch();
+
+        mSwitchBar.setCheckedInternal(
+                Settings.Secure.getInt(getContentResolver(), mPreferenceKey, 0) == 1);
+        mSwitchBar.addOnSwitchChangeListener(this);
+    }
+
+    @Override
+    protected void onRemoveSwitchBarToggleSwitch() {
+        super.onRemoveSwitchBarToggleSwitch();
+        mSwitchBar.removeOnSwitchChangeListener(this);
+    }
+
+    @Override
+    protected void onProcessArguments(Bundle arguments) {
+        super.onProcessArguments(arguments);
+        if (arguments == null) {
+            return;
+        }
+
+        if (arguments.containsKey(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID)) {
+            mVideoPreference.setVisible(true);
+            final int resId = arguments.getInt(
+                    AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID);
+        } else {
+            mVideoPreference.setVisible(false);
+        }
+
+        if (arguments.containsKey(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW)) {
+            mLaunchFromSuw = arguments.getBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW);
+        }
+
+        if (arguments.containsKey(AccessibilitySettings.EXTRA_CHECKED)) {
+            mInitialSetting = arguments.getBoolean(AccessibilitySettings.EXTRA_CHECKED);
+        }
+    }
+
+    private void updateConfigurationWarningIfNeeded() {
+        final CharSequence warningMessage =
+                MagnificationPreferenceFragment.getConfigurationWarningStringForSecureSettingsKey(
+                        mPreferenceKey, getPrefContext());
+        if (warningMessage != null) {
+            mConfigWarningPreference.setSummary(warningMessage);
+        }
+        mConfigWarningPreference.setVisible(warningMessage != null);
+    }
+
     private static int getScreenWidth(Context context) {
         WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
         Display display = wm.getDefaultDisplay();
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java
index ab0790b..4338172 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java
@@ -24,14 +24,6 @@
 public class ToggleScreenMagnificationPreferenceFragmentForSetupWizard
         extends ToggleScreenMagnificationPreferenceFragment {
 
-    private boolean mToggleSwitchWasInitiallyChecked;
-
-    @Override
-    protected void onProcessArguments(Bundle arguments) {
-        super.onProcessArguments(arguments);
-        mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
-    }
-
     @Override
     public int getMetricsCategory() {
         return MetricsEvent.SUW_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION;
@@ -40,12 +32,15 @@
     @Override
     public void onStop() {
         // Log the final choice in value if it's different from the previous value.
-        if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
-            mMetricsFeatureProvider.action(getContext(),
-                    MetricsEvent.SUW_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION,
-                    mToggleSwitch.isChecked());
+        Bundle args = getArguments();
+        if ((args != null) && args.containsKey(AccessibilitySettings.EXTRA_CHECKED)) {
+            if (mToggleSwitch.isChecked() != args.getBoolean(AccessibilitySettings.EXTRA_CHECKED)) {
+                // TODO: Distinguish between magnification modes
+                mMetricsFeatureProvider.action(getContext(),
+                        MetricsEvent.SUW_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION,
+                        mToggleSwitch.isChecked());
+            }
         }
-
         super.onStop();
     }
 }
diff --git a/src/com/android/settings/applications/ApplicationFeatureProvider.java b/src/com/android/settings/applications/ApplicationFeatureProvider.java
index 51e79d8..1855308 100644
--- a/src/com/android/settings/applications/ApplicationFeatureProvider.java
+++ b/src/com/android/settings/applications/ApplicationFeatureProvider.java
@@ -30,22 +30,13 @@
     AppHeaderController newAppHeaderController(Fragment fragment, View appHeader);
 
     /**
-     * Count all installed packages, irrespective of install reason.
-     */
-    public static final int IGNORE_INSTALL_REASON = -1;
-
-    /**
-     * Calculates the total number of apps installed on the device, across all users and managed
-     * profiles.
+     * Calculates the total number of apps installed on the device via policy across all users
+     * and managed profiles.
      *
-     * @param installReason Only consider apps with this install reason; may be any install reason
-     *         defined in {@link android.content.pm.PackageManager} or
-     *         {@link #IGNORE_INSTALL_REASON} to count all apps, irrespective of install reason.
      * @param async Whether to count asynchronously in a background thread
      * @param callback The callback to invoke with the result
      */
-    void calculateNumberOfInstalledApps(int installReason, boolean async,
-            NumberOfAppsCallback callback);
+    void calculateNumberOfPolicyInstalledApps(boolean async, NumberOfAppsCallback callback);
 
     /**
      * Asynchronously calculates the total number of apps installed on the device, across all users
diff --git a/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java b/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
index 77c9f3e..ca19dca 100644
--- a/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
+++ b/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
@@ -20,6 +20,7 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.ComponentInfo;
+import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.content.pm.UserInfo;
 import android.os.RemoteException;
@@ -56,10 +57,9 @@
     }
 
     @Override
-    public void calculateNumberOfInstalledApps(int installReason, boolean async,
-            NumberOfAppsCallback callback) {
-        final AllUserInstalledAppCounter counter = new AllUserInstalledAppCounter(mContext,
-                installReason, mPm, callback);
+    public void calculateNumberOfPolicyInstalledApps(boolean async, NumberOfAppsCallback callback) {
+        final AllUserPolicyInstalledAppCounter counter =
+                new AllUserPolicyInstalledAppCounter(mContext, mPm, callback);
         if (async) {
             counter.execute();
         } else {
@@ -113,12 +113,12 @@
         return activities;
     }
 
-    private static class AllUserInstalledAppCounter extends InstalledAppCounter {
+    private static class AllUserPolicyInstalledAppCounter extends InstalledAppCounter {
         private NumberOfAppsCallback mCallback;
 
-        AllUserInstalledAppCounter(Context context, int installReason,
-                PackageManagerWrapper packageManager, NumberOfAppsCallback callback) {
-            super(context, installReason, packageManager);
+        AllUserPolicyInstalledAppCounter(Context context, PackageManagerWrapper packageManager,
+                                         NumberOfAppsCallback callback) {
+            super(context, PackageManager.INSTALL_REASON_POLICY, packageManager);
             mCallback = callback;
         }
 
diff --git a/src/com/android/settings/applications/InstalledAppCounter.java b/src/com/android/settings/applications/InstalledAppCounter.java
index 251b0a2..8065d49 100644
--- a/src/com/android/settings/applications/InstalledAppCounter.java
+++ b/src/com/android/settings/applications/InstalledAppCounter.java
@@ -25,6 +25,11 @@
 
 public abstract class InstalledAppCounter extends AppCounter {
 
+    /**
+     * Count all installed packages, irrespective of install reason.
+     */
+    public static final int IGNORE_INSTALL_REASON = -1;
+
     private final int mInstallReason;
     private final PackageManagerWrapper mPackageManager;
 
@@ -38,7 +43,7 @@
     @Override
     protected boolean includeInCount(ApplicationInfo info) {
         final int userId = UserHandle.getUserId(info.uid);
-        if (mInstallReason != ApplicationFeatureProvider.IGNORE_INSTALL_REASON
+        if (mInstallReason != IGNORE_INSTALL_REASON
                 && mPackageManager.getInstallReason(info.packageName,
                         new UserHandle(userId)) != mInstallReason) {
             return false;
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index e00ba92..dac10e7 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -546,7 +546,7 @@
             .newAppHeaderController(this, appSnippet)
             .setLabel(mAppEntry)
             .setIcon(mAppEntry)
-            .setSummary(getString(getInstallationStatus(mAppEntry.info)))
+            .setSummary(getString(Utils.getInstallationStatus(mAppEntry.info)))
             .setIsInstantApp(AppUtils.isInstant(mPackageInfo.applicationInfo))
             .done(false /* rebindActions */);
         mVersionPreference.setSummary(getString(R.string.version_text, pkgInfo.versionName));
@@ -574,14 +574,6 @@
         return showIt;
     }
 
-    @VisibleForTesting
-    int getInstallationStatus(ApplicationInfo info) {
-        if ((info.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
-            return R.string.not_installed;
-        }
-        return info.enabled ? R.string.installed : R.string.disabled;
-    }
-
     private boolean signaturesMatch(String pkg1, String pkg2) {
         if (pkg1 != null && pkg2 != null) {
             try {
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index 826e5db..f83dfeb 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -69,7 +69,6 @@
 import com.android.settings.SettingsActivity;
 import com.android.settings.Utils;
 import com.android.settings.applications.AppStateAppOpsBridge.PermissionState;
-import com.android.settings.applications.AppStateInstallAppsBridge.InstallAppsState;
 import com.android.settings.applications.AppStateUsageBridge.UsageState;
 import com.android.settings.core.InstrumentedPreferenceFragment;
 import com.android.settings.dashboard.SummaryLoader;
@@ -1398,7 +1397,7 @@
         @Override
         public void setListening(boolean listening) {
             if (listening) {
-                new InstalledAppCounter(mContext, ApplicationFeatureProvider.IGNORE_INSTALL_REASON,
+                new InstalledAppCounter(mContext, InstalledAppCounter.IGNORE_INSTALL_REASON,
                         new PackageManagerWrapperImpl(mContext.getPackageManager())) {
                     @Override
                     protected void onCountComplete(int num) {
diff --git a/src/com/android/settings/applications/ResetAppPrefPreferenceController.java b/src/com/android/settings/applications/ResetAppPrefPreferenceController.java
new file mode 100644
index 0000000..41352bb
--- /dev/null
+++ b/src/com/android/settings/applications/ResetAppPrefPreferenceController.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.applications;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v7.preference.Preference;
+import android.text.TextUtils;
+
+import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.core.lifecycle.LifecycleObserver;
+import com.android.settings.core.lifecycle.events.OnCreate;
+import com.android.settings.core.lifecycle.events.OnSaveInstanceState;
+
+public class ResetAppPrefPreferenceController extends PreferenceController
+        implements LifecycleObserver, OnCreate, OnSaveInstanceState {
+
+    private ResetAppsHelper mResetAppsHelper;
+
+    public ResetAppPrefPreferenceController(Context context, Lifecycle lifecycle) {
+        super(context);
+        mResetAppsHelper = new ResetAppsHelper(context);
+        if (lifecycle != null) {
+            lifecycle.addObserver(this);
+        }
+    }
+
+    @Override
+    public boolean handlePreferenceTreeClick(Preference preference) {
+        if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
+            return false;
+        }
+        mResetAppsHelper.buildResetDialog();
+        return true;
+    }
+
+    @Override
+    public boolean isAvailable() {
+        return true;
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return "reset_app_prefs";
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        mResetAppsHelper.onRestoreInstanceState(savedInstanceState);
+    }
+
+    @Override
+    public void onSaveInstanceState(Bundle outState) {
+        mResetAppsHelper.onSaveInstanceState(outState);
+    }
+}
diff --git a/src/com/android/settings/applications/ResetAppsHelper.java b/src/com/android/settings/applications/ResetAppsHelper.java
index ddcb244..93d384d 100644
--- a/src/com/android/settings/applications/ResetAppsHelper.java
+++ b/src/com/android/settings/applications/ResetAppsHelper.java
@@ -15,6 +15,9 @@
  */
 package com.android.settings.applications;
 
+import static android.net.NetworkPolicyManager.POLICY_NONE;
+import static android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND;
+
 import android.app.ActivityManager;
 import android.app.AlertDialog;
 import android.app.AppOpsManager;
@@ -36,9 +39,6 @@
 
 import java.util.List;
 
-import static android.net.NetworkPolicyManager.POLICY_NONE;
-import static android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND;
-
 public class ResetAppsHelper implements DialogInterface.OnClickListener,
         DialogInterface.OnDismissListener {
 
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAppInfo.java b/src/com/android/settings/applications/defaultapps/DefaultAppInfo.java
index e99b106..b40943f 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAppInfo.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAppInfo.java
@@ -20,6 +20,7 @@
 import android.content.ComponentName;
 import android.content.pm.ActivityInfo;
 import android.content.pm.ApplicationInfo;
+import android.content.pm.ComponentInfo;
 import android.content.pm.PackageItemInfo;
 import android.content.pm.PackageManager;
 import android.graphics.drawable.Drawable;
@@ -76,16 +77,15 @@
     public CharSequence loadLabel() {
         if (componentName != null) {
             try {
-                final ActivityInfo actInfo = AppGlobals.getPackageManager().getActivityInfo(
-                        componentName, 0, userId);
-                if (actInfo != null) {
-                    return actInfo.loadLabel(mPm.getPackageManager());
+                final ComponentInfo componentInfo = getComponentInfo();
+                if (componentInfo != null) {
+                    return componentInfo.loadLabel(mPm.getPackageManager());
                 } else {
                     final ApplicationInfo appInfo = mPm.getApplicationInfoAsUser(
                             componentName.getPackageName(), 0, userId);
                     return appInfo.loadLabel(mPm.getPackageManager());
                 }
-            } catch (RemoteException | PackageManager.NameNotFoundException e) {
+            } catch (PackageManager.NameNotFoundException e) {
                 return null;
             }
         } else if (packageItemInfo != null) {
@@ -100,16 +100,15 @@
     public Drawable loadIcon() {
         if (componentName != null) {
             try {
-                final ActivityInfo actInfo = AppGlobals.getPackageManager().getActivityInfo(
-                        componentName, 0, userId);
-                if (actInfo != null) {
-                    return actInfo.loadIcon(mPm.getPackageManager());
+                final ComponentInfo componentInfo = getComponentInfo();
+                if (componentInfo != null) {
+                    return componentInfo.loadIcon(mPm.getPackageManager());
                 } else {
                     final ApplicationInfo appInfo = mPm.getApplicationInfoAsUser(
                             componentName.getPackageName(), 0, userId);
                     return appInfo.loadIcon(mPm.getPackageManager());
                 }
-            } catch (RemoteException | PackageManager.NameNotFoundException e) {
+            } catch (PackageManager.NameNotFoundException e) {
                 return null;
             }
         }
@@ -130,4 +129,18 @@
             return null;
         }
     }
+
+    private ComponentInfo getComponentInfo() {
+        try {
+            ComponentInfo componentInfo = AppGlobals.getPackageManager().getActivityInfo(
+                    componentName, 0, userId);
+            if (componentInfo == null) {
+                componentInfo = AppGlobals.getPackageManager().getServiceInfo(
+                        componentName, 0, userId);
+            }
+            return componentInfo;
+        } catch (RemoteException e) {
+            return null;
+        }
+    }
 }
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java b/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java
index d08ac99..98557ee 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java
@@ -61,7 +61,6 @@
         }
     }
 
-
     @Override
     public void bindPreferenceExtra(RadioButtonPreference pref,
             String key, CandidateInfo info, String defaultKey, String systemDefaultKey) {
diff --git a/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java b/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java
index dc37efc..282f613 100644
--- a/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java
@@ -98,13 +98,13 @@
         }
         switch (mConnectionState) {
             case BluetoothAdapter.STATE_CONNECTED:
-                return mContext.getString(R.string.bluetooth_connected);
+                return mContext.getString(R.string.bluetooth_connected_summary);
             case BluetoothAdapter.STATE_CONNECTING:
                 return mContext.getString(R.string.bluetooth_connecting);
             case BluetoothAdapter.STATE_DISCONNECTING:
                 return mContext.getString(R.string.bluetooth_disconnecting);
             default:
-                return mContext.getString(R.string.bluetooth_disconnected);
+                return mContext.getString(R.string.disconnected);
         }
     }
 
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 59cedf8..d1bb9d6 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -103,7 +103,6 @@
 import com.android.settings.notification.NotificationStation;
 import com.android.settings.notification.SoundSettings;
 import com.android.settings.notification.ZenAccessSettings;
-import com.android.settings.notification.ZenModeAutomationSettings;
 import com.android.settings.notification.ZenModeEventRuleSettings;
 import com.android.settings.notification.ZenModePrioritySettings;
 import com.android.settings.notification.ZenModeScheduleRuleSettings;
@@ -113,6 +112,7 @@
 import com.android.settings.print.PrintSettingsFragment;
 import com.android.settings.security.LockscreenDashboardFragment;
 import com.android.settings.sim.SimSettings;
+import com.android.settings.system.ResetDashboardFragment;
 import com.android.settings.system.SystemDashboardFragment;
 import com.android.settings.tts.TextToSpeechSettings;
 import com.android.settings.users.UserSettings;
@@ -206,7 +206,6 @@
             ApnEditor.class.getName(),
             WifiCallingSettings.class.getName(),
             ZenModePrioritySettings.class.getName(),
-            ZenModeAutomationSettings.class.getName(),
             ZenModeScheduleRuleSettings.class.getName(),
             ZenModeEventRuleSettings.class.getName(),
             ZenModeVisualInterruptionSettings.class.getName(),
@@ -231,6 +230,7 @@
             WifiAPITest.class.getName(),
             WifiInfo.class.getName(),
             MasterClear.class.getName(),
+            ResetDashboardFragment.class.getName(),
             NightDisplaySettings.class.getName(),
             ManageDomainUrls.class.getName(),
             AutomaticStorageManagerSettings.class.getName(),
diff --git a/src/com/android/settings/deviceinfo/DeviceModelPreferenceController.java b/src/com/android/settings/deviceinfo/DeviceModelPreferenceController.java
index a2c4302..ac3870a 100644
--- a/src/com/android/settings/deviceinfo/DeviceModelPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/DeviceModelPreferenceController.java
@@ -46,7 +46,7 @@
         super.displayPreference(screen);
         final Preference pref = screen.findPreference(KEY_DEVICE_MODEL);
         if (pref != null) {
-            pref.setSummary(Build.MODEL + DeviceInfoUtils.getMsvSuffix());
+            pref.setSummary(getDeviceModel());
         }
     }
 
@@ -64,4 +64,8 @@
         fragment.show(mHost.getFragmentManager(), HardwareInfoDialogFragment.TAG);
         return true;
     }
+
+    public static String getDeviceModel() {
+        return Build.MODEL + DeviceInfoUtils.getMsvSuffix();
+    }
 }
diff --git a/src/com/android/settings/deviceinfo/HardwareInfoDialogFragment.java b/src/com/android/settings/deviceinfo/HardwareInfoDialogFragment.java
index d68b47a..60082c7 100644
--- a/src/com/android/settings/deviceinfo/HardwareInfoDialogFragment.java
+++ b/src/com/android/settings/deviceinfo/HardwareInfoDialogFragment.java
@@ -18,7 +18,6 @@
 
 import android.app.AlertDialog;
 import android.app.Dialog;
-import android.os.Build;
 import android.os.Bundle;
 import android.os.SystemProperties;
 import android.support.annotation.VisibleForTesting;
@@ -30,7 +29,6 @@
 import com.android.internal.logging.nano.MetricsProto;
 import com.android.settings.R;
 import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-import com.android.settingslib.DeviceInfoUtils;
 
 public class HardwareInfoDialogFragment extends InstrumentedDialogFragment {
 
@@ -55,7 +53,7 @@
                 .inflate(R.layout.dialog_hardware_info, null /* parent */);
         // Model
         setText(content, R.id.model_label, R.id.model_value,
-                Build.MODEL + DeviceInfoUtils.getMsvSuffix());
+                DeviceModelPreferenceController.getDeviceModel());
         // Hardware rev
         setText(content, R.id.hardware_rev_label, R.id.hardware_rev_value,
                 SystemProperties.get("ro.boot.hardware.revision"));
diff --git a/src/com/android/settings/deviceinfo/StorageProfileFragment.java b/src/com/android/settings/deviceinfo/StorageProfileFragment.java
index 1a24962..c5d1045 100644
--- a/src/com/android/settings/deviceinfo/StorageProfileFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageProfileFragment.java
@@ -73,8 +73,7 @@
 
         mPreferenceController.setVolume(mVolume);
         mUserId = args.getInt(USER_ID_EXTRA, UserHandle.myUserId());
-        // TODO(b/36224168): Use the user id to appropriately badge the preferences.
-        mPreferenceController.setUserId(mUserId);
+        mPreferenceController.setUserId(UserHandle.of(mUserId));
     }
 
     @Override
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index e22aa24..5b27592 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -20,6 +20,9 @@
 import android.content.ActivityNotFoundException;
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.UserHandle;
 import android.os.storage.VolumeInfo;
@@ -165,8 +168,35 @@
     /**
      * Sets the user id for which this preference controller is handling.
      */
-    public void setUserId(int userId) {
-        mUserId = userId;
+    public void setUserId(UserHandle userHandle) {
+        mUserId = userHandle.getIdentifier();
+
+        PackageManager pm = mContext.getPackageManager();
+        badgePreference(pm, userHandle, mPhotoPreference);
+        badgePreference(pm, userHandle, mAudioPreference);
+        badgePreference(pm, userHandle, mGamePreference);
+        badgePreference(pm, userHandle, mAppPreference);
+        badgePreference(pm, userHandle, mSystemPreference);
+        badgePreference(pm, userHandle, mFilePreference);
+    }
+
+    private void badgePreference(PackageManager pm, UserHandle userHandle, Preference preference) {
+        if (preference != null) {
+            Drawable currentIcon = preference.getIcon();
+            // Sigh... Applying the badge to the icon clobbers the tint on the base drawable.
+            // For some reason, re-applying it here means the tint remains.
+            currentIcon = applyTint(mContext, currentIcon);
+            preference.setIcon(pm.getUserBadgedIcon(currentIcon, userHandle));
+        }
+    }
+
+    private static Drawable applyTint(Context context, Drawable icon) {
+        TypedArray array =
+                context.obtainStyledAttributes(new int[]{android.R.attr.colorControlNormal});
+        icon = icon.mutate();
+        icon.setTint(array.getColor(0, 0));
+        array.recycle();
+        return icon;
     }
 
     @Override
diff --git a/src/com/android/settings/display/VrDisplayPreferenceController.java b/src/com/android/settings/display/VrDisplayPreferenceController.java
index 0eb1c88..4fef987 100644
--- a/src/com/android/settings/display/VrDisplayPreferenceController.java
+++ b/src/com/android/settings/display/VrDisplayPreferenceController.java
@@ -17,17 +17,13 @@
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.provider.Settings;
-import android.support.v7.preference.DropDownPreference;
 import android.support.v7.preference.Preference;
-import android.util.Log;
 
 import com.android.settings.R;
 import com.android.settings.core.PreferenceController;
 
-public class VrDisplayPreferenceController extends PreferenceController implements
-        Preference.OnPreferenceChangeListener {
+public class VrDisplayPreferenceController extends PreferenceController {
 
-    private static final String TAG = "VrDisplayPrefContr";
     private static final String KEY_VR_DISPLAY_PREF = "vr_display_pref";
 
     public VrDisplayPreferenceController(Context context) {
@@ -47,31 +43,14 @@
 
     @Override
     public void updateState(Preference preference) {
-        final DropDownPreference pref = (DropDownPreference) preference;
-        pref.setEntries(new CharSequence[]{
-                mContext.getString(R.string.display_vr_pref_low_persistence),
-                mContext.getString(R.string.display_vr_pref_off),
-        });
-        pref.setEntryValues(new CharSequence[]{"0", "1"});
-
         int currentUser = ActivityManager.getCurrentUser();
         int current = Settings.Secure.getIntForUser(mContext.getContentResolver(),
-                Settings.Secure.VR_DISPLAY_MODE,
-                            /*default*/Settings.Secure.VR_DISPLAY_MODE_LOW_PERSISTENCE,
+                Settings.Secure.VR_DISPLAY_MODE, Settings.Secure.VR_DISPLAY_MODE_LOW_PERSISTENCE,
                 currentUser);
-        pref.setValueIndex(current);
-    }
-
-    @Override
-    public boolean onPreferenceChange(Preference preference, Object newValue) {
-        int i = Integer.parseInt((String) newValue);
-        int u = ActivityManager.getCurrentUser();
-        if (!Settings.Secure.putIntForUser(mContext.getContentResolver(),
-                Settings.Secure.VR_DISPLAY_MODE,
-                i, u)) {
-            Log.e(TAG, "Could not change setting for " +
-                    Settings.Secure.VR_DISPLAY_MODE);
+        if (current == 0) {
+            preference.setSummary(R.string.display_vr_pref_low_persistence);
+        } else {
+            preference.setSummary(R.string.display_vr_pref_off);
         }
-        return true;
     }
 }
diff --git a/src/com/android/settings/display/VrDisplayPreferencePicker.java b/src/com/android/settings/display/VrDisplayPreferencePicker.java
new file mode 100644
index 0000000..bccdaa5
--- /dev/null
+++ b/src/com/android/settings/display/VrDisplayPreferencePicker.java
@@ -0,0 +1,99 @@
+/*
+ * 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.display;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.provider.Settings;
+import android.text.TextUtils;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.widget.RadioButtonPickerFragment;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class VrDisplayPreferencePicker extends RadioButtonPickerFragment {
+
+    static final String PREF_KEY_PREFIX = "vr_display_pref_";
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsProto.MetricsEvent.VR_DISPLAY_PREFERENCE;
+    }
+
+    @Override
+    protected List<VrCandidateInfo> getCandidates() {
+        List<VrCandidateInfo> candidates = new ArrayList<>();
+        final Context context = getContext();
+        candidates.add(new VrCandidateInfo(context, 0, R.string.display_vr_pref_low_persistence));
+        candidates.add(new VrCandidateInfo(context, 1, R.string.display_vr_pref_off));
+        return candidates;
+    }
+
+    @Override
+    protected String getDefaultKey() {
+        int current = Settings.Secure.getIntForUser(getContext().getContentResolver(),
+                Settings.Secure.VR_DISPLAY_MODE, Settings.Secure.VR_DISPLAY_MODE_LOW_PERSISTENCE,
+                mUserId);
+        return PREF_KEY_PREFIX + current;
+    }
+
+    @Override
+    protected boolean setDefaultKey(String key) {
+        if (TextUtils.isEmpty(key)) {
+            return false;
+        }
+        switch (key) {
+            case PREF_KEY_PREFIX + 0:
+                return Settings.Secure.putIntForUser(getContext().getContentResolver(),
+                        Settings.Secure.VR_DISPLAY_MODE, 0, mUserId);
+            case PREF_KEY_PREFIX + 1:
+                return Settings.Secure.putIntForUser(getContext().getContentResolver(),
+                        Settings.Secure.VR_DISPLAY_MODE, 1, mUserId);
+        }
+        return false;
+    }
+
+    static class VrCandidateInfo extends CandidateInfo {
+
+        public final String label;
+        public final int value;
+
+        public VrCandidateInfo(Context context, int value, int resId) {
+            super(true);
+            this.value = value;
+            label = context.getString(resId);
+        }
+
+        @Override
+        public CharSequence loadLabel() {
+            return label;
+        }
+
+        @Override
+        public Drawable loadIcon() {
+            return null;
+        }
+
+        @Override
+        public String getKey() {
+            return PREF_KEY_PREFIX + value;
+        }
+    }
+}
diff --git a/src/com/android/settings/enterprise/DevicePolicyManagerWrapper.java b/src/com/android/settings/enterprise/DevicePolicyManagerWrapper.java
index ed9dd94..e988fda 100644
--- a/src/com/android/settings/enterprise/DevicePolicyManagerWrapper.java
+++ b/src/com/android/settings/enterprise/DevicePolicyManagerWrapper.java
@@ -81,6 +81,20 @@
             String permission);
 
     /**
+     * Calls {@code DevicePolicyManager.isSecurityLoggingEnabled()}.
+     *
+     * @see android.app.admin.DevicePolicyManager#isSecurityLoggingEnabled
+     */
+    boolean isSecurityLoggingEnabled(@Nullable ComponentName admin);
+
+    /**
+     * Calls {@code DevicePolicyManager.isNetworkLoggingEnabled()}.
+     *
+     * @see android.app.admin.DevicePolicyManager#isNetworkLoggingEnabled
+     */
+    boolean isNetworkLoggingEnabled(@Nullable ComponentName admin);
+
+    /**
      * Calls {@code DevicePolicyManager.getLastSecurityLogRetrievalTime()}.
      *
      * @see android.app.admin.DevicePolicyManager#getLastSecurityLogRetrievalTime
diff --git a/src/com/android/settings/enterprise/DevicePolicyManagerWrapperImpl.java b/src/com/android/settings/enterprise/DevicePolicyManagerWrapperImpl.java
index 647b4a7..18563b5 100644
--- a/src/com/android/settings/enterprise/DevicePolicyManagerWrapperImpl.java
+++ b/src/com/android/settings/enterprise/DevicePolicyManagerWrapperImpl.java
@@ -68,6 +68,16 @@
     }
 
     @Override
+    public boolean isSecurityLoggingEnabled(@Nullable ComponentName admin) {
+        return mDpm.isSecurityLoggingEnabled(admin);
+    }
+
+    @Override
+    public boolean isNetworkLoggingEnabled(@Nullable ComponentName admin) {
+        return mDpm.isNetworkLoggingEnabled(admin);
+    }
+
+    @Override
     public long getLastSecurityLogRetrievalTime() {
         return mDpm.getLastSecurityLogRetrievalTime();
     }
diff --git a/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceController.java b/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceController.java
index e70396d..acbcc2e 100644
--- a/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceController.java
+++ b/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceController.java
@@ -14,8 +14,6 @@
 package com.android.settings.enterprise;
 
 import android.content.Context;
-import android.content.pm.PackageManager;
-import android.content.res.Resources;
 import android.support.v7.preference.Preference;
 
 import com.android.settings.R;
@@ -42,8 +40,7 @@
 
     @Override
     public void updateState(Preference preference) {
-        mFeatureProvider.calculateNumberOfInstalledApps(
-                PackageManager.INSTALL_REASON_POLICY, true /* async */,
+        mFeatureProvider.calculateNumberOfPolicyInstalledApps(true /* async */,
                 (num) -> {
                     if (num == 0) {
                         preference.setVisible(false);
@@ -69,8 +66,8 @@
         // changes to the pref's visibility made in updateState() would not be seen by the indexer.
         // We block and return synchronously whether there are enterprise-installed apps or not.
         final Boolean[] haveEnterpriseInstalledPackages = { null };
-        mFeatureProvider.calculateNumberOfInstalledApps(PackageManager.INSTALL_REASON_POLICY,
-                false /* async */, (num) -> haveEnterpriseInstalledPackages[0] = num > 0);
+        mFeatureProvider.calculateNumberOfPolicyInstalledApps(false /* async */,
+                (num) -> haveEnterpriseInstalledPackages[0] = num > 0);
         return haveEnterpriseInstalledPackages[0];
     }
 
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java
index 4478865..4ad0f2e 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java
@@ -64,6 +64,16 @@
     Date getLastNetworkLogRetrievalTime();
 
     /**
+     * Returns whether security logging is currently enabled.
+     */
+    boolean isSecurityLoggingEnabled();
+
+    /**
+     * Returns whether network logging is currently enabled.
+     */
+    boolean isNetworkLoggingEnabled();
+
+    /**
      * Returns whether the Device Owner in the primary user set an always-on VPN.
      */
     boolean isAlwaysOnVpnSetInPrimaryUser();
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
index 69eaa2e..6d038dc 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
@@ -132,6 +132,16 @@
     }
 
     @Override
+    public boolean isSecurityLoggingEnabled() {
+        return mDpm.isSecurityLoggingEnabled(null);
+    }
+
+    @Override
+    public boolean isNetworkLoggingEnabled() {
+        return mDpm.isNetworkLoggingEnabled(null);
+    }
+
+    @Override
     public boolean isAlwaysOnVpnSetInPrimaryUser() {
         return VpnUtils.isAlwaysOnVpnSet(mCm, MY_USER_ID);
     }
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacySettings.java b/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
index 55ec3ea..9649d84 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
@@ -58,7 +58,6 @@
     private static List<PreferenceController> buildPreferenceControllers(Context context,
             Lifecycle lifecycle, boolean async) {
         final List controllers = new ArrayList<PreferenceController>();
-        controllers.add(new InstalledPackagesPreferenceController(context));
         controllers.add(new NetworkLogsPreferenceController(context));
         controllers.add(new BugReportsPreferenceController(context));
         controllers.add(new SecurityLogsPreferenceController(context));
diff --git a/src/com/android/settings/enterprise/InstalledPackagesPreferenceController.java b/src/com/android/settings/enterprise/InstalledPackagesPreferenceController.java
deleted file mode 100644
index 43436b1..0000000
--- a/src/com/android/settings/enterprise/InstalledPackagesPreferenceController.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package com.android.settings.enterprise;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v7.preference.Preference;
-
-import com.android.settings.R;
-import com.android.settings.applications.ApplicationFeatureProvider;
-import com.android.settings.core.PreferenceController;
-import com.android.settings.overlay.FeatureFactory;
-
-public class InstalledPackagesPreferenceController extends PreferenceController {
-
-    private static final String KEY_INSTALLED_PACKAGES = "installed_packages";
-    private final ApplicationFeatureProvider mFeatureProvider;
-
-    public InstalledPackagesPreferenceController(Context context) {
-        super(context);
-        mFeatureProvider = FeatureFactory.getFactory(context)
-                .getApplicationFeatureProvider(context);
-    }
-
-    @Override
-    public void updateState(Preference preference) {
-        mFeatureProvider.calculateNumberOfInstalledApps(
-                ApplicationFeatureProvider.IGNORE_INSTALL_REASON, true /* async */,
-                (num) -> {
-                    if (num == 0) {
-                        preference.setSummary("");
-                    } else {
-                        preference.setSummary(mContext.getResources().getQuantityString(
-                                R.plurals.enterprise_privacy_number_packages, num, num));
-                    }
-                });
-    }
-
-    @Override
-    public boolean isAvailable() {
-        return true;
-    }
-
-    @Override
-    public String getPreferenceKey() {
-        return KEY_INSTALLED_PACKAGES;
-    }
-}
diff --git a/src/com/android/settings/enterprise/NetworkLogsPreferenceController.java b/src/com/android/settings/enterprise/NetworkLogsPreferenceController.java
index d7da525..fd87bbe 100644
--- a/src/com/android/settings/enterprise/NetworkLogsPreferenceController.java
+++ b/src/com/android/settings/enterprise/NetworkLogsPreferenceController.java
@@ -31,6 +31,12 @@
     }
 
     @Override
+    public boolean isAvailable() {
+        return mFeatureProvider.isNetworkLoggingEnabled() ||
+                mFeatureProvider.getLastNetworkLogRetrievalTime() != null;
+    }
+
+    @Override
     public String getPreferenceKey() {
         return KEY_NETWORK_LOGS;
     }
diff --git a/src/com/android/settings/enterprise/SecurityLogsPreferenceController.java b/src/com/android/settings/enterprise/SecurityLogsPreferenceController.java
index 60baa63..482b014 100644
--- a/src/com/android/settings/enterprise/SecurityLogsPreferenceController.java
+++ b/src/com/android/settings/enterprise/SecurityLogsPreferenceController.java
@@ -31,6 +31,12 @@
     }
 
     @Override
+    public boolean isAvailable() {
+        return mFeatureProvider.isSecurityLoggingEnabled() ||
+                mFeatureProvider.getLastSecurityLogRetrievalTime() != null;
+    }
+
+    @Override
     public String getPreferenceKey() {
         return KEY_SECURITY_LOGS;
     }
diff --git a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
new file mode 100644
index 0000000..73cb5b5
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge;
+
+import android.content.Context;
+import android.os.BatteryStats;
+import android.os.Bundle;
+import android.os.SystemClock;
+import android.os.UserHandle;
+import android.support.annotation.VisibleForTesting;
+import android.support.v14.preference.PreferenceFragment;
+import android.support.v7.preference.Preference;
+import android.view.View;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.internal.os.BatterySipper;
+import com.android.internal.os.BatteryStatsHelper;
+import com.android.internal.util.ArrayUtils;
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.Utils;
+import com.android.settings.applications.AppHeaderController;
+import com.android.settings.applications.LayoutPreference;
+import com.android.settings.core.PreferenceController;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.applications.ApplicationsState;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Power usage detail fragment for each app, this fragment contains
+ *
+ * 1. Detail battery usage information for app(i.e. usage time, usage amount)
+ * 2. Battery related controls for app(i.e uninstall, force stop)
+ *
+ * This fragment will replace {@link PowerUsageDetail}
+ */
+public class AdvancedPowerUsageDetail extends PowerUsageBase {
+
+    public static final String TAG = "AdvancedPowerUsageDetail";
+    public static final String EXTRA_UID = "extra_uid";
+    public static final String EXTRA_PACKAGE_NAME = "extra_package_name";
+    public static final String EXTRA_FOREGROUND_TIME = "extra_foreground_time";
+    public static final String EXTRA_BACKGROUND_TIME = "extra_background_time";
+    public static final String EXTRA_LABEL = "extra_label";
+    public static final String EXTRA_ICON_ID = "extra_icon_id";
+    public static final String EXTRA_POWER_USAGE_PERCENT = "extra_power_usage_percent";
+    public static final String EXTRA_POWER_USAGE_AMOUNT = "extra_power_usage_amount";
+
+    private static final String KEY_PREF_FOREGROUND = "app_usage_foreground";
+    private static final String KEY_PREF_BACKGROUND = "app_usage_background";
+    private static final String KEY_PREF_POWER_USAGE = "app_power_usage";
+    private static final String KEY_PREF_HEADER = "header_view";
+
+    @VisibleForTesting
+    LayoutPreference mHeaderPreference;
+    @VisibleForTesting
+    ApplicationsState mState;
+    @VisibleForTesting
+    ApplicationsState.AppEntry mAppEntry;
+
+    private Preference mForegroundPreference;
+    private Preference mBackgroundPreference;
+    private Preference mPowerUsagePreference;
+
+    public static void startBatteryDetailPage(SettingsActivity caller, PreferenceFragment fragment,
+            BatteryStatsHelper helper, int which, BatteryEntry entry, String usagePercent) {
+        // Initialize mStats if necessary.
+        helper.getStats();
+
+        final Bundle args = new Bundle();
+        final BatterySipper sipper = entry.sipper;
+        final BatteryStats.Uid uid = sipper.uidObj;
+
+        final long backgroundTimeMs = BatteryUtils.getProcessTimeMs(
+                BatteryUtils.StatusType.BACKGROUND, uid, which);
+        final long foregroundTimeMs = BatteryUtils.getProcessTimeMs(
+                BatteryUtils.StatusType.FOREGROUND, uid, which);
+
+        if (ArrayUtils.isEmpty(sipper.mPackages)) {
+            // populate data for system app
+            args.putString(EXTRA_LABEL, entry.getLabel());
+            args.putInt(EXTRA_ICON_ID, entry.iconId);
+            args.putString(EXTRA_PACKAGE_NAME, null);
+        } else {
+            // populate data for normal app
+            args.putString(EXTRA_PACKAGE_NAME, sipper.mPackages[0]);
+        }
+
+        args.putInt(EXTRA_UID, sipper.getUid());
+        args.putLong(EXTRA_BACKGROUND_TIME, backgroundTimeMs);
+        args.putLong(EXTRA_FOREGROUND_TIME, foregroundTimeMs);
+        args.putString(EXTRA_POWER_USAGE_PERCENT, usagePercent);
+        args.putInt(EXTRA_POWER_USAGE_AMOUNT, (int) sipper.totalPowerMah);
+
+        caller.startPreferencePanelAsUser(fragment, AdvancedPowerUsageDetail.class.getName(), args,
+                R.string.battery_details_title, null, new UserHandle(UserHandle.myUserId()));
+    }
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+
+        mForegroundPreference = findPreference(KEY_PREF_FOREGROUND);
+        mBackgroundPreference = findPreference(KEY_PREF_BACKGROUND);
+        mPowerUsagePreference = findPreference(KEY_PREF_POWER_USAGE);
+        mHeaderPreference = (LayoutPreference) findPreference(KEY_PREF_HEADER);
+        mState = ApplicationsState.getInstance(getActivity().getApplication());
+
+        final String packageName = getArguments().getString(EXTRA_PACKAGE_NAME);
+        if (packageName != null) {
+            mAppEntry = mState.getEntry(packageName, UserHandle.myUserId());
+        }
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+
+        initHeader();
+
+        final Bundle bundle = getArguments();
+        final Context context = getContext();
+
+        final long foregroundTimeMs = bundle.getLong(EXTRA_FOREGROUND_TIME);
+        final long backgroundTimeMs = bundle.getLong(EXTRA_BACKGROUND_TIME);
+        final String usagePercent = bundle.getString(EXTRA_POWER_USAGE_PERCENT);
+        final int powerMah = bundle.getInt(EXTRA_POWER_USAGE_AMOUNT);
+        mForegroundPreference.setSummary(Utils.formatElapsedTime(context, foregroundTimeMs, false));
+        mBackgroundPreference.setSummary(Utils.formatElapsedTime(context, backgroundTimeMs, false));
+        mPowerUsagePreference.setSummary(
+                getString(R.string.battery_detail_power_percentage, usagePercent, powerMah));
+    }
+
+    @VisibleForTesting
+    void initHeader() {
+        final View appSnippet = mHeaderPreference.findViewById(R.id.app_snippet);
+        final Context context = getContext();
+        final Bundle bundle = getArguments();
+        AppHeaderController controller = FeatureFactory.getFactory(context)
+                .getApplicationFeatureProvider(context)
+                .newAppHeaderController(this, appSnippet)
+                .setButtonActions(AppHeaderController.ActionType.ACTION_NONE,
+                        AppHeaderController.ActionType.ACTION_NONE);
+
+        if (mAppEntry == null) {
+            controller.setLabel(bundle.getString(EXTRA_LABEL));
+            controller.setIcon(getContext().getDrawable(bundle.getInt(EXTRA_ICON_ID)));
+        } else {
+            mState.ensureIcon(mAppEntry);
+            controller.setLabel(mAppEntry);
+            controller.setIcon(mAppEntry);
+            controller.setSummary(getString(Utils.getInstallationStatus(mAppEntry.info)));
+        }
+
+        controller.done(true /* rebindActions */);
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsEvent.FUELGAUGE_POWER_USAGE_DETAIL;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.power_usage_detail_ia;
+    }
+
+    @Override
+    protected List<PreferenceController> getPreferenceControllers(Context context) {
+        final List<PreferenceController> controllers = new ArrayList<>();
+        final Bundle bundle = getArguments();
+        final int uid = bundle.getInt(EXTRA_UID, 0);
+        final String packageName = bundle.getString(EXTRA_PACKAGE_NAME);
+
+        controllers.add(new BackgroundActivityPreferenceController(context, uid));
+        controllers.add(new BatteryOptimizationPreferenceController(
+                (SettingsActivity) getActivity(), this));
+        controllers.add(
+                new AppButtonsPreferenceController(getActivity(), getLifecycle(), packageName));
+
+        return controllers;
+    }
+}
diff --git a/src/com/android/settings/fuelgauge/AppButtonsPreferenceController.java b/src/com/android/settings/fuelgauge/AppButtonsPreferenceController.java
new file mode 100644
index 0000000..b02c8c5
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/AppButtonsPreferenceController.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge;
+
+import android.app.Activity;
+import android.os.UserHandle;
+import android.support.v7.preference.PreferenceScreen;
+import android.view.View;
+import android.widget.Button;
+
+import com.android.settings.R;
+import com.android.settings.applications.LayoutPreference;
+import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.core.lifecycle.LifecycleObserver;
+import com.android.settings.core.lifecycle.events.OnResume;
+import com.android.settingslib.applications.ApplicationsState;
+
+/**
+ * Controller to control the uninstall button and forcestop button
+ */
+//TODO(b/35810915): refine the button logic and make InstalledAppDetails use this controller
+//TODO(b/35810915): add test for this file
+public class AppButtonsPreferenceController extends PreferenceController implements
+        LifecycleObserver, OnResume {
+    private static final String KEY_ACTION_BUTTONS = "action_buttons";
+
+    private ApplicationsState.AppEntry mAppEntry;
+    private LayoutPreference mButtonsPref;
+    private Button mForceStopButton;
+    private Button mUninstallButton;
+
+    public AppButtonsPreferenceController(Activity activity, Lifecycle lifecycle,
+            String packageName) {
+        super(activity);
+
+        lifecycle.addObserver(this);
+        ApplicationsState state = ApplicationsState.getInstance(activity.getApplication());
+
+        if (packageName != null) {
+            mAppEntry = state.getEntry(packageName, UserHandle.myUserId());
+        }
+    }
+
+    @Override
+    public boolean isAvailable() {
+        return mAppEntry != null;
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        if (isAvailable()) {
+            mButtonsPref = (LayoutPreference) screen.findPreference(KEY_ACTION_BUTTONS);
+
+            mUninstallButton = (Button) mButtonsPref.findViewById(R.id.left_button);
+            mUninstallButton.setText(R.string.uninstall_text);
+
+            mForceStopButton = (Button) mButtonsPref.findViewById(R.id.right_button);
+            mForceStopButton.setText(R.string.force_stop);
+        }
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY_ACTION_BUTTONS;
+    }
+
+    @Override
+    public void onResume() {
+        //TODO(b/35810915): check and update the status of buttons
+    }
+}
diff --git a/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceController.java b/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceController.java
index 0f08398..c249676 100644
--- a/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceController.java
@@ -23,6 +23,8 @@
 import android.support.v14.preference.SwitchPreference;
 import android.support.v7.preference.Preference;
 import android.util.Log;
+
+import com.android.settings.R;
 import com.android.settings.core.PreferenceController;
 
 /**
@@ -56,8 +58,12 @@
 
         if (mode == AppOpsManager.MODE_ERRORED) {
             preference.setEnabled(false);
+            preference.setSummary(R.string.background_activity_summary_disabled);
         } else {
-            ((SwitchPreference) preference).setChecked(mode != AppOpsManager.MODE_IGNORED);
+            final boolean checked = mode != AppOpsManager.MODE_IGNORED;
+            ((SwitchPreference) preference).setChecked(checked);
+            preference.setSummary(checked ? R.string.background_activity_summary_on
+                    : R.string.background_activity_summary_off);
         }
     }
 
diff --git a/src/com/android/settings/fuelgauge/BatteryOptimizationPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryOptimizationPreferenceController.java
new file mode 100644
index 0000000..946a9b8
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/BatteryOptimizationPreferenceController.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package com.android.settings.fuelgauge;
+
+import android.app.Fragment;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v7.preference.Preference;
+import android.text.TextUtils;
+
+import com.android.settings.R;
+import com.android.settings.Settings;
+import com.android.settings.SettingsActivity;
+import com.android.settings.applications.ManageApplications;
+import com.android.settings.core.PreferenceController;
+
+/**
+ * Controller that jumps to high power optimization fragment
+ */
+public class BatteryOptimizationPreferenceController extends PreferenceController {
+
+    private static final String KEY_BACKGROUND_ACTIVITY = "battery_optimization";
+
+    private Fragment mFragment;
+    private SettingsActivity mSettingsActivity;
+
+    public BatteryOptimizationPreferenceController(SettingsActivity settingsActivity,
+            Fragment fragment) {
+        super(settingsActivity);
+        mFragment = fragment;
+        mSettingsActivity = settingsActivity;
+    }
+
+    @Override
+    public boolean isAvailable() {
+        return true;
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY_BACKGROUND_ACTIVITY;
+    }
+
+    @Override
+    public boolean handlePreferenceTreeClick(Preference preference) {
+        if (!KEY_BACKGROUND_ACTIVITY.equals(preference.getKey())) {
+            return false;
+        }
+
+        Bundle args = new Bundle(1);
+        args.putString(ManageApplications.EXTRA_CLASSNAME,
+                Settings.HighPowerApplicationsActivity.class.getName());
+        mSettingsActivity.startPreferencePanel(mFragment, ManageApplications.class.getName(), args,
+                R.string.high_power_apps, null, null, 0);
+        return true;
+    }
+}
diff --git a/src/com/android/settings/fuelgauge/BatteryUtils.java b/src/com/android/settings/fuelgauge/BatteryUtils.java
new file mode 100644
index 0000000..85bc0fd
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/BatteryUtils.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.fuelgauge;
+
+import android.annotation.IntDef;
+import android.os.BatteryStats;
+import android.os.SystemClock;
+import android.support.annotation.Nullable;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Utils for battery operation
+ */
+public class BatteryUtils {
+    @Retention(RetentionPolicy.SOURCE)
+    @IntDef({StatusType.FOREGROUND,
+            StatusType.BACKGROUND,
+            StatusType.ALL
+    })
+    public @interface StatusType {
+        int FOREGROUND = 0;
+        int BACKGROUND = 1;
+        int ALL = 2;
+    }
+
+    public static long getProcessTimeMs(@StatusType int type, @Nullable BatteryStats.Uid uid,
+            int which) {
+        if (uid == null) {
+            return 0;
+        }
+
+        switch (type) {
+            case StatusType.FOREGROUND:
+                return getProcessForegroundTimeMs(uid, which);
+            case StatusType.BACKGROUND:
+                return getProcessBackgroundTimeMs(uid, which);
+            case StatusType.ALL:
+                return getProcessForegroundTimeMs(uid, which)
+                        + getProcessBackgroundTimeMs(uid, which);
+        }
+        return 0;
+    }
+
+    private static long getProcessBackgroundTimeMs(BatteryStats.Uid uid, int which) {
+        final long rawRealTimeUs = convertMsToUs(SystemClock.elapsedRealtime());
+        final long timeUs = uid.getProcessStateTime(
+                BatteryStats.Uid.PROCESS_STATE_BACKGROUND, rawRealTimeUs, which);
+        return  convertUsToMs(timeUs);
+    }
+
+    private static long getProcessForegroundTimeMs(BatteryStats.Uid uid, int which) {
+        final long rawRealTimeUs = convertMsToUs(SystemClock.elapsedRealtime());
+        final int foregroundTypes[] = {BatteryStats.Uid.PROCESS_STATE_TOP,
+                BatteryStats.Uid.PROCESS_STATE_FOREGROUND_SERVICE,
+                BatteryStats.Uid.PROCESS_STATE_TOP_SLEEPING,
+                BatteryStats.Uid.PROCESS_STATE_FOREGROUND};
+        long timeUs = 0;
+        for (int type : foregroundTypes) {
+            timeUs += uid.getProcessStateTime(type, rawRealTimeUs, which);
+        }
+
+        return convertUsToMs(timeUs);
+    }
+
+    private static long convertUsToMs(long timeUs) {
+        return timeUs / 1000;
+    }
+
+    private static long convertMsToUs(long timeMs) {
+        return timeMs * 1000;
+    }
+
+}
+
diff --git a/src/com/android/settings/fuelgauge/FakeUid.java b/src/com/android/settings/fuelgauge/FakeUid.java
index 4faa832..770c567 100644
--- a/src/com/android/settings/fuelgauge/FakeUid.java
+++ b/src/com/android/settings/fuelgauge/FakeUid.java
@@ -142,6 +142,21 @@
     }
 
     @Override
+    public int getWifiScanBackgroundCount(int which)  {
+        return 0;
+    }
+
+    @Override
+    public long getWifiScanActualTime(long elapsedRealtimeUs)  {
+        return 0;
+    }
+
+    @Override
+    public long getWifiScanBackgroundTime(long elapsedRealtimeUs)  {
+        return 0;
+    }
+
+    @Override
     public long getWifiBatchedScanTime(int csphBin, long elapsedRealtimeUs, int which) {
         return 0;
     }
@@ -276,6 +291,11 @@
     }
 
     @Override
+    public Timer getBluetoothScanBackgroundTimer() {
+        return null;
+    }
+
+    @Override
     public long getWifiRadioApWakeupCount(int which) {
         return 0;
     }
diff --git a/src/com/android/settings/fuelgauge/PowerGaugePreference.java b/src/com/android/settings/fuelgauge/PowerGaugePreference.java
index fe7ef6e..d4f2dd2 100644
--- a/src/com/android/settings/fuelgauge/PowerGaugePreference.java
+++ b/src/com/android/settings/fuelgauge/PowerGaugePreference.java
@@ -63,6 +63,10 @@
         notifyChanged();
     }
 
+    public String getPercent() {
+        return mProgress.toString();
+    }
+
     BatteryEntry getInfo() {
         return mInfo;
     }
diff --git a/src/com/android/settings/fuelgauge/PowerUsageDetail.java b/src/com/android/settings/fuelgauge/PowerUsageDetail.java
index 956b279..f0d0a10 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageDetail.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageDetail.java
@@ -69,6 +69,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+// TODO(b/35810915): Delete this page once ag/1971493 is done.
 public class PowerUsageDetail extends PowerUsageBase implements Button.OnClickListener {
 
     // Note: Must match the sequence of the DrainType
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 1ffc594..b0e8fb0 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -165,8 +165,8 @@
         }
         PowerGaugePreference pgp = (PowerGaugePreference) preference;
         BatteryEntry entry = pgp.getInfo();
-        PowerUsageDetail.startBatteryDetailPage((SettingsActivity) getActivity(), this,
-                mStatsHelper, mStatsType, entry, true, true);
+        AdvancedPowerUsageDetail.startBatteryDetailPage((SettingsActivity) getActivity(),
+                this, mStatsHelper, mStatsType, entry, pgp.getPercent());
         return super.onPreferenceTreeClick(preference);
     }
 
diff --git a/src/com/android/settings/fuelgauge/RequestIgnoreBatteryOptimizations.java b/src/com/android/settings/fuelgauge/RequestIgnoreBatteryOptimizations.java
index b16fd18..27bd889 100644
--- a/src/com/android/settings/fuelgauge/RequestIgnoreBatteryOptimizations.java
+++ b/src/com/android/settings/fuelgauge/RequestIgnoreBatteryOptimizations.java
@@ -91,8 +91,8 @@
         final AlertController.AlertParams p = mAlertParams;
         p.mTitle = getText(R.string.high_power_prompt_title);
         p.mMessage = getString(R.string.high_power_prompt_body, ai.loadLabel(getPackageManager()));
-        p.mPositiveButtonText = getText(R.string.yes);
-        p.mNegativeButtonText = getText(R.string.no);
+        p.mPositiveButtonText = getText(R.string.allow);
+        p.mNegativeButtonText = getText(R.string.deny);
         p.mPositiveButtonListener = this;
         p.mNegativeButtonListener = this;
         setupAlert();
diff --git a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
index ad6e041..42eff15 100644
--- a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
+++ b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
@@ -136,7 +136,7 @@
         unregisterShowVirtualKeyboardSettingsObserver();
     }
 
-    public void onLoadFinishedInternal(
+    private void onLoadFinishedInternal(
             final int loaderId, @NonNull final List<Keyboards> keyboardsList) {
         if (!mLoaderIDs.remove(loaderId)) {
             // Already destroyed loader.  Ignore.
@@ -198,8 +198,8 @@
     }
 
     @NonNull
-    private static ArrayList<HardKeyboardDeviceInfo> getHardKeyboards() {
-        final ArrayList<HardKeyboardDeviceInfo> keyboards = new ArrayList<>();
+    public static List<HardKeyboardDeviceInfo> getHardKeyboards() {
+        final List<HardKeyboardDeviceInfo> keyboards = new ArrayList<>();
         final int[] devicesIds = InputDevice.getDeviceIds();
         for (int deviceId : devicesIds) {
             final InputDevice device = InputDevice.getDevice(deviceId);
@@ -211,7 +211,7 @@
     }
 
     private void updateHardKeyboards() {
-        final ArrayList<HardKeyboardDeviceInfo> newHardKeyboards = getHardKeyboards();
+        final List<HardKeyboardDeviceInfo> newHardKeyboards = getHardKeyboards();
         if (!Objects.equals(newHardKeyboards, mLastHardKeyboards)) {
             clearLoader();
             mLastHardKeyboards.clear();
diff --git a/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java b/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java
new file mode 100644
index 0000000..aa9f5ad
--- /dev/null
+++ b/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java
@@ -0,0 +1,111 @@
+/*
+ * 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.inputmethod;
+
+import android.content.Context;
+import android.hardware.input.InputManager;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.core.lifecycle.LifecycleObserver;
+import com.android.settings.core.lifecycle.events.OnPause;
+import com.android.settings.core.lifecycle.events.OnResume;
+import com.android.settings.inputmethod.PhysicalKeyboardFragment.HardKeyboardDeviceInfo;
+
+import java.util.List;
+
+public class PhysicalKeyboardPreferenceController extends PreferenceController implements
+        LifecycleObserver, OnResume, OnPause, InputManager.InputDeviceListener {
+
+    private final InputManager mIm;
+
+    private Preference mPreference;
+
+    public PhysicalKeyboardPreferenceController(Context context, Lifecycle lifecycle) {
+        super(context);
+        mIm = (InputManager) context.getSystemService(Context.INPUT_SERVICE);
+
+        if (lifecycle != null) {
+            lifecycle.addObserver(this);
+        }
+    }
+
+    @Override
+    public boolean isAvailable() {
+        return true;
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        mPreference = preference;
+        updateSummary();
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return "physical_keyboard_pref";
+    }
+
+    @Override
+    public void onPause() {
+        mIm.registerInputDeviceListener(this, null);
+    }
+
+    @Override
+    public void onResume() {
+        mIm.unregisterInputDeviceListener(this);
+    }
+
+    @Override
+    public void onInputDeviceAdded(int deviceId) {
+        updateSummary();
+    }
+
+    @Override
+    public void onInputDeviceRemoved(int deviceId) {
+        updateSummary();
+    }
+
+    @Override
+    public void onInputDeviceChanged(int deviceId) {
+        updateSummary();
+    }
+
+    private void updateSummary() {
+        if (mPreference == null) {
+            return;
+        }
+        final List<HardKeyboardDeviceInfo> keyboards =
+                PhysicalKeyboardFragment.getHardKeyboards();
+        if (keyboards.isEmpty()) {
+            mPreference.setSummary(R.string.disconnected);
+            return;
+        }
+        String summary = null;
+        for (HardKeyboardDeviceInfo info : keyboards) {
+            if (summary == null) {
+                summary = info.mDeviceName;
+            } else {
+                summary = mContext.getString(R.string.join_many_items_middle, summary,
+                        info.mDeviceName);
+            }
+        }
+        mPreference.setSummary(summary);
+    }
+}
diff --git a/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceController.java b/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceController.java
new file mode 100644
index 0000000..b7bf3dc
--- /dev/null
+++ b/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceController.java
@@ -0,0 +1,89 @@
+/*
+ * 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.inputmethod;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.support.v7.preference.Preference;
+import android.view.inputmethod.InputMethodInfo;
+import android.view.inputmethod.InputMethodManager;
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceController;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class VirtualKeyboardPreferenceController extends PreferenceController {
+
+    private final InputMethodManager mImm;
+    private final DevicePolicyManager mDpm;
+    private final PackageManager mPm;
+
+    public VirtualKeyboardPreferenceController(Context context) {
+        super(context);
+        mPm = mContext.getPackageManager();
+        mDpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
+        mImm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
+    }
+
+    @Override
+    public boolean isAvailable() {
+        return true;
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return "virtual_keyboard_pref";
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        final List<InputMethodInfo> imis = mImm.getEnabledInputMethodList();
+        if (imis == null) {
+            preference.setSummary(R.string.summary_empty);
+            return;
+        }
+
+        final List<String> permittedList = mDpm.getPermittedInputMethodsForCurrentUser();
+        final List<String> labels = new ArrayList<>();
+
+        for (InputMethodInfo imi : imis) {
+            final boolean isAllowedByOrganization = permittedList == null
+                    || permittedList.contains(imi.getPackageName());
+            if (!isAllowedByOrganization) {
+                continue;
+            }
+            labels.add(imi.loadLabel(mPm).toString());
+        }
+        if (labels.isEmpty()) {
+            preference.setSummary(R.string.summary_empty);
+            return;
+        }
+
+        String summary = null;
+        for (String label : labels) {
+            if (summary == null) {
+                summary = label;
+            } else {
+                summary = mContext.getString(R.string.join_many_items_middle, summary, label);
+            }
+        }
+        preference.setSummary(summary);
+    }
+}
diff --git a/src/com/android/settings/language/LanguageAndInputSettings.java b/src/com/android/settings/language/LanguageAndInputSettings.java
index 5a2c0c7..86ce118 100644
--- a/src/com/android/settings/language/LanguageAndInputSettings.java
+++ b/src/com/android/settings/language/LanguageAndInputSettings.java
@@ -43,7 +43,9 @@
 import com.android.settings.gestures.PickupGesturePreferenceController;
 import com.android.settings.gestures.SwipeToNotificationPreferenceController;
 import com.android.settings.inputmethod.GameControllerPreferenceController;
+import com.android.settings.inputmethod.PhysicalKeyboardPreferenceController;
 import com.android.settings.inputmethod.SpellCheckerPreferenceController;
+import com.android.settings.inputmethod.VirtualKeyboardPreferenceController;
 import com.android.settings.search.BaseSearchIndexProvider;
 
 import java.util.ArrayList;
@@ -87,9 +89,11 @@
         controllers.add(new UserDictionaryPreferenceController(context));
         controllers.add(new TtsPreferenceController(context, new TtsEngines(context)));
         // Input
+        controllers.add(new VirtualKeyboardPreferenceController(context));
+        controllers.add(new PhysicalKeyboardPreferenceController(context, lifecycle));
         final GameControllerPreferenceController gameControllerPreferenceController
                 = new GameControllerPreferenceController(context);
-        getLifecycle().addObserver(gameControllerPreferenceController);
+        lifecycle.addObserver(gameControllerPreferenceController);
 
         if (mAmbientDisplayConfig == null) {
             mAmbientDisplayConfig = new AmbientDisplayConfiguration(context);
diff --git a/src/com/android/settings/network/NetworkResetActionMenuController.java b/src/com/android/settings/network/NetworkResetActionMenuController.java
index d5065d1..028ac7b 100644
--- a/src/com/android/settings/network/NetworkResetActionMenuController.java
+++ b/src/com/android/settings/network/NetworkResetActionMenuController.java
@@ -55,7 +55,12 @@
 
     @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
     boolean isAvailable() {
-        return !RestrictedLockUtils.hasBaseUserRestriction(mContext,
+        return isAvailable(mContext);
+    }
+
+    static boolean isAvailable(Context context) {
+        return !RestrictedLockUtils.hasBaseUserRestriction(context,
                 UserManager.DISALLOW_NETWORK_RESET, UserHandle.myUserId());
     }
+
 }
diff --git a/src/com/android/settings/network/NetworkResetPreferenceController.java b/src/com/android/settings/network/NetworkResetPreferenceController.java
new file mode 100644
index 0000000..04573c9
--- /dev/null
+++ b/src/com/android/settings/network/NetworkResetPreferenceController.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.network;
+
+import android.content.Context;
+
+import com.android.settings.core.PreferenceController;
+
+public class NetworkResetPreferenceController extends PreferenceController {
+
+    public NetworkResetPreferenceController(Context context) {
+        super(context);
+    }
+
+    @Override
+    public boolean isAvailable() {
+        return NetworkResetActionMenuController.isAvailable(mContext);
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return "network_reset_pref";
+    }
+}
diff --git a/src/com/android/settings/notification/VibrateOnTouchPreferenceController.java b/src/com/android/settings/notification/VibrateOnTouchPreferenceController.java
index 8fd938e..544c372 100644
--- a/src/com/android/settings/notification/VibrateOnTouchPreferenceController.java
+++ b/src/com/android/settings/notification/VibrateOnTouchPreferenceController.java
@@ -32,7 +32,7 @@
             Lifecycle lifecycle) {
         super(context, parent, lifecycle);
         mPreference = new SettingPref(
-            TYPE_SYSTEM, KEY_VIBRATE_ON_TOUCH, System.HAPTIC_FEEDBACK_ENABLED, DEFAULT_ON) {
+            TYPE_SYSTEM, KEY_VIBRATE_ON_TOUCH, System.HAPTIC_FEEDBACK_ENABLED, 0) {
             @Override
             public boolean isApplicable(Context context) {
                 return hasHaptic(context);
diff --git a/src/com/android/settings/notification/ZenModeAutomationSettings.java b/src/com/android/settings/notification/ZenModeAutomationSettings.java
deleted file mode 100644
index 495e499..0000000
--- a/src/com/android/settings/notification/ZenModeAutomationSettings.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification;
-
-import android.app.AlertDialog;
-import android.app.AutomaticZenRule;
-import android.app.NotificationManager;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.ServiceInfo;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.service.notification.ConditionProviderService;
-import android.service.notification.ZenModeConfig;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.Preference.OnPreferenceClickListener;
-import android.support.v7.preference.PreferenceScreen;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.view.View;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.R;
-import com.android.settings.utils.ManagedServiceSettings.Config;
-import com.android.settings.utils.ZenServiceListing;
-
-import java.lang.ref.WeakReference;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Map;
-
-public class ZenModeAutomationSettings extends ZenModeSettingsBase {
-
-    static final Config CONFIG = getConditionProviderConfig();
-
-    private PackageManager mPm;
-    private ZenServiceListing mServiceListing;
-
-    @Override
-    public void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-        addPreferencesFromResource(R.xml.zen_mode_automation_settings);
-        mPm = mContext.getPackageManager();
-        mServiceListing = new ZenServiceListing(mContext, CONFIG);
-        mServiceListing.reloadApprovedServices();
-    }
-
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-    }
-
-    @Override
-    protected void onZenModeChanged() {
-        // don't care
-    }
-
-    @Override
-    protected void onZenModeConfigChanged() {
-        updateControls();
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-        if (isUiRestricted()) {
-            return;
-        }
-        updateControls();
-    }
-
-    private void showAddRuleDialog() {
-        new ZenRuleSelectionDialog(mContext, mServiceListing) {
-            @Override
-            public void onSystemRuleSelected(ZenRuleInfo ri) {
-                showNameRuleDialog(ri);
-            }
-
-            @Override
-            public void onExternalRuleSelected(ZenRuleInfo ri) {
-                Intent intent = new Intent().setComponent(ri.configurationActivity);
-                startActivity(intent);
-            }
-        }.show();
-    }
-
-    private void showNameRuleDialog(final ZenRuleInfo ri) {
-        new ZenRuleNameDialog(mContext, null) {
-            @Override
-            public void onOk(String ruleName) {
-                mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_ZEN_ADD_RULE_OK);
-                AutomaticZenRule rule = new AutomaticZenRule(ruleName, ri.serviceComponent,
-                        ri.defaultConditionId, NotificationManager.INTERRUPTION_FILTER_PRIORITY,
-                        true);
-                String savedRuleId = addZenRule(rule);
-                if (savedRuleId != null) {
-                    startActivity(getRuleIntent(ri.settingsAction, null, savedRuleId));
-                }
-            }
-        }.show();
-    }
-
-    private void showDeleteRuleDialog(final String ruleId, final CharSequence ruleName) {
-        new AlertDialog.Builder(mContext)
-                .setMessage(getString(R.string.zen_mode_delete_rule_confirmation, ruleName))
-                .setNegativeButton(R.string.cancel, null)
-                .setPositiveButton(R.string.zen_mode_delete_rule_button,
-                        new DialogInterface.OnClickListener() {
-                    @Override
-                    public void onClick(DialogInterface dialog, int which) {
-                        mMetricsFeatureProvider.action(mContext,
-                                MetricsEvent.ACTION_ZEN_DELETE_RULE_OK);
-                        removeZenRule(ruleId);
-                    }
-                })
-                .show();
-    }
-
-    private Intent getRuleIntent(String settingsAction, ComponentName configurationActivity,
-            String ruleId) {
-        Intent intent = new Intent()
-                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
-                .putExtra(ConditionProviderService.EXTRA_RULE_ID, ruleId);
-        if (configurationActivity != null) {
-            intent.setComponent(configurationActivity);
-        } else {
-            intent.setAction(settingsAction);
-        }
-        return intent;
-    }
-
-    private Map.Entry<String,AutomaticZenRule>[] sortedRules() {
-        final Map.Entry<String,AutomaticZenRule>[] rt =
-                mRules.toArray(new Map.Entry[mRules.size()]);
-        Arrays.sort(rt, RULE_COMPARATOR);
-        return rt;
-    }
-
-    private void updateControls() {
-        final PreferenceScreen root = getPreferenceScreen();
-        root.removeAll();
-        final Map.Entry<String,AutomaticZenRule>[] sortedRules = sortedRules();
-        for (Map.Entry<String,AutomaticZenRule> sortedRule : sortedRules) {
-            ZenRulePreference pref = new ZenRulePreference(getPrefContext(), sortedRule);
-            if (pref.appExists) {
-                root.addPreference(pref);
-            }
-        }
-        final Preference p = new Preference(getPrefContext());
-        p.setIcon(R.drawable.ic_add);
-        p.setTitle(R.string.zen_mode_add_rule);
-        p.setPersistent(false);
-        p.setOnPreferenceClickListener(new OnPreferenceClickListener() {
-            @Override
-            public boolean onPreferenceClick(Preference preference) {
-                mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_ZEN_ADD_RULE);
-                showAddRuleDialog();
-                return true;
-            }
-        });
-        root.addPreference(p);
-    }
-
-    @Override
-    public int getMetricsCategory() {
-        return MetricsEvent.NOTIFICATION_ZEN_MODE_AUTOMATION;
-    }
-
-    private String computeRuleSummary(AutomaticZenRule rule, boolean isSystemRule,
-            CharSequence providerLabel) {
-        final String mode = computeZenModeCaption(getResources(), rule.getInterruptionFilter());
-        final String ruleState = (rule == null || !rule.isEnabled())
-                ? getString(R.string.switch_off_text)
-                : getString(R.string.zen_mode_rule_summary_enabled_combination, mode);
-
-        return isSystemRule ? ruleState
-                : getString(R.string.zen_mode_rule_summary_provider_combination,
-                        providerLabel, ruleState);
-    }
-
-    private static Config getConditionProviderConfig() {
-        final Config c = new Config();
-        c.tag = TAG;
-        c.setting = Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES;
-        c.secondarySetting = Settings.Secure.ENABLED_NOTIFICATION_LISTENERS;
-        c.intentAction = ConditionProviderService.SERVICE_INTERFACE;
-        c.permission = android.Manifest.permission.BIND_CONDITION_PROVIDER_SERVICE;
-        c.noun = "condition provider";
-        return c;
-    }
-
-    private static String computeZenModeCaption(Resources res, int zenMode) {
-        switch (zenMode) {
-            case NotificationManager.INTERRUPTION_FILTER_ALARMS:
-                return res.getString(R.string.zen_mode_option_alarms);
-            case NotificationManager.INTERRUPTION_FILTER_PRIORITY:
-                return res.getString(R.string.zen_mode_option_important_interruptions);
-            case NotificationManager.INTERRUPTION_FILTER_NONE:
-                return res.getString(R.string.zen_mode_option_no_interruptions);
-            default:
-                return null;
-        }
-    }
-
-    public static ZenRuleInfo getRuleInfo(PackageManager pm, ServiceInfo si) {
-        if (si == null || si.metaData == null) return null;
-        final String ruleType = si.metaData.getString(ConditionProviderService.META_DATA_RULE_TYPE);
-        final ComponentName configurationActivity = getSettingsActivity(si);
-        if (ruleType != null && !ruleType.trim().isEmpty() && configurationActivity != null) {
-            final ZenRuleInfo ri = new ZenRuleInfo();
-            ri.serviceComponent = new ComponentName(si.packageName, si.name);
-            ri.settingsAction = Settings.ACTION_ZEN_MODE_EXTERNAL_RULE_SETTINGS;
-            ri.title = ruleType;
-            ri.packageName = si.packageName;
-            ri.configurationActivity = getSettingsActivity(si);
-            ri.packageLabel = si.applicationInfo.loadLabel(pm);
-            ri.ruleInstanceLimit =
-                    si.metaData.getInt(ConditionProviderService.META_DATA_RULE_INSTANCE_LIMIT, -1);
-            return ri;
-        }
-        return null;
-    }
-
-    private static ComponentName getSettingsActivity(ServiceInfo si) {
-        if (si == null || si.metaData == null) return null;
-        final String configurationActivity =
-                si.metaData.getString(ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY);
-        if (configurationActivity != null) {
-            return ComponentName.unflattenFromString(configurationActivity);
-        }
-        return null;
-    }
-
-    private static final Comparator<Map.Entry<String,AutomaticZenRule>> RULE_COMPARATOR =
-            new Comparator<Map.Entry<String,AutomaticZenRule>>() {
-        @Override
-        public int compare(Map.Entry<String,AutomaticZenRule> lhs,
-                Map.Entry<String,AutomaticZenRule> rhs) {
-            int byDate = Long.compare(lhs.getValue().getCreationTime(),
-                    rhs.getValue().getCreationTime());
-            if (byDate != 0) {
-                return byDate;
-            } else {
-                return key(lhs.getValue()).compareTo(key(rhs.getValue()));
-            }
-        }
-
-        private String key(AutomaticZenRule rule) {
-            final int type = ZenModeConfig.isValidScheduleConditionId(rule.getConditionId()) ? 1
-                    : ZenModeConfig.isValidEventConditionId(rule.getConditionId()) ? 2
-                    : 3;
-            return type + rule.getName().toString();
-        }
-    };
-
-    private class ZenRulePreference extends Preference {
-        final CharSequence mName;
-        final String mId;
-        final boolean appExists;
-
-        public ZenRulePreference(Context context,
-                final Map.Entry<String, AutomaticZenRule> ruleEntry) {
-            super(context);
-
-            final AutomaticZenRule rule = ruleEntry.getValue();
-            mName = rule.getName();
-            mId = ruleEntry.getKey();
-
-            final boolean isSchedule = ZenModeConfig.isValidScheduleConditionId(
-                    rule.getConditionId());
-            final boolean isEvent = ZenModeConfig.isValidEventConditionId(rule.getConditionId());
-            final boolean isSystemRule = isSchedule || isEvent;
-
-            try {
-                ApplicationInfo info = mPm.getApplicationInfo(rule.getOwner().getPackageName(), 0);
-                LoadIconTask task = new LoadIconTask(this);
-                task.execute(info);
-                setSummary(computeRuleSummary(rule, isSystemRule, info.loadLabel(mPm)));
-            } catch (PackageManager.NameNotFoundException e) {
-                setIcon(R.drawable.ic_label);
-                appExists = false;
-                return;
-            }
-
-            appExists = true;
-            setTitle(rule.getName());
-            setPersistent(false);
-
-            final String action = isSchedule ? ZenModeScheduleRuleSettings.ACTION
-                    : isEvent ? ZenModeEventRuleSettings.ACTION : "";
-            ServiceInfo si = mServiceListing.findService(rule.getOwner());
-            ComponentName settingsActivity = getSettingsActivity(si);
-            setIntent(getRuleIntent(action, settingsActivity, mId));
-            setSelectable(settingsActivity != null || isSystemRule);
-
-            setWidgetLayoutResource(R.layout.zen_rule_widget);
-        }
-
-        @Override
-        public void onBindViewHolder(PreferenceViewHolder view) {
-            super.onBindViewHolder(view);
-
-            View v = view.findViewById(R.id.delete_zen_rule);
-            if (v != null) {
-                v.setOnClickListener(mDeleteListener);
-            }
-            view.setDividerAllowedAbove(true);
-            view.setDividerAllowedBelow(true);
-        }
-
-        private final View.OnClickListener mDeleteListener = new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                showDeleteRuleDialog(mId, mName);
-            }
-        };
-    }
-
-    private class LoadIconTask extends AsyncTask<ApplicationInfo, Void, Drawable> {
-        private final WeakReference<Preference> prefReference;
-
-        public LoadIconTask(Preference pref) {
-            prefReference = new WeakReference<>(pref);
-        }
-
-        @Override
-        protected Drawable doInBackground(ApplicationInfo... params) {
-            return params[0].loadIcon(mPm);
-        }
-
-        @Override
-        protected void onPostExecute(Drawable icon) {
-            if (icon != null) {
-                final Preference pref = prefReference.get();
-                if (pref != null) {
-                    pref.setIcon(icon);
-                }
-            }
-        }
-    }
-
-}
diff --git a/src/com/android/settings/notification/ZenModePreferenceController.java b/src/com/android/settings/notification/ZenModePreferenceController.java
index 1427d5a..e11b422 100644
--- a/src/com/android/settings/notification/ZenModePreferenceController.java
+++ b/src/com/android/settings/notification/ZenModePreferenceController.java
@@ -16,22 +16,18 @@
 
 package com.android.settings.notification;
 
-import android.app.NotificationManager;
 import android.content.Context;
 import android.support.v7.preference.Preference;
-import com.android.settings.R;
 
 public class ZenModePreferenceController extends AdjustVolumeRestrictedPreferenceController {
 
     private static final String KEY_ZEN_MODE = "zen_mode";
-    private String mSummaryPrefix;
 
     private ZenModeSettings.SummaryBuilder mSummaryBuilder;
 
     public ZenModePreferenceController(Context context) {
         super(context);
         mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
-        mSummaryPrefix = context.getString(R.string.zen_mode_priority_settings_title) + " ";
     }
 
     @Override
@@ -48,8 +44,7 @@
     public void updateState(Preference preference) {
         super.updateState(preference);
         if (preference.isEnabled()) {
-            preference.setSummary(mSummaryPrefix + mSummaryBuilder.getPrioritySettingSummary(
-                NotificationManager.from(mContext).getNotificationPolicy()));
+            preference.setSummary(mSummaryBuilder.getAutomaticRulesSummary());
         }
     }
 }
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index 6266af9..bbcaa9c 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -16,25 +16,56 @@
 
 package com.android.settings.notification;
 
+import android.app.AlertDialog;
+import android.app.AutomaticZenRule;
 import android.app.NotificationManager;
 import android.app.NotificationManager.Policy;
+import android.content.ComponentName;
 import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ServiceInfo;
+import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
+import android.os.AsyncTask;
 import android.os.Bundle;
+import android.provider.Settings;
+import android.service.notification.ConditionProviderService;
+import android.service.notification.ZenModeConfig;
+import com.android.settings.utils.ManagedServiceSettings;
+import com.android.settings.utils.ZenServiceListing;
 import android.support.annotation.VisibleForTesting;
 import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceCategory;
 import android.support.v7.preference.PreferenceScreen;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.view.View;
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 
+import java.lang.ref.WeakReference;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.Map.Entry;
+
 public class ZenModeSettings extends ZenModeSettingsBase {
     private static final String KEY_PRIORITY_SETTINGS = "priority_settings";
     private static final String KEY_VISUAL_SETTINGS = "visual_interruptions_settings";
+    private static final String KEY_AUTOMATIC_RULES = "automatic_rules";
 
+    static final ManagedServiceSettings.Config CONFIG = getConditionProviderConfig();
+
+    private PreferenceCategory mAutomaticRules;
     private Preference mPrioritySettings;
     private Preference mVisualSettings;
     private Policy mPolicy;
     private SummaryBuilder mSummaryBuilder;
+    private PackageManager mPm;
+    private ZenServiceListing mServiceListing;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
@@ -43,10 +74,14 @@
         addPreferencesFromResource(R.xml.zen_mode_settings);
         final PreferenceScreen root = getPreferenceScreen();
 
+        mAutomaticRules = (PreferenceCategory) root.findPreference(KEY_AUTOMATIC_RULES);
         mPrioritySettings = root.findPreference(KEY_PRIORITY_SETTINGS);
         mVisualSettings = root.findPreference(KEY_VISUAL_SETTINGS);
         mPolicy = NotificationManager.from(mContext).getNotificationPolicy();
         mSummaryBuilder = new SummaryBuilder(getContext());
+        mPm = mContext.getPackageManager();
+        mServiceListing = new ZenServiceListing(mContext, CONFIG);
+        mServiceListing.reloadApprovedServices();
     }
 
     @Override
@@ -55,6 +90,7 @@
         if (isUiRestricted()) {
             return;
         }
+        updateControls();
     }
 
     @Override
@@ -76,6 +112,7 @@
     private void updateControls() {
         updatePrioritySettingsSummary();
         updateVisualSettingsSummary();
+        updateAutomaticRules();
     }
 
     private void updatePrioritySettingsSummary() {
@@ -86,11 +123,251 @@
         mVisualSettings.setSummary(mSummaryBuilder.getVisualSettingSummary(mPolicy));
     }
 
+    private void updateAutomaticRules() {
+        mAutomaticRules.removeAll();
+        final Map.Entry<String,AutomaticZenRule>[] sortedRules = sortedRules();
+        for (Map.Entry<String,AutomaticZenRule> sortedRule : sortedRules) {
+            ZenRulePreference pref = new ZenRulePreference(getPrefContext(), sortedRule);
+            if (pref.appExists) {
+                mAutomaticRules.addPreference(pref);
+            }
+        }
+        final Preference p = new Preference(getPrefContext());
+        p.setIcon(R.drawable.ic_add);
+        p.setTitle(R.string.zen_mode_add_rule);
+        p.setPersistent(false);
+        p.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+            @Override
+            public boolean onPreferenceClick(Preference preference) {
+                mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_ZEN_ADD_RULE);
+                showAddRuleDialog();
+                return true;
+            }
+        });
+        mAutomaticRules.addPreference(p);
+    }
+
+    private void showAddRuleDialog() {
+        new ZenRuleSelectionDialog(mContext, mServiceListing) {
+            @Override
+            public void onSystemRuleSelected(ZenRuleInfo ri) {
+                showNameRuleDialog(ri);
+            }
+
+            @Override
+            public void onExternalRuleSelected(ZenRuleInfo ri) {
+                Intent intent = new Intent().setComponent(ri.configurationActivity);
+                startActivity(intent);
+            }
+        }.show();
+    }
+
+    private String computeRuleSummary(AutomaticZenRule rule, boolean isSystemRule,
+            CharSequence providerLabel) {
+        final String mode = computeZenModeCaption(getResources(), rule.getInterruptionFilter());
+        final String ruleState = (rule == null || !rule.isEnabled())
+                ? getString(R.string.switch_off_text)
+                : getString(R.string.zen_mode_rule_summary_enabled_combination, mode);
+
+        return isSystemRule ? ruleState
+                : getString(R.string.zen_mode_rule_summary_provider_combination,
+                        providerLabel, ruleState);
+    }
+
+    private static ManagedServiceSettings.Config getConditionProviderConfig() {
+        final ManagedServiceSettings.Config c = new ManagedServiceSettings.Config();
+        c.tag = TAG;
+        c.setting = Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES;
+        c.secondarySetting = Settings.Secure.ENABLED_NOTIFICATION_LISTENERS;
+        c.intentAction = ConditionProviderService.SERVICE_INTERFACE;
+        c.permission = android.Manifest.permission.BIND_CONDITION_PROVIDER_SERVICE;
+        c.noun = "condition provider";
+        return c;
+    }
+
+    private static String computeZenModeCaption(Resources res, int zenMode) {
+        switch (zenMode) {
+            case NotificationManager.INTERRUPTION_FILTER_ALARMS:
+                return res.getString(R.string.zen_mode_option_alarms);
+            case NotificationManager.INTERRUPTION_FILTER_PRIORITY:
+                return res.getString(R.string.zen_mode_option_important_interruptions);
+            case NotificationManager.INTERRUPTION_FILTER_NONE:
+                return res.getString(R.string.zen_mode_option_no_interruptions);
+            default:
+                return null;
+        }
+    }
+
+    public static ZenRuleInfo getRuleInfo(PackageManager pm, ServiceInfo si) {
+        if (si == null || si.metaData == null) return null;
+        final String ruleType = si.metaData.getString(ConditionProviderService.META_DATA_RULE_TYPE);
+        final ComponentName configurationActivity = getSettingsActivity(si);
+        if (ruleType != null && !ruleType.trim().isEmpty() && configurationActivity != null) {
+            final ZenRuleInfo ri = new ZenRuleInfo();
+            ri.serviceComponent = new ComponentName(si.packageName, si.name);
+            ri.settingsAction = Settings.ACTION_ZEN_MODE_EXTERNAL_RULE_SETTINGS;
+            ri.title = ruleType;
+            ri.packageName = si.packageName;
+            ri.configurationActivity = getSettingsActivity(si);
+            ri.packageLabel = si.applicationInfo.loadLabel(pm);
+            ri.ruleInstanceLimit =
+                    si.metaData.getInt(ConditionProviderService.META_DATA_RULE_INSTANCE_LIMIT, -1);
+            return ri;
+        }
+        return null;
+    }
+
+    private static ComponentName getSettingsActivity(ServiceInfo si) {
+        if (si == null || si.metaData == null) return null;
+        final String configurationActivity =
+                si.metaData.getString(ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY);
+        if (configurationActivity != null) {
+            return ComponentName.unflattenFromString(configurationActivity);
+        }
+        return null;
+    }
+
+    private void showNameRuleDialog(final ZenRuleInfo ri) {
+        new ZenRuleNameDialog(mContext, null) {
+            @Override
+            public void onOk(String ruleName) {
+                mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_ZEN_ADD_RULE_OK);
+                AutomaticZenRule rule = new AutomaticZenRule(ruleName, ri.serviceComponent,
+                        ri.defaultConditionId, NotificationManager.INTERRUPTION_FILTER_PRIORITY,
+                        true);
+                String savedRuleId = addZenRule(rule);
+                if (savedRuleId != null) {
+                    startActivity(getRuleIntent(ri.settingsAction, null, savedRuleId));
+                }
+            }
+        }.show();
+    }
+
+    private void showDeleteRuleDialog(final String ruleId, final CharSequence ruleName) {
+        new AlertDialog.Builder(mContext)
+                .setMessage(getString(R.string.zen_mode_delete_rule_confirmation, ruleName))
+                .setNegativeButton(R.string.cancel, null)
+                .setPositiveButton(R.string.zen_mode_delete_rule_button,
+                        new DialogInterface.OnClickListener() {
+                            @Override
+                            public void onClick(DialogInterface dialog, int which) {
+                                mMetricsFeatureProvider.action(mContext,
+                                        MetricsEvent.ACTION_ZEN_DELETE_RULE_OK);
+                                removeZenRule(ruleId);
+                            }
+                        })
+                .show();
+    }
+
+    private Intent getRuleIntent(String settingsAction, ComponentName configurationActivity,
+            String ruleId) {
+        Intent intent = new Intent()
+                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
+                .putExtra(ConditionProviderService.EXTRA_RULE_ID, ruleId);
+        if (configurationActivity != null) {
+            intent.setComponent(configurationActivity);
+        } else {
+            intent.setAction(settingsAction);
+        }
+        return intent;
+    }
+
+    private Map.Entry<String,AutomaticZenRule>[] sortedRules() {
+        final Map.Entry<String,AutomaticZenRule>[] rt =
+                mRules.toArray(new Map.Entry[mRules.size()]);
+        Arrays.sort(rt, RULE_COMPARATOR);
+        return rt;
+    }
+
     @Override
     protected int getHelpResource() {
         return R.string.help_uri_interruptions;
     }
 
+    private class ZenRulePreference extends Preference {
+        final CharSequence mName;
+        final String mId;
+        final boolean appExists;
+
+        public ZenRulePreference(Context context,
+                final Map.Entry<String, AutomaticZenRule> ruleEntry) {
+            super(context);
+
+            final AutomaticZenRule rule = ruleEntry.getValue();
+            mName = rule.getName();
+            mId = ruleEntry.getKey();
+
+            final boolean isSchedule = ZenModeConfig.isValidScheduleConditionId(
+                    rule.getConditionId());
+            final boolean isEvent = ZenModeConfig.isValidEventConditionId(rule.getConditionId());
+            final boolean isSystemRule = isSchedule || isEvent;
+
+            try {
+                ApplicationInfo info = mPm.getApplicationInfo(rule.getOwner().getPackageName(), 0);
+                LoadIconTask task = new LoadIconTask(this);
+                task.execute(info);
+                setSummary(computeRuleSummary(rule, isSystemRule, info.loadLabel(mPm)));
+            } catch (PackageManager.NameNotFoundException e) {
+                setIcon(R.drawable.ic_label);
+                appExists = false;
+                return;
+            }
+
+            appExists = true;
+            setTitle(rule.getName());
+            setPersistent(false);
+
+            final String action = isSchedule ? ZenModeScheduleRuleSettings.ACTION
+                    : isEvent ? ZenModeEventRuleSettings.ACTION : "";
+            ServiceInfo si = mServiceListing.findService(rule.getOwner());
+            ComponentName settingsActivity = getSettingsActivity(si);
+            setIntent(getRuleIntent(action, settingsActivity, mId));
+            setSelectable(settingsActivity != null || isSystemRule);
+
+            setWidgetLayoutResource(R.layout.zen_rule_widget);
+        }
+
+        @Override
+        public void onBindViewHolder(PreferenceViewHolder view) {
+            super.onBindViewHolder(view);
+
+            View v = view.findViewById(R.id.delete_zen_rule);
+            if (v != null) {
+                v.setOnClickListener(mDeleteListener);
+            }
+        }
+
+        private final View.OnClickListener mDeleteListener = new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                showDeleteRuleDialog(mId, mName);
+            }
+        };
+    }
+
+    private class LoadIconTask extends AsyncTask<ApplicationInfo, Void, Drawable> {
+        private final WeakReference<Preference> prefReference;
+
+        public LoadIconTask(Preference pref) {
+            prefReference = new WeakReference<>(pref);
+        }
+
+        @Override
+        protected Drawable doInBackground(ApplicationInfo... params) {
+            return params[0].loadIcon(mPm);
+        }
+
+        @Override
+        protected void onPostExecute(Drawable icon) {
+            if (icon != null) {
+                final Preference pref = prefReference.get();
+                if (pref != null) {
+                    pref.setIcon(icon);
+                }
+            }
+        }
+    }
+
     public static class SummaryBuilder {
 
         private Context mContext;
@@ -137,6 +414,29 @@
             return s;
         }
 
+        String getAutomaticRulesSummary() {
+            final int count = getEnabledAutomaticRulesCount();
+            return count == 0 ? mContext.getString(R.string.zen_mode_settings_summary_off)
+                : mContext.getResources().getQuantityString(
+                    R.plurals.zen_mode_settings_summary_on, count, count);
+        }
+
+        @VisibleForTesting
+        int getEnabledAutomaticRulesCount() {
+            int count = 0;
+            final Map<String, AutomaticZenRule> ruleMap =
+                NotificationManager.from(mContext).getAutomaticZenRules();
+            if (ruleMap != null) {
+                for (Entry<String, AutomaticZenRule> ruleEntry : ruleMap.entrySet()) {
+                    final AutomaticZenRule rule = ruleEntry.getValue();
+                    if (rule != null && rule.isEnabled()) {
+                        count++;
+                    }
+                }
+            }
+            return count;
+        }
+
         @VisibleForTesting
         String append(String s, boolean condition, int resId) {
             if (condition) {
@@ -153,6 +453,29 @@
         private boolean isEffectSuppressed(Policy policy, int effect) {
             return (policy.suppressedVisualEffects & effect) != 0;
         }
-
     }
+
+    private static final Comparator<Map.Entry<String,AutomaticZenRule>> RULE_COMPARATOR =
+            new Comparator<Map.Entry<String,AutomaticZenRule>>() {
+                @Override
+                public int compare(Map.Entry<String,AutomaticZenRule> lhs,
+                        Map.Entry<String,AutomaticZenRule> rhs) {
+                    int byDate = Long.compare(lhs.getValue().getCreationTime(),
+                            rhs.getValue().getCreationTime());
+                    if (byDate != 0) {
+                        return byDate;
+                    } else {
+                        return key(lhs.getValue()).compareTo(key(rhs.getValue()));
+                    }
+                }
+
+                private String key(AutomaticZenRule rule) {
+                    final int type = ZenModeConfig.isValidScheduleConditionId(rule.getConditionId())
+                            ? 1
+                            : ZenModeConfig.isValidEventConditionId(rule.getConditionId())
+                                    ? 2
+                                    : 3;
+                    return type + rule.getName().toString();
+                }
+            };
 }
diff --git a/src/com/android/settings/notification/ZenRuleSelectionDialog.java b/src/com/android/settings/notification/ZenRuleSelectionDialog.java
index 9de9a60..4fa632a 100644
--- a/src/com/android/settings/notification/ZenRuleSelectionDialog.java
+++ b/src/com/android/settings/notification/ZenRuleSelectionDialog.java
@@ -169,7 +169,7 @@
             if (DEBUG) Log.d(TAG, "Services reloaded: count=" + services.size());
             Set<ZenRuleInfo> externalRuleTypes = new TreeSet<>(RULE_TYPE_COMPARATOR);
             for (ServiceInfo serviceInfo : services) {
-                final ZenRuleInfo ri = ZenModeAutomationSettings.getRuleInfo(mPm, serviceInfo);
+                final ZenRuleInfo ri = ZenModeSettings.getRuleInfo(mPm, serviceInfo);
                 if (ri != null && ri.configurationActivity != null
                         && mNm.isNotificationPolicyAccessGrantedForPackage(ri.packageName)
                         && (ri.ruleInstanceLimit <= 0 || ri.ruleInstanceLimit
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index f88d830..f8cedc1 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -30,6 +30,8 @@
 import com.android.settings.ScreenPinningSettings;
 import com.android.settings.SecuritySettings;
 import com.android.settings.accessibility.AccessibilitySettings;
+import com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment;
+import com.android.settings.accessibility.MagnificationPreferenceFragment;
 import com.android.settings.accounts.UserAndAccountDashboardFragment;
 import com.android.settings.applications.AdvancedAppSettings;
 import com.android.settings.applications.AppAndNotificationDashboardFragment;
@@ -72,6 +74,7 @@
 import com.android.settings.print.PrintSettingsFragment;
 import com.android.settings.security.LockscreenDashboardFragment;
 import com.android.settings.sim.SimSettings;
+import com.android.settings.system.ResetDashboardFragment;
 import com.android.settings.system.SystemDashboardFragment;
 import com.android.settings.tts.TtsEnginePreferenceFragment;
 import com.android.settings.users.UserSettings;
@@ -164,6 +167,7 @@
                 R.xml.zen_mode_visual_interruptions_settings,
                 R.drawable.ic_settings_notifications);
         addIndex(SystemDashboardFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_about);
+        addIndex(ResetDashboardFragment.class, NO_DATA_RES_ID, R.drawable.ic_restore);
         addIndex(StorageDashboardFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_storage);
         addIndex(ConnectedDeviceDashboardFragment.class, NO_DATA_RES_ID,
                 R.drawable.ic_devices_other);
@@ -173,6 +177,10 @@
                 TtsEnginePreferenceFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_language);
         addIndex(LockscreenDashboardFragment.class, R.xml.security_lockscreen_settings,
             R.drawable.ic_settings_security);
+        addIndex(MagnificationPreferenceFragment.class, NO_DATA_RES_ID,
+                R.drawable.ic_settings_accessibility);
+        addIndex(AccessibilityShortcutPreferenceFragment.class, NO_DATA_RES_ID,
+                R.drawable.ic_settings_accessibility);
     }
 
     private SearchIndexableResources() {
diff --git a/src/com/android/settings/system/FactoryResetPreferenceController.java b/src/com/android/settings/system/FactoryResetPreferenceController.java
index 95a9e54..38afd16 100644
--- a/src/com/android/settings/system/FactoryResetPreferenceController.java
+++ b/src/com/android/settings/system/FactoryResetPreferenceController.java
@@ -15,22 +15,30 @@
  */
 package com.android.settings.system;
 
+import android.accounts.Account;
+import android.accounts.AccountManager;
 import android.content.Context;
-
+import android.content.pm.UserInfo;
+import android.os.UserHandle;
 import android.os.UserManager;
+import android.support.v7.preference.Preference;
 
 import com.android.settings.R;
 import com.android.settings.core.PreferenceController;
 
+import java.util.List;
+
 public class FactoryResetPreferenceController extends PreferenceController {
-    /** Key of the "Factory reset" preference in {@link R.xml.system_dashboard_fragment}.*/
+    /** Key of the "Factory reset" preference in {@link R.xml.reset_dashboard_fragment}. */
     private static final String KEY_FACTORY_RESET = "factory_reset";
 
     private final UserManager mUm;
+    private final AccountManager mAm;
 
-    public FactoryResetPreferenceController(Context context, UserManager um) {
+    public FactoryResetPreferenceController(Context context) {
         super(context);
-        mUm = um;
+        mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
+        mAm = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
     }
 
     /** Hide "Factory reset" settings for secondary users. */
@@ -43,4 +51,22 @@
     public String getPreferenceKey() {
         return KEY_FACTORY_RESET;
     }
+
+    @Override
+    public void updateState(Preference preference) {
+        final List<UserInfo> profiles = mUm.getProfiles(UserHandle.myUserId());
+        int accountsCount = 0;
+        for (UserInfo userInfo : profiles) {
+            final int profileId = userInfo.id;
+            Account[] accounts = mAm.getAccountsAsUser(profileId);
+            accountsCount += accounts.length;
+        }
+        if (accountsCount == 0) {
+            preference.setSummary(R.string.master_clear_summary);
+        } else {
+            preference.setSummary(mContext.getResources().getQuantityString(
+                    R.plurals.master_clear_with_account_summary,
+                    accountsCount, accountsCount));
+        }
+    }
 }
diff --git a/src/com/android/settings/system/ResetDashboardFragment.java b/src/com/android/settings/system/ResetDashboardFragment.java
new file mode 100644
index 0000000..d4685bc
--- /dev/null
+++ b/src/com/android/settings/system/ResetDashboardFragment.java
@@ -0,0 +1,86 @@
+/*
+ * 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.system;
+
+import android.content.Context;
+import android.provider.SearchIndexableResource;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.applications.ResetAppPrefPreferenceController;
+import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.network.NetworkResetPreferenceController;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ResetDashboardFragment extends DashboardFragment {
+
+    private static final String TAG = "ResetDashboardFragment";
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsProto.MetricsEvent.RESET_DASHBOARD;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.reset_dashboard_fragment;
+    }
+
+    @Override
+    protected List<PreferenceController> getPreferenceControllers(Context context) {
+        return buildPreferenceControllers(context, getLifecycle());
+    }
+
+    private static List<PreferenceController> buildPreferenceControllers(Context context,
+            Lifecycle lifecycle) {
+        final List<PreferenceController> controllers = new ArrayList<>();
+        controllers.add(new NetworkResetPreferenceController(context));
+        controllers.add(new FactoryResetPreferenceController(context));
+        controllers.add(new ResetAppPrefPreferenceController(context, lifecycle));
+        return controllers;
+    }
+
+    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider() {
+                @Override
+                public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+                        boolean enabled) {
+                    final ArrayList<SearchIndexableResource> result = new ArrayList<>();
+
+                    final SearchIndexableResource sir = new SearchIndexableResource(context);
+                    sir.xmlResId = R.xml.reset_dashboard_fragment;
+                    result.add(sir);
+                    return result;
+                }
+
+                @Override
+                public List<PreferenceController> getPreferenceControllers(Context context) {
+                    return buildPreferenceControllers(context, null /* lifecycle */);
+                }
+            };
+}
diff --git a/src/com/android/settings/system/SystemDashboardFragment.java b/src/com/android/settings/system/SystemDashboardFragment.java
index d4c63c2..76ac4a6 100644
--- a/src/com/android/settings/system/SystemDashboardFragment.java
+++ b/src/com/android/settings/system/SystemDashboardFragment.java
@@ -60,7 +60,6 @@
         final List<PreferenceController> controllers = new ArrayList<>();
         controllers.add(new SystemUpdatePreferenceController(context, UserManager.get(context)));
         controllers.add(new AdditionalSystemUpdatePreferenceController(context));
-        controllers.add(new FactoryResetPreferenceController(context, UserManager.get(context)));
         return controllers;
     }
 
diff --git a/src/com/android/settings/users/UserPreference.java b/src/com/android/settings/users/UserPreference.java
index 7b13597..8b53dd4 100644
--- a/src/com/android/settings/users/UserPreference.java
+++ b/src/com/android/settings/users/UserPreference.java
@@ -20,7 +20,6 @@
 import android.graphics.drawable.Drawable;
 import android.os.UserHandle;
 import android.os.UserManager;
-import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceViewHolder;
 import android.util.AttributeSet;
 import android.view.View;
@@ -87,6 +86,20 @@
     }
 
     @Override
+    protected boolean shouldHideSecondTarget() {
+        if (isDisabledByAdmin()) {
+            // Disabled by admin, show no secondary target.
+            return true;
+        }
+        if (canDeleteUser()) {
+            // Need to show delete user target so don't hide.
+            return false;
+        }
+        // Hide if don't have advanced setting listener.
+        return mSettingsClickListener == null;
+    }
+
+    @Override
     public void onBindViewHolder(PreferenceViewHolder view) {
         super.onBindViewHolder(view);
         final boolean disabledByAdmin = isDisabledByAdmin();
@@ -96,14 +109,11 @@
             userDeleteWidget.setVisibility(disabledByAdmin ? View.GONE : View.VISIBLE);
         }
         if (!disabledByAdmin) {
-            UserManager um = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
             View deleteDividerView = view.findViewById(R.id.divider_delete);
             View manageDividerView = view.findViewById(R.id.divider_manage);
             View deleteView = view.findViewById(R.id.trash_user);
             if (deleteView != null) {
-                if (mDeleteClickListener != null
-                        && !RestrictedLockUtils.hasBaseUserRestriction(getContext(),
-                                UserManager.DISALLOW_REMOVE_USER, UserHandle.myUserId())) {
+                if (canDeleteUser()) {
                     deleteView.setVisibility(View.VISIBLE);
                     deleteDividerView.setVisibility(View.VISIBLE);
                     deleteView.setOnClickListener(mDeleteClickListener);
@@ -129,6 +139,12 @@
         }
     }
 
+    private boolean canDeleteUser() {
+        return mDeleteClickListener != null
+                && !RestrictedLockUtils.hasBaseUserRestriction(getContext(),
+                UserManager.DISALLOW_REMOVE_USER, UserHandle.myUserId());
+    }
+
     private int getSerialNumber() {
         if (mUserId == UserHandle.myUserId()) return Integer.MIN_VALUE;
         if (mSerialNumber < 0) {
diff --git a/src/com/android/settings/vpn2/AppManagementFragment.java b/src/com/android/settings/vpn2/AppManagementFragment.java
index 9ef087b..7559512 100644
--- a/src/com/android/settings/vpn2/AppManagementFragment.java
+++ b/src/com/android/settings/vpn2/AppManagementFragment.java
@@ -259,13 +259,13 @@
 
             if (isAlwaysOnSupportedByApp(mPackageInfo.applicationInfo)) {
                 // setSummary doesn't override the admin message when user restriction is applied
-                mPreferenceAlwaysOn.setSummary(null);
+                mPreferenceAlwaysOn.setSummary(R.string.vpn_always_on_summary);
                 // setEnabled is not required here, as checkRestrictionAndSetDisabled
                 // should have refreshed the enable state.
             } else {
                 mPreferenceAlwaysOn.setEnabled(false);
                 mPreferenceLockdown.setEnabled(false);
-                mPreferenceAlwaysOn.setSummary(R.string.vpn_not_supported_by_this_app);
+                mPreferenceAlwaysOn.setSummary(R.string.vpn_always_on_summary_not_supported);
             }
         }
     }
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index ead2143..d40441f 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -18,6 +18,7 @@
 
 import android.annotation.UiThread;
 import android.annotation.WorkerThread;
+import android.app.Activity;
 import android.app.AppOpsManager;
 import android.content.Context;
 import android.content.Intent;
@@ -215,9 +216,16 @@
 
     @Override @WorkerThread
     public boolean handleMessage(Message message) {
+        //Return if activity has been recycled
+        final Activity activity = getActivity();
+        if (activity == null) {
+            return true;
+        }
+        final Context context = activity.getApplicationContext();
+
         // Run heavy RPCs before switching to UI thread
         final List<VpnProfile> vpnProfiles = loadVpnProfiles(mKeyStore);
-        final List<AppVpnInfo> vpnApps = getVpnApps(getActivity(), /* includeProfiles */ true);
+        final List<AppVpnInfo> vpnApps = getVpnApps(context, /* includeProfiles */ true);
 
         final Map<String, LegacyVpnInfo> connectedLegacyVpns = getConnectedLegacyVpns();
         final Set<AppVpnInfo> connectedAppVpns = getConnectedAppVpns();
@@ -226,7 +234,7 @@
         final String lockdownVpnKey = VpnUtils.getLockdownVpn();
 
         // Refresh list of VPNs
-        getActivity().runOnUiThread(new UpdatePreferences(this)
+        activity.runOnUiThread(new UpdatePreferences(this)
                 .legacyVpns(vpnProfiles, connectedLegacyVpns, lockdownVpnKey)
                 .appVpns(vpnApps, connectedAppVpns, alwaysOnAppVpnInfos));
 
diff --git a/src/com/android/settings/widget/ImeAwareEditText.java b/src/com/android/settings/widget/ImeAwareEditText.java
new file mode 100644
index 0000000..6e70929
--- /dev/null
+++ b/src/com/android/settings/widget/ImeAwareEditText.java
@@ -0,0 +1,92 @@
+/*
+ * 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.widget;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputConnection;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+
+public class ImeAwareEditText extends EditText {
+    private boolean mHasPendingShowSoftInputRequest;
+    final Runnable mRunShowSoftInputIfNecessary = () -> showSoftInputIfNecessary();
+
+    public ImeAwareEditText(Context context) {
+        super(context, null);
+    }
+
+    public ImeAwareEditText(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public ImeAwareEditText(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+    }
+
+    public ImeAwareEditText(Context context, AttributeSet attrs, int defStyleAttr,
+            int defStyleRes) {
+        super(context, attrs, defStyleAttr, defStyleRes);
+    }
+
+    /**
+     * This method is called back by the system when the system is about to establish a connection
+     * to the current input method.
+     *
+     * <p>This is a good and reliable signal to schedule a pending task to call
+     * {@link InputMethodManager#showSoftInput(View, int)}.</p>
+     *
+     * @param editorInfo context about the text input field.
+     * @return {@link InputConnection} to be passed to the input method.
+     */
+    @Override
+    public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
+        final InputConnection ic = super.onCreateInputConnection(editorInfo);
+        if (mHasPendingShowSoftInputRequest) {
+            removeCallbacks(mRunShowSoftInputIfNecessary);
+            post(mRunShowSoftInputIfNecessary);
+        }
+        return ic;
+    }
+
+    private void showSoftInputIfNecessary() {
+        if (mHasPendingShowSoftInputRequest) {
+            final InputMethodManager imm =
+                    getContext().getSystemService(InputMethodManager.class);
+            imm.showSoftInput(this, 0);
+            mHasPendingShowSoftInputRequest = false;
+        }
+    }
+
+    public void scheduleShowSoftInput() {
+        final InputMethodManager imm = getContext().getSystemService(InputMethodManager.class);
+        if (imm.isActive(this)) {
+            // This means that ImeAwareEditText is already connected to the IME.
+            // InputMethodManager#showSoftInput() is guaranteed to pass client-side focus check.
+            mHasPendingShowSoftInputRequest = false;
+            removeCallbacks(mRunShowSoftInputIfNecessary);
+            imm.showSoftInput(this, 0);
+            return;
+        }
+
+        // Otherwise, InputMethodManager#showSoftInput() should be deferred after
+        // onCreateInputConnection().
+        mHasPendingShowSoftInputRequest = true;
+    }
+}
diff --git a/src/com/android/settings/widget/RadioButtonPickerFragment.java b/src/com/android/settings/widget/RadioButtonPickerFragment.java
index 52e8c53..2444539 100644
--- a/src/com/android/settings/widget/RadioButtonPickerFragment.java
+++ b/src/com/android/settings/widget/RadioButtonPickerFragment.java
@@ -141,8 +141,7 @@
         }
         for (Map.Entry<String, CandidateInfo> app : mCandidates.entrySet()) {
             RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
-            bindPreference(
-                    pref, app.getKey(), app.getValue(), defaultKey);
+            bindPreference(pref, app.getKey(), app.getValue(), defaultKey);
             bindPreferenceExtra(pref, app.getKey(), app.getValue(), defaultKey, systemDefaultKey);
             screen.addPreference(pref);
         }
diff --git a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
index 72da2e9..b8fb07d 100644
--- a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
+++ b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
@@ -101,7 +101,7 @@
         Collections.sort(accessPoints, new Comparator<AccessPoint>() {
             public int compare(AccessPoint ap1, AccessPoint ap2) {
                 if (ap1.getConfigName() != null) {
-                    return ap1.getConfigName().compareTo(ap2.getConfigName());
+                    return ap1.getConfigName().compareToIgnoreCase(ap2.getConfigName());
                 } else {
                     return -1;
                 }
diff --git a/src/com/android/settings/wifi/WifiManagerWrapper.java b/src/com/android/settings/wifi/WifiManagerWrapper.java
new file mode 100644
index 0000000..69b5ee9
--- /dev/null
+++ b/src/com/android/settings/wifi/WifiManagerWrapper.java
@@ -0,0 +1,23 @@
+package com.android.settings.wifi;
+
+import android.net.wifi.WifiManager;
+
+/**
+ * Wrapper around {@link WifiManager} to facilitate unit testing.
+ *
+ * TODO: delete this class once robolectric supports Android O
+ */
+public class WifiManagerWrapper {
+    private final WifiManager mWifiManager;
+
+    public WifiManagerWrapper(WifiManager wifiManager) {
+        mWifiManager = wifiManager;
+    }
+
+    /**
+     * {@link WifiManager#getCurrentNetworkWpsNfcConfigurationToken}
+     */
+    public String getCurrentNetworkWpsNfcConfigurationToken() {
+        return mWifiManager.getCurrentNetworkWpsNfcConfigurationToken();
+    }
+}
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index ab1e04e..e9204f9 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -139,10 +139,6 @@
     // should Next button only be enabled when we have a connection?
     private boolean mEnableNextOnConnection;
 
-    // should see all networks instead of collapsing networks and showing mSeeAllNetworksPreference.
-    private boolean mSeeAllNetworks;
-    private static final int NETWORKS_TO_INITIALLY_SHOW = 5;
-
     // Save the dialog details
     private int mDialogMode;
     private AccessPoint mDlgAccessPoint;
@@ -160,7 +156,6 @@
     private PreferenceCategory mAccessPointsPreferenceCategory;
     private PreferenceCategory mAdditionalSettingsPreferenceCategory;
     private Preference mAddPreference;
-    private Preference mSeeAllNetworksPreference;
     private Preference mConfigureWifiSettingsPreference;
     private Preference mSavedNetworksPreference;
     private LinkablePreference mStatusMessagePreference;
@@ -210,10 +205,6 @@
         mAddPreference = new Preference(prefContext);
         mAddPreference.setIcon(R.drawable.ic_menu_add_inset);
         mAddPreference.setTitle(R.string.wifi_add_network);
-        mSeeAllNetworksPreference = new Preference(prefContext);
-        mSeeAllNetworksPreference.setIcon(R.drawable.ic_arrow_down_24dp);
-        mSeeAllNetworksPreference.setTitle(R.string.wifi_see_all_networks_button_title);
-        mSeeAllNetworks = false;
         mStatusMessagePreference = new LinkablePreference(prefContext);
 
         mUserBadgeCache = new AccessPointPreference.UserBadgeCache(getPackageManager());
@@ -335,6 +326,8 @@
 
         // On/off switch is hidden for Setup Wizard (returns null)
         mWifiEnabler = createWifiEnabler();
+
+        mWifiTracker.startTracking();
     }
 
     /**
@@ -354,7 +347,6 @@
             mWifiEnabler.resume(activity);
         }
 
-        mWifiTracker.startTracking();
         activity.invalidateOptionsMenu();
     }
 
@@ -364,7 +356,11 @@
         if (mWifiEnabler != null) {
             mWifiEnabler.pause();
         }
+    }
 
+    @Override
+    public void onStop() {
+        super.onStop();
         mWifiTracker.stopTracking();
     }
 
@@ -520,9 +516,6 @@
             }
         } else if (preference == mAddPreference) {
             onAddNetworkPressed();
-        } else if (preference == mSeeAllNetworksPreference) {
-            mSeeAllNetworks = true;
-            onAccessPointsChanged();
         } else {
             return super.onPreferenceTreeClick(preference);
         }
@@ -577,12 +570,12 @@
             case WRITE_NFC_DIALOG_ID:
                 if (mSelectedAccessPoint != null) {
                     mWifiToNfcDialog = new WriteWifiConfigToNfcDialog(
-                            getActivity(), mSelectedAccessPoint.getConfig().networkId,
+                            getActivity(),
                             mSelectedAccessPoint.getSecurity(),
-                            mWifiManager);
+                            new WifiManagerWrapper(mWifiManager));
                 } else if (mWifiNfcDialogSavedState != null) {
-                    mWifiToNfcDialog = new WriteWifiConfigToNfcDialog(
-                            getActivity(), mWifiNfcDialogSavedState, mWifiManager);
+                    mWifiToNfcDialog = new WriteWifiConfigToNfcDialog(getActivity(),
+                            mWifiNfcDialogSavedState, new WifiManagerWrapper(mWifiManager));
                 }
 
                 return mWifiToNfcDialog;
@@ -666,12 +659,8 @@
 
         int index =
                 configureConnectedAccessPointPreferenceCategory(accessPoints) ? 1 : 0;
-        boolean fewerNetworksThanLimit =
-                accessPoints.size() <= index + NETWORKS_TO_INITIALLY_SHOW;
-        int numAccessPointsToShow = mSeeAllNetworks || fewerNetworksThanLimit
-                ? accessPoints.size() : index + NETWORKS_TO_INITIALLY_SHOW;
-
-        for (; index < numAccessPointsToShow; index++) {
+        int numAccessPoints = accessPoints.size();
+        for (; index < numAccessPoints; index++) {
             AccessPoint accessPoint = accessPoints.get(index);
             // Ignore access points that are out of range.
             if (accessPoint.isReachable()) {
@@ -702,15 +691,8 @@
             }
         }
         removeCachedPrefs(mAccessPointsPreferenceCategory);
-        if (mSeeAllNetworks || fewerNetworksThanLimit) {
-            mAccessPointsPreferenceCategory.removePreference(mSeeAllNetworksPreference);
-            mAddPreference.setOrder(index);
-            mAccessPointsPreferenceCategory.addPreference(mAddPreference);
-        } else {
-            mAccessPointsPreferenceCategory.removePreference(mAddPreference);
-            mSeeAllNetworksPreference.setOrder(index);
-            mAccessPointsPreferenceCategory.addPreference(mSeeAllNetworksPreference);
-        }
+        mAddPreference.setOrder(index);
+        mAccessPointsPreferenceCategory.addPreference(mAddPreference);
         setConfigureWifiSettingsVisibility();
 
         if (!hasAvailableAccessPoints) {
@@ -810,8 +792,17 @@
             return;
         }
         mAdditionalSettingsPreferenceCategory.addPreference(mConfigureWifiSettingsPreference);
-        if (mWifiTracker.doSavedNetworksExist()) {
+        boolean wifiWakeupEnabled = Settings.Global.getInt(
+                getContentResolver(), Settings.Global.WIFI_WAKEUP_ENABLED, 0) == 1;
+        mConfigureWifiSettingsPreference.setSummary(getString(wifiWakeupEnabled
+                ? R.string.wifi_configure_settings_preference_summary_wakeup_on
+                : R.string.wifi_configure_settings_preference_summary_wakeup_off));
+        int numSavedNetworks = mWifiTracker.getNumSavedNetworks();
+        if (numSavedNetworks > 0) {
             mAdditionalSettingsPreferenceCategory.addPreference(mSavedNetworksPreference);
+            mSavedNetworksPreference.setSummary(
+                    getResources().getQuantityString(R.plurals.wifi_saved_access_points_summary,
+                            numSavedNetworks, numSavedNetworks));
         } else {
             mAdditionalSettingsPreferenceCategory.removePreference(mSavedNetworksPreference);
         }
diff --git a/src/com/android/settings/wifi/WriteWifiConfigToNfcDialog.java b/src/com/android/settings/wifi/WriteWifiConfigToNfcDialog.java
index 0d3f3b6..6fca8f2 100644
--- a/src/com/android/settings/wifi/WriteWifiConfigToNfcDialog.java
+++ b/src/com/android/settings/wifi/WriteWifiConfigToNfcDialog.java
@@ -56,7 +56,6 @@
     private static final String PASSWORD_FORMAT = "102700%s%s";
     private static final int HEX_RADIX = 16;
     private static final char[] hexArray = "0123456789ABCDEF".toCharArray();
-    private static final String NETWORK_ID = "network_id";
     private static final String SECURITY = "security";
 
     private final PowerManager.WakeLock mWakeLock;
@@ -69,33 +68,29 @@
     private TextView mLabelView;
     private CheckBox mPasswordCheckBox;
     private ProgressBar mProgressBar;
-    private WifiManager mWifiManager;
+    private WifiManagerWrapper mWifiManager;
     private String mWpsNfcConfigurationToken;
     private Context mContext;
-    private int mNetworkId;
     private int mSecurity;
 
-    WriteWifiConfigToNfcDialog(Context context, int networkId, int security,
-            WifiManager wifiManager) {
+    WriteWifiConfigToNfcDialog(Context context, int security, WifiManagerWrapper wifiManager) {
         super(context);
 
         mContext = context;
         mWakeLock = ((PowerManager) context.getSystemService(Context.POWER_SERVICE))
                 .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "WriteWifiConfigToNfcDialog:wakeLock");
         mOnTextChangedHandler = new Handler();
-        mNetworkId = networkId;
         mSecurity = security;
         mWifiManager = wifiManager;
     }
 
-    WriteWifiConfigToNfcDialog(Context context, Bundle savedState, WifiManager wifiManager) {
+    WriteWifiConfigToNfcDialog(Context context, Bundle savedState, WifiManagerWrapper wifiManager) {
         super(context);
 
         mContext = context;
         mWakeLock = ((PowerManager) context.getSystemService(Context.POWER_SERVICE))
                 .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "WriteWifiConfigToNfcDialog:wakeLock");
         mOnTextChangedHandler = new Handler();
-        mNetworkId = savedState.getInt(NETWORK_ID);
         mSecurity = savedState.getInt(SECURITY);
         mWifiManager = wifiManager;
     }
@@ -114,12 +109,12 @@
                 mContext.getResources().getString(com.android.internal.R.string.cancel),
                 (OnClickListener) null);
 
-        mPasswordView = (TextView) mView.findViewById(R.id.password);
-        mLabelView = (TextView) mView.findViewById(R.id.password_label);
+        mPasswordView = mView.findViewById(R.id.password);
+        mLabelView = mView.findViewById(R.id.password_label);
         mPasswordView.addTextChangedListener(this);
-        mPasswordCheckBox = (CheckBox) mView.findViewById(R.id.show_password);
+        mPasswordCheckBox = mView.findViewById(R.id.show_password);
         mPasswordCheckBox.setOnCheckedChangeListener(this);
-        mProgressBar = (ProgressBar) mView.findViewById(R.id.progress_bar);
+        mProgressBar = mView.findViewById(R.id.progress_bar);
 
         super.onCreate(savedInstanceState);
 
@@ -135,8 +130,7 @@
         mWakeLock.acquire();
 
         String password = mPasswordView.getText().toString();
-        String wpsNfcConfigurationToken
-                = mWifiManager.getWpsNfcConfigurationToken(mNetworkId);
+        String wpsNfcConfigurationToken = mWifiManager.getCurrentNetworkWpsNfcConfigurationToken();
         String passwordHex = byteArrayToHexString(password.getBytes());
 
         String passwordLength = password.length() >= HEX_RADIX
@@ -180,7 +174,6 @@
     }
 
     public void saveState(Bundle state) {
-        state.putInt(NETWORK_ID, mNetworkId);
         state.putInt(SECURITY, mSecurity);
     }
 
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index 1ed25f2..d0e21e926 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -149,7 +149,6 @@
     @Override
     public void onResume() {
         mWifiInfo = mWifiManager.getConnectionInfo();
-        mWifiConfig = mWifiManager.getWifiApConfiguration();
 
         refreshFromWifiInfo();
         setIpText();
@@ -257,4 +256,17 @@
         }
         mDnsPref.setDetailText(builder.toString());
     }
+
+    /**
+     * Forgets the wifi network associated with this preference.
+     */
+    public void forgetNetwork() {
+        if (mWifiConfig.ephemeral) {
+            mWifiManager.disableEphemeralNetwork(mWifiConfig.SSID);
+        } else if (mWifiConfig.isPasspoint()) {
+            mWifiManager.removePasspointConfiguration(mWifiConfig.FQDN);
+        } else {
+            mWifiManager.forget(mWifiConfig.networkId, null /* action listener */);
+        }
+    }
 }
diff --git a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
index 0073202..ade9d6a 100644
--- a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
+++ b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
@@ -19,6 +19,7 @@
 import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
 import android.os.Bundle;
+import android.view.View;
 import android.widget.Button;
 
 import com.android.internal.logging.nano.MetricsProto;
@@ -69,17 +70,9 @@
     }
 
     private void forgetNetwork() {
-        WifiInfo info = mWifiDetailPreferenceController.getWifiInfo();
         mMetricsFeatureProvider.action(getActivity(), MetricsProto.MetricsEvent.ACTION_WIFI_FORGET);
-        if (!info.isEphemeral()) {
-                // Network is active but has no network ID - must be ephemeral.
-                mWifiManager.disableEphemeralNetwork(
-                        AccessPoint.convertToQuotedString(info.getSSID()));
-        } else if (mAccessPoint.getConfig().isPasspoint()) {
-            mWifiManager.removePasspointConfiguration(mAccessPoint.getConfig().FQDN);
-        } else {
-            mWifiManager.forget(info.getNetworkId(), null /* action listener */);
-        }
+        mWifiDetailPreferenceController.forgetNetwork();
+        mForgetButton.setEnabled(false);
     }
 
     @Override
diff --git a/tests/app/src/com/android/settings/notification/ZenModeSettingsIntegrationTest.java b/tests/app/src/com/android/settings/notification/ZenModeSettingsIntegrationTest.java
new file mode 100644
index 0000000..e7e5e19
--- /dev/null
+++ b/tests/app/src/com/android/settings/notification/ZenModeSettingsIntegrationTest.java
@@ -0,0 +1,53 @@
+package com.android.settings.notification;
+
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.action.ViewActions.click;
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.withText;
+
+import android.content.Context;
+import android.content.Intent;
+import android.provider.Settings;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.LargeTest;
+import android.support.test.runner.AndroidJUnit4;
+import android.support.test.uiautomator.UiDevice;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+@LargeTest
+public class ZenModeSettingsIntegrationTest {
+    private static final String WM_DISMISS_KEYGUARD_COMMAND = "wm dismiss-keyguard";
+
+    private Context mContext;
+    private UiDevice mUiDevice;
+
+    @Before
+    public void setUp() throws Exception {
+        mContext = InstrumentationRegistry.getTargetContext();
+        mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+        mUiDevice.wakeUp();
+        mUiDevice.executeShellCommand(WM_DISMISS_KEYGUARD_COMMAND);
+    }
+
+    @Test
+    public void testAutomaticRulesAppear() {
+        launchZenSettings();
+        onView(withText("Automatic rules")).check(matches(isDisplayed()));
+        onView(withText("Weekend")).check(matches(isDisplayed()));
+        onView(withText("Add more")).check(matches(isDisplayed())).perform(click());
+        onView(withText("Choose rule type")).check(matches(isDisplayed()));
+    }
+
+    private void launchZenSettings() {
+        Intent settingsIntent = new Intent(Settings.ACTION_ZEN_MODE_SETTINGS)
+                .setPackage(mContext.getPackageName())
+                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        mContext.startActivity(settingsIntent);
+    }
+}
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index 778440d..240b8eb 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -4,5 +4,6 @@
 com.android.settings.inputmethod.InputAndGestureSettings
 com.android.settings.accounts.AccountDetailDashboardFragment
 com.android.settings.fuelgauge.PowerUsageDetail
+com.android.settings.fuelgauge.AdvancedPowerUsageDetail
 com.android.settings.deviceinfo.StorageProfileFragment
 com.android.settings.wifi.details.WifiNetworkDetailsFragment
diff --git a/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java b/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java
index ea889a5..c43ad3c 100644
--- a/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java
@@ -16,10 +16,20 @@
 
 package com.android.settings;
 
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import android.content.Context;
+import android.os.Build;
 import android.os.UserManager;
 import android.support.v7.preference.PreferenceScreen;
 
+import com.android.settings.dashboard.SummaryLoader;
+import com.android.settingslib.DeviceInfoUtils;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -28,11 +38,6 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.annotation.Config;
 
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public class DeviceInfoSettingsTest {
@@ -43,6 +48,8 @@
     private PreferenceScreen mScreen;
     @Mock
     private UserManager mUserManager;
+    @Mock
+    private SummaryLoader mSummaryLoader;
 
     private DeviceInfoSettings mSettings;
 
@@ -58,4 +65,14 @@
     public void getPrefXml_shouldReturnDeviceInfoXml() {
         assertThat(mSettings.getPreferenceScreenResId()).isEqualTo(R.xml.device_info_settings);
     }
+
+    @Test
+    public void getSummary_shouldReturnDeviceModel() {
+        final SummaryLoader.SummaryProvider mProvider = DeviceInfoSettings.SUMMARY_PROVIDER_FACTORY
+                .createSummaryProvider(null, mSummaryLoader);
+
+        mProvider.setListening(true);
+
+        verify(mSummaryLoader).setSummary(mProvider, Build.MODEL + DeviceInfoUtils.getMsvSuffix());
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/UtilsTest.java b/tests/robotests/src/com/android/settings/UtilsTest.java
index 324e751..8b7605c 100644
--- a/tests/robotests/src/com/android/settings/UtilsTest.java
+++ b/tests/robotests/src/com/android/settings/UtilsTest.java
@@ -9,6 +9,7 @@
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
+import android.content.pm.ApplicationInfo;
 import android.net.ConnectivityManager;
 import android.net.LinkAddress;
 import android.net.LinkProperties;
@@ -116,4 +117,28 @@
 
         Utils.maybeInitializeVolume(storageManager, new Bundle());
     }
+
+    @Test
+    public void getInstallationStatus_notInstalled_shouldReturnUninstalled() {
+        assertThat(Utils.getInstallationStatus(new ApplicationInfo()))
+                .isEqualTo(R.string.not_installed);
+    }
+
+    @Test
+    public void getInstallationStatus_enabled_shouldReturnInstalled() {
+        final ApplicationInfo info = new ApplicationInfo();
+        info.flags = ApplicationInfo.FLAG_INSTALLED;
+        info.enabled = true;
+
+        assertThat(Utils.getInstallationStatus(info)).isEqualTo(R.string.installed);
+    }
+
+    @Test
+    public void getInstallationStatus_disabled_shouldReturnDisabled() {
+        final ApplicationInfo info = new ApplicationInfo();
+        info.flags = ApplicationInfo.FLAG_INSTALLED;
+        info.enabled = false;
+
+        assertThat(Utils.getInstallationStatus(info)).isEqualTo(R.string.disabled);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/accessibility/ShortcutServicePickerFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ShortcutServicePickerFragmentTest.java
new file mode 100644
index 0000000..9161f06
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/ShortcutServicePickerFragmentTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.accessibility;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.UserManager;
+
+import android.test.mock.MockContentResolver;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.applications.PackageManagerWrapper;
+import com.android.settings.testutils.FakeFeatureFactory;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
+import org.robolectric.annotation.Config;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class ShortcutServicePickerFragmentTest {
+
+    private static final String TEST_SERVICE_KEY_1 = "abc/123";
+    private static final String TEST_SERVICE_KEY_2 = "abcd/1234";
+
+    private static final String SUMMARY_1 = "summary1";
+    private static final String SUMMARY_2 = "summary2";
+
+    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+    private Activity mActivity;
+    @Mock
+    private UserManager mUserManager;
+    @Mock
+    private PackageManagerWrapper mPackageManager;
+
+    private ShortcutServicePickerFragment mFragment;
+    private MockContentResolver mContentResolver;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        FakeFeatureFactory.setupForTest(mActivity);
+        when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+
+        mFragment = spy(new ShortcutServicePickerFragment());
+        mFragment.onAttach((Context) mActivity);
+
+        doReturn(RuntimeEnvironment.application).when(mFragment).getContext();
+    }
+
+    @Test
+    public void setAndGetDefaultAppKey_shouldUpdateDefaultAppKey() {
+        assertThat(mFragment.setDefaultKey(TEST_SERVICE_KEY_1)).isTrue();
+        assertThat(mFragment.getDefaultKey()).isEqualTo(TEST_SERVICE_KEY_1);
+    }
+}
+
diff --git a/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
index a513f71..f946780 100644
--- a/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
@@ -88,7 +88,7 @@
                 mPackageManagerService, mDevicePolicyManager);
     }
 
-    private void verifyCalculateNumberOfInstalledApps(boolean async) {
+    private void verifyCalculateNumberOfPolicyInstalledApps(boolean async) {
         setUpUsersAndInstalledApps();
 
         when(mPackageManager.getInstallReason(APP_1, new UserHandle(MAIN_USER_ID)))
@@ -96,18 +96,8 @@
         when(mPackageManager.getInstallReason(APP_2, new UserHandle(MANAGED_PROFILE_ID)))
                 .thenReturn(PackageManager.INSTALL_REASON_POLICY);
 
-        // Count all installed apps.
         mAppCount = -1;
-        mProvider.calculateNumberOfInstalledApps(ApplicationFeatureProvider.IGNORE_INSTALL_REASON,
-                async, (num) -> mAppCount = num);
-        if (async) {
-            ShadowApplication.runBackgroundTasks();
-        }
-        assertThat(mAppCount).isEqualTo(2);
-
-        // Count apps with specific install reason only.
-        mAppCount = -1;
-        mProvider.calculateNumberOfInstalledApps(PackageManager.INSTALL_REASON_POLICY, async,
+        mProvider.calculateNumberOfPolicyInstalledApps(async,
                 (num) -> mAppCount = num);
         if (async) {
             ShadowApplication.runBackgroundTasks();
@@ -117,12 +107,12 @@
 
     @Test
     public void testCalculateNumberOfInstalledAppsSync() {
-        verifyCalculateNumberOfInstalledApps(false /* async */);
+        verifyCalculateNumberOfPolicyInstalledApps(false /* async */);
     }
 
     @Test
     public void testCalculateNumberOfInstalledAppsAsync() {
-        verifyCalculateNumberOfInstalledApps(true /* async */);
+        verifyCalculateNumberOfPolicyInstalledApps(true /* async */);
     }
 
     private void verifyCalculateNumberOfAppsWithAdminGrantedPermissions(boolean async)
diff --git a/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java b/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java
index 8b1c9c9..1134ec5 100644
--- a/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java
+++ b/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java
@@ -156,7 +156,7 @@
                 .thenReturn(PackageManager.INSTALL_REASON_UNKNOWN);
 
         // Count the number of all apps installed, irrespective of install reason.
-        count(ApplicationFeatureProvider.IGNORE_INSTALL_REASON, async);
+        count(InstalledAppCounter.IGNORE_INSTALL_REASON, async);
         assertThat(mInstalledAppCount).isEqualTo(5);
 
         // Verify that installed packages were retrieved for the users returned by
diff --git a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
index b0cd8d5..bf00889 100644
--- a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
@@ -68,31 +68,6 @@
     }
 
     @Test
-    public void getInstallationStatus_notInstalled_shouldReturnUninstalled() {
-
-        assertThat(mAppDetail.getInstallationStatus(new ApplicationInfo()))
-                .isEqualTo(R.string.not_installed);
-    }
-
-    @Test
-    public void getInstallationStatus_enabled_shouldReturnInstalled() {
-        final ApplicationInfo info = new ApplicationInfo();
-        info.flags = ApplicationInfo.FLAG_INSTALLED;
-        info.enabled = true;
-
-        assertThat(mAppDetail.getInstallationStatus(info)).isEqualTo(R.string.installed);
-    }
-
-    @Test
-    public void getInstallationStatus_disabled_shouldReturnDisabled() {
-        final ApplicationInfo info = new ApplicationInfo();
-        info.flags = ApplicationInfo.FLAG_INSTALLED;
-        info.enabled = false;
-
-        assertThat(mAppDetail.getInstallationStatus(info)).isEqualTo(R.string.disabled);
-    }
-
-    @Test
     public void shouldShowUninstallForAll_installForOneOtherUserOnly_shouldReturnTrue() {
         when(mDevicePolicyManager.packageHasActiveAdmins(anyString())).thenReturn(false);
         when(mUserManager.getUsers().size()).thenReturn(2);
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java
index 2c88179..2d9ae9b 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java
@@ -17,7 +17,6 @@
 package com.android.settings.applications.defaultapps;
 
 
-import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java
index a2770a0..cc059ad 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java
@@ -86,7 +86,8 @@
     public void register_true_shouldSendSummaryChange() {
         mSummaryUpdater.register(true);
 
-        verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_connected));
+        verify(mListener).onSummaryChanged(
+            mContext.getString(R.string.bluetooth_connected_summary));
     }
 
     @Test
@@ -102,7 +103,8 @@
         mSummaryUpdater.register(true);
         mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_ON);
 
-        verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_connected));
+        verify(mListener).onSummaryChanged(
+            mContext.getString(R.string.bluetooth_connected_summary));
     }
 
     @Test
@@ -111,7 +113,8 @@
         mSummaryUpdater.register(true);
         mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_TURNING_ON);
 
-        verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_disconnected));
+        verify(mListener).onSummaryChanged(
+            mContext.getString(R.string.disconnected));
     }
 
     @Test
@@ -128,7 +131,8 @@
         mSummaryUpdater.onConnectionStateChanged(null /* device */,
             BluetoothAdapter.STATE_CONNECTED);
 
-        verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_connected));
+        verify(mListener).onSummaryChanged(
+            mContext.getString(R.string.bluetooth_connected_summary));
     }
 
     @Test
@@ -137,7 +141,8 @@
         mSummaryUpdater.onConnectionStateChanged(null /* device */,
             BluetoothAdapter.STATE_CONNECTED);
 
-        verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_disconnected));
+        verify(mListener).onSummaryChanged(
+            mContext.getString(R.string.disconnected));
     }
 
     @Test
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 18b0c82..7d1f79b 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
@@ -31,6 +31,7 @@
 import android.app.Fragment;
 import android.content.Context;
 import android.content.Intent;
+import android.graphics.drawable.Drawable;
 import android.os.UserHandle;
 import android.os.storage.VolumeInfo;
 import android.support.v7.preference.PreferenceScreen;
@@ -243,4 +244,43 @@
         assertThat(system.getSummary().toString()).isEqualTo("16.00KB");
         assertThat(files.getSummary().toString()).isEqualTo("5.00KB");
     }
+
+    @Test
+    public void settingUserIdAppliesNewIcons() {
+        StorageItemPreference audio = spy(new StorageItemPreference(mContext));
+        audio.setIcon(R.drawable.ic_photo_library_vd_theme_24);
+        StorageItemPreference image = spy(new StorageItemPreference(mContext));
+        image.setIcon(R.drawable.ic_photo_library_vd_theme_24);
+        StorageItemPreference games = spy(new StorageItemPreference(mContext));
+        games.setIcon(R.drawable.ic_photo_library_vd_theme_24);
+        StorageItemPreference apps = spy(new StorageItemPreference(mContext));
+        apps.setIcon(R.drawable.ic_photo_library_vd_theme_24);
+        StorageItemPreference system = spy(new StorageItemPreference(mContext));
+        system.setIcon(R.drawable.ic_photo_library_vd_theme_24);
+        StorageItemPreference files = spy(new StorageItemPreference(mContext));
+        files.setIcon(R.drawable.ic_photo_library_vd_theme_24);
+        PreferenceScreen screen = mock(PreferenceScreen.class);
+        when(screen.findPreference(
+                eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
+        when(screen.findPreference(
+                eq(StorageItemPreferenceController.PHOTO_KEY))).thenReturn(image);
+        when(screen.findPreference(
+                eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
+        when(screen.findPreference(
+                eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
+        when(screen.findPreference(
+                eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
+        when(screen.findPreference(
+                eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
+        mController.displayPreference(screen);
+
+        mController.setUserId(new UserHandle(10));
+
+        verify(audio, times(2)).setIcon(any(Drawable.class));
+        verify(image, times(2)).setIcon(any(Drawable.class));
+        verify(games, times(2)).setIcon(any(Drawable.class));
+        verify(apps, times(2)).setIcon(any(Drawable.class));
+        verify(system, times(2)).setIcon(any(Drawable.class));
+        verify(files, times(2)).setIcon(any(Drawable.class));
+    }
 }
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/display/VrDisplayPreferencePickerTest.java b/tests/robotests/src/com/android/settings/display/VrDisplayPreferencePickerTest.java
new file mode 100644
index 0000000..56d4c47
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/VrDisplayPreferencePickerTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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.display;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+import android.content.ContentResolver;
+import android.os.UserHandle;
+import android.provider.Settings;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.shadow.ShadowSecureSettings;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.List;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class VrDisplayPreferencePickerTest {
+
+    private VrDisplayPreferencePicker mPicker;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        mPicker = spy(new VrDisplayPreferencePicker());
+        doReturn(RuntimeEnvironment.application).when(mPicker).getContext();
+    }
+
+    @Test
+    public void verifyMetricsConstant() {
+        assertThat(mPicker.getMetricsCategory())
+                .isEqualTo(MetricsProto.MetricsEvent.VR_DISPLAY_PREFERENCE);
+    }
+
+    @Test
+    public void getCandidates_shouldReturnTwoCandidates() {
+        List<VrDisplayPreferencePicker.VrCandidateInfo> candidates = mPicker.getCandidates();
+
+        assertThat(candidates.size()).isEqualTo(2);
+        assertThat(candidates.get(0).getKey())
+                .isEqualTo(VrDisplayPreferencePicker.PREF_KEY_PREFIX + 0);
+        assertThat(candidates.get(1).getKey())
+                .isEqualTo(VrDisplayPreferencePicker.PREF_KEY_PREFIX + 1);
+    }
+
+    @Test
+    @Config(shadows = ShadowSecureSettings.class)
+    public void getKey_shouldGetFromSettingsProvider() {
+        final ContentResolver cr = RuntimeEnvironment.application.getContentResolver();
+        Settings.Secure.putIntForUser(cr, Settings.Secure.VR_DISPLAY_MODE, 1,
+                UserHandle.myUserId());
+
+        assertThat(mPicker.getDefaultKey())
+                .isEqualTo(VrDisplayPreferencePicker.PREF_KEY_PREFIX + 1);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java
index 6442242..b5d6b7a 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java
@@ -21,11 +21,14 @@
 import com.android.settings.SettingsRobolectricTestRunner;
 import com.android.settings.TestConfig;
 
+import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.robolectric.annotation.Config;
 
 import java.util.Date;
 
+import static com.google.common.truth.Truth.assertThat;
+
 /**
  * Tests for {@link AdminActionPreferenceControllerBase}.
  */
@@ -47,6 +50,11 @@
         mDate = date;
     }
 
+    @Test
+    public void testIsAvailable() {
+        assertThat(mController.isAvailable()).isTrue();
+    }
+
     @Override
     public String getPreferenceKey() {
         return null;
diff --git a/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java
index ae1e264..b9c838b 100644
--- a/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java
@@ -20,11 +20,13 @@
 import com.android.settings.TestConfig;
 import com.android.settings.testutils.FakeFeatureFactory;
 
+import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.robolectric.annotation.Config;
 
 import java.util.Date;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.Mockito.when;
 
 /**
@@ -47,6 +49,11 @@
                 .thenReturn(date);
     }
 
+    @Test
+    public void testIsAvailable() {
+        assertThat(mController.isAvailable()).isTrue();
+    }
+
     @Override
     public String getPreferenceKey() {
         return "bug_reports";
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
index ff884e4..4255d96 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
@@ -17,8 +17,6 @@
 package com.android.settings.enterprise;
 
 import android.content.Context;
-import android.content.pm.PackageManager;
-import android.content.res.Resources;
 import android.support.v7.preference.Preference;
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -70,11 +68,10 @@
         doAnswer(new Answer() {
             public Object answer(InvocationOnMock invocation) {
                 ((ApplicationFeatureProvider.NumberOfAppsCallback)
-                        invocation.getArguments()[2]).onNumberOfAppsResult(number);
+                        invocation.getArguments()[1]).onNumberOfAppsResult(number);
                 return null;
             }}).when(mFeatureFactory.applicationFeatureProvider)
-                    .calculateNumberOfInstalledApps(eq(PackageManager.INSTALL_REASON_POLICY),
-                            eq(async), anyObject());
+                    .calculateNumberOfPolicyInstalledApps(eq(async), anyObject());
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
index 2afcab9..8d78ef7 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
@@ -177,6 +177,24 @@
     }
 
     @Test
+    public void testIsSecurityLoggingEnabled() {
+        when(mDevicePolicyManager.isSecurityLoggingEnabled(null)).thenReturn(false);
+        assertThat(mProvider.isSecurityLoggingEnabled()).isFalse();
+
+        when(mDevicePolicyManager.isSecurityLoggingEnabled(null)).thenReturn(true);
+        assertThat(mProvider.isSecurityLoggingEnabled()).isTrue();
+    }
+
+    @Test
+    public void testIsNetworkLoggingEnabled() {
+        when(mDevicePolicyManager.isNetworkLoggingEnabled(null)).thenReturn(false);
+        assertThat(mProvider.isNetworkLoggingEnabled()).isFalse();
+
+        when(mDevicePolicyManager.isNetworkLoggingEnabled(null)).thenReturn(true);
+        assertThat(mProvider.isNetworkLoggingEnabled()).isTrue();
+    }
+
+    @Test
     public void testIsAlwaysOnVpnSetInPrimaryUser() {
         when(mConnectivityManger.getAlwaysOnVpnPackageForUser(MY_USER_ID)).thenReturn(null);
         assertThat(mProvider.isAlwaysOnVpnSetInPrimaryUser()).isFalse();
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
index 8a11779..2225687 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
@@ -117,31 +117,34 @@
 
     private void verifyPreferenceControllers(List<PreferenceController> controllers) {
         assertThat(controllers).isNotNull();
-        assertThat(controllers.size()).isEqualTo(16);
-        assertThat(controllers.get(0)).isInstanceOf(InstalledPackagesPreferenceController.class);
-        assertThat(controllers.get(1)).isInstanceOf(NetworkLogsPreferenceController.class);
-        assertThat(controllers.get(2)).isInstanceOf(BugReportsPreferenceController.class);
-        assertThat(controllers.get(3)).isInstanceOf(SecurityLogsPreferenceController.class);
-        assertThat(controllers.get(4)).isInstanceOf(
+        assertThat(controllers.size()).isEqualTo(15);
+        int position = 0;
+        assertThat(controllers.get(position++)).isInstanceOf(NetworkLogsPreferenceController.class);
+        assertThat(controllers.get(position++)).isInstanceOf(BugReportsPreferenceController.class);
+        assertThat(controllers.get(position++)).isInstanceOf(
+                SecurityLogsPreferenceController.class);
+        assertThat(controllers.get(position++)).isInstanceOf(
                 EnterpriseInstalledPackagesPreferenceController.class);
-        assertThat(controllers.get(5)).isInstanceOf(
+        assertThat(controllers.get(position++)).isInstanceOf(
                 AdminGrantedLocationPermissionsPreferenceController.class);
-        assertThat(controllers.get(6)).isInstanceOf(
+        assertThat(controllers.get(position++)).isInstanceOf(
                 AdminGrantedMicrophonePermissionPreferenceController.class);
-        assertThat(controllers.get(7)).isInstanceOf(
+        assertThat(controllers.get(position++)).isInstanceOf(
                 AdminGrantedCameraPermissionPreferenceController.class);
-        assertThat(controllers.get(8)).isInstanceOf(
+        assertThat(controllers.get(position++)).isInstanceOf(
                 EnterpriseSetDefaultAppsPreferenceController.class);
-        assertThat(controllers.get(9)).isInstanceOf(
+        assertThat(controllers.get(position++)).isInstanceOf(
                 AlwaysOnVpnPrimaryUserPreferenceController.class);
-        assertThat(controllers.get(10)).isInstanceOf(
+        assertThat(controllers.get(position++)).isInstanceOf(
                 AlwaysOnVpnManagedProfilePreferenceController.class);
-        assertThat(controllers.get(11)).isInstanceOf(GlobalHttpProxyPreferenceController.class);
-        assertThat(controllers.get(12)).isInstanceOf(CaCertsPreferenceController.class);
-        assertThat(controllers.get(13)).isInstanceOf(
+        assertThat(controllers.get(position++)).isInstanceOf(
+                GlobalHttpProxyPreferenceController.class);
+        assertThat(controllers.get(position++)).isInstanceOf(
+                CaCertsPreferenceController.class);
+        assertThat(controllers.get(position++)).isInstanceOf(
                 FailedPasswordWipePrimaryUserPreferenceController.class);
-        assertThat(controllers.get(14)).isInstanceOf(
+        assertThat(controllers.get(position++)).isInstanceOf(
                 FailedPasswordWipeManagedProfilePreferenceController.class);
-        assertThat(controllers.get(15)).isInstanceOf(ImePreferenceController.class);
+        assertThat(controllers.get(position++)).isInstanceOf(ImePreferenceController.class);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/enterprise/InstalledPackagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/InstalledPackagesPreferenceControllerTest.java
deleted file mode 100644
index 4a5a183..0000000
--- a/tests/robotests/src/com/android/settings/enterprise/InstalledPackagesPreferenceControllerTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.enterprise;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v7.preference.Preference;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.R;
-import com.android.settings.SettingsRobolectricTestRunner;
-import com.android.settings.TestConfig;
-import com.android.settings.applications.ApplicationFeatureProvider;
-import com.android.settings.testutils.FakeFeatureFactory;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.robolectric.annotation.Config;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.anyObject;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.when;
-
-/**
- * Tests for {@link InstalledPackagesPreferenceController}.
- */
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public final class InstalledPackagesPreferenceControllerTest {
-
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private Context mContext;
-    private FakeFeatureFactory mFeatureFactory;
-
-    private InstalledPackagesPreferenceController mController;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        FakeFeatureFactory.setupForTest(mContext);
-        mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
-        mController = new InstalledPackagesPreferenceController(mContext);
-    }
-
-    private void setNumberOfInstalledPackages(int number) {
-        doAnswer(new Answer() {
-            public Object answer(InvocationOnMock invocation) {
-                ((ApplicationFeatureProvider.NumberOfAppsCallback)
-                        invocation.getArguments()[2]).onNumberOfAppsResult(number);
-                return null;
-            }}).when(mFeatureFactory.applicationFeatureProvider).calculateNumberOfInstalledApps(
-                    eq(ApplicationFeatureProvider.IGNORE_INSTALL_REASON), eq(true), anyObject());
-    }
-
-    @Test
-    public void testUpdateState() {
-        final Preference preference = new Preference(mContext, null, 0, 0);
-
-        setNumberOfInstalledPackages(0);
-        mController.updateState(preference);
-        assertThat(preference.getSummary()).isEqualTo("");
-
-        setNumberOfInstalledPackages(20);
-        when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_packages,
-                20, 20)).thenReturn("20 packages");
-        mController.updateState(preference);
-        assertThat(preference.getSummary()).isEqualTo("20 packages");
-    }
-
-    @Test
-    public void testIsAvailable() {
-        assertThat(mController.isAvailable()).isTrue();
-    }
-
-    @Test
-    public void testHandlePreferenceTreeClick() {
-        assertThat(mController.handlePreferenceTreeClick(new Preference(mContext, null, 0, 0)))
-                .isFalse();
-    }
-
-    @Test
-    public void testGetPreferenceKey() {
-        assertThat(mController.getPreferenceKey()).isEqualTo("installed_packages");
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/enterprise/NetworkLogsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/NetworkLogsPreferenceControllerTest.java
index fe9fcf6..33360cc 100644
--- a/tests/robotests/src/com/android/settings/enterprise/NetworkLogsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/NetworkLogsPreferenceControllerTest.java
@@ -20,11 +20,13 @@
 import com.android.settings.TestConfig;
 import com.android.settings.testutils.FakeFeatureFactory;
 
+import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.robolectric.annotation.Config;
 
 import java.util.Date;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.Mockito.when;
 
 /**
@@ -47,6 +49,22 @@
                 .thenReturn(date);
     }
 
+    @Test
+    public void testIsAvailable() {
+        setDate(null);
+        when(mFeatureFactory.enterprisePrivacyFeatureProvider.isNetworkLoggingEnabled())
+                .thenReturn(false);
+        assertThat(mController.isAvailable()).isFalse();
+
+        setDate(new Date());
+        assertThat(mController.isAvailable()).isTrue();
+
+        setDate(null);
+        when(mFeatureFactory.enterprisePrivacyFeatureProvider.isNetworkLoggingEnabled())
+                .thenReturn(true);
+        assertThat(mController.isAvailable()).isTrue();
+    }
+
     @Override
     public String getPreferenceKey() {
         return "network_logs";
diff --git a/tests/robotests/src/com/android/settings/enterprise/SecurityLogsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/SecurityLogsPreferenceControllerTest.java
index b260d61..1205b0b 100644
--- a/tests/robotests/src/com/android/settings/enterprise/SecurityLogsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/SecurityLogsPreferenceControllerTest.java
@@ -20,11 +20,13 @@
 import com.android.settings.TestConfig;
 import com.android.settings.testutils.FakeFeatureFactory;
 
+import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.robolectric.annotation.Config;
 
 import java.util.Date;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.Mockito.when;
 
 /**
@@ -47,6 +49,22 @@
                 .thenReturn(date);
     }
 
+    @Test
+    public void testIsAvailable() {
+        setDate(null);
+        when(mFeatureFactory.enterprisePrivacyFeatureProvider.isSecurityLoggingEnabled())
+                .thenReturn(false);
+        assertThat(mController.isAvailable()).isFalse();
+
+        setDate(new Date());
+        assertThat(mController.isAvailable()).isTrue();
+
+        setDate(null);
+        when(mFeatureFactory.enterprisePrivacyFeatureProvider.isSecurityLoggingEnabled())
+                .thenReturn(true);
+        assertThat(mController.isAvailable()).isTrue();
+    }
+
     @Override
     public String getPreferenceKey() {
         return "security_logs";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
new file mode 100644
index 0000000..8b5ce19
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.Fragment;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.graphics.drawable.Drawable;
+import android.os.BatteryStats;
+import android.os.Bundle;
+import android.os.UserHandle;
+import android.view.View;
+
+import com.android.internal.os.BatterySipper;
+import com.android.internal.os.BatteryStatsHelper;
+import com.android.settings.SettingsActivity;
+import com.android.settings.TestConfig;
+import com.android.settings.applications.AppHeaderController;
+import com.android.settings.applications.LayoutPreference;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settingslib.applications.ApplicationsState;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class AdvancedPowerUsageDetailTest {
+    private static final String APP_LABEL = "app label";
+    private static final String SUMMARY = "summary";
+    private static final String[] PACKAGE_NAME = {"com.android.app"};
+    private static final String USAGE_PERCENT = "16";
+    private static final int ICON_ID = 123;
+    private static final int UID = 1;
+    private static final long BACKGROUND_TIME_US = 100 * 1000;
+    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;
+
+    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+    private Context mContext;
+    @Mock
+    private AppHeaderController mAppHeaderController;
+    @Mock
+    private LayoutPreference mHeaderPreference;
+    @Mock
+    private ApplicationsState mState;
+    @Mock
+    private ApplicationsState.AppEntry mAppEntry;
+    @Mock
+    private Drawable mIconDrawable;
+    @Mock
+    private Bundle mBundle;
+    @Mock
+    private BatteryEntry mBatteryEntry;
+    @Mock
+    private BatterySipper mBatterySipper;
+    @Mock
+    private BatteryStatsHelper mBatteryStatsHelper;
+    @Mock
+    private BatteryStats.Uid mUid;
+    private Bundle mTestBundle;
+    private AdvancedPowerUsageDetail mFragment;
+    private FakeFeatureFactory mFeatureFactory;
+    private SettingsActivity mTestActivity;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        FakeFeatureFactory.setupForTest(mContext);
+        mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+
+        mFragment = spy(new AdvancedPowerUsageDetail());
+        doReturn(mContext).when(mFragment).getContext();
+        doReturn(SUMMARY).when(mFragment).getString(anyInt());
+        doReturn(APP_LABEL).when(mBundle).getString(anyString());
+        doReturn(mBundle).when(mFragment).getArguments();
+
+        doReturn(mAppHeaderController).when(mFeatureFactory.applicationFeatureProvider)
+                .newAppHeaderController(any(Fragment.class), any(View.class));
+        doReturn(mAppHeaderController).when(mAppHeaderController).setButtonActions(anyInt(),
+                anyInt());
+        doReturn(mAppHeaderController).when(mAppHeaderController).setIcon(any(Drawable.class));
+        doReturn(mAppHeaderController).when(mAppHeaderController).setIcon(any(
+                ApplicationsState.AppEntry.class));
+        doReturn(mAppHeaderController).when(mAppHeaderController).setLabel(anyString());
+        doReturn(mAppHeaderController).when(mAppHeaderController).setLabel(any(
+                ApplicationsState.AppEntry.class));
+        doReturn(mAppHeaderController).when(mAppHeaderController).setSummary(anyString());
+
+
+        doReturn(UID).when(mBatterySipper).getUid();
+        doReturn(APP_LABEL).when(mBatteryEntry).getLabel();
+        doReturn(BACKGROUND_TIME_US).when(mUid).getProcessStateTime(
+                eq(BatteryStats.Uid.PROCESS_STATE_BACKGROUND), anyLong(), anyInt());
+        doReturn(FOREGROUND_TIME_US).when(mUid).getProcessStateTime(
+                eq(BatteryStats.Uid.PROCESS_STATE_FOREGROUND), anyLong(), anyInt());
+        ReflectionHelpers.setField(mBatteryEntry, "sipper", mBatterySipper);
+        mBatteryEntry.iconId = ICON_ID;
+        mBatterySipper.uidObj = mUid;
+
+        mFragment.mHeaderPreference = mHeaderPreference;
+        mFragment.mState = mState;
+        mAppEntry.info = mock(ApplicationInfo.class);
+
+        mTestActivity = spy(new SettingsActivity());
+
+        final ArgumentCaptor<Bundle> captor = ArgumentCaptor.forClass(Bundle.class);
+
+        Answer<Void> callable = new Answer<Void>() {
+            @Override
+            public Void answer(InvocationOnMock invocation) throws Exception {
+                mBundle = captor.getValue();
+                return null;
+            }
+        };
+        doAnswer(callable).when(mTestActivity).startPreferencePanelAsUser(any(), anyString(),
+                captor.capture(), anyInt(), any(), any());
+    }
+
+    @Test
+    public void testInitHeader_NoAppEntry_BuildByBundle() {
+        mFragment.mAppEntry = null;
+        mFragment.initHeader();
+
+        verify(mAppHeaderController).setIcon(any(Drawable.class));
+        verify(mAppHeaderController).setLabel(APP_LABEL);
+    }
+
+    @Test
+    public void testInitHeader_HasAppEntry_BuildByAppEntry() {
+        mFragment.mAppEntry = mAppEntry;
+        mFragment.initHeader();
+
+        verify(mAppHeaderController).setIcon(mAppEntry);
+        verify(mAppHeaderController).setLabel(mAppEntry);
+    }
+
+    @Test
+    public void testStartBatteryDetailPage_hasBasicData() {
+        AdvancedPowerUsageDetail.startBatteryDetailPage(mTestActivity, null, mBatteryStatsHelper, 0,
+                mBatteryEntry, USAGE_PERCENT);
+
+        assertThat(mBundle.getInt(AdvancedPowerUsageDetail.EXTRA_UID)).isEqualTo(UID);
+        assertThat(mBundle.getLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME)).isEqualTo(
+                BACKGROUND_TIME_MS);
+        assertThat(mBundle.getLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME)).isEqualTo(
+                FOREGROUND_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,
+                mBatteryEntry, USAGE_PERCENT);
+
+        assertThat(mBundle.getString(AdvancedPowerUsageDetail.EXTRA_PACKAGE_NAME)).isEqualTo(
+                PACKAGE_NAME[0]);
+    }
+
+    @Test
+    public void testStartBatteryDetailPage_SystemApp() {
+        mBatterySipper.mPackages = null;
+        AdvancedPowerUsageDetail.startBatteryDetailPage(mTestActivity, null, mBatteryStatsHelper, 0,
+                mBatteryEntry, USAGE_PERCENT);
+
+        assertThat(mBundle.getString(AdvancedPowerUsageDetail.EXTRA_LABEL)).isEqualTo(APP_LABEL);
+        assertThat(mBundle.getInt(AdvancedPowerUsageDetail.EXTRA_ICON_ID)).isEqualTo(ICON_ID);
+        assertThat(mBundle.getString(AdvancedPowerUsageDetail.EXTRA_PACKAGE_NAME)).isEqualTo(null);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryOptimizationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryOptimizationPreferenceControllerTest.java
new file mode 100644
index 0000000..2c5296a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryOptimizationPreferenceControllerTest.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.SettingsActivity;
+import com.android.settings.TestConfig;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class BatteryOptimizationPreferenceControllerTest {
+    private static final String KEY_OPTIMIZATION = "battery_optimization";
+    private static final String KEY_OTHER = "other";
+    @Mock
+    private SettingsActivity mSettingsActivity;
+    @Mock
+    private Fragment mFragment;
+    @Mock
+    private Preference mPreference;
+
+    private BatteryOptimizationPreferenceController mController;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        mController = new BatteryOptimizationPreferenceController(mSettingsActivity, mFragment);
+    }
+
+    @Test
+    public void testHandlePreferenceTreeClick_OptimizationPreference_HandleClick() {
+        when(mPreference.getKey()).thenReturn(KEY_OPTIMIZATION);
+
+        final boolean handled = mController.handlePreferenceTreeClick(mPreference);
+
+        assertThat(handled).isTrue();
+        verify(mSettingsActivity).startPreferencePanel(any(Fragment.class),
+                anyString(), any(Bundle.class), anyInt(), any(CharSequence.class),
+                any(Fragment.class), anyInt());
+    }
+
+    @Test
+    public void testHandlePreferenceTreeClick_OtherPreference_NotHandleClick() {
+        when(mPreference.getKey()).thenReturn(KEY_OTHER);
+
+        final boolean handled = mController.handlePreferenceTreeClick(mPreference);
+
+        assertThat(handled).isFalse();
+        verify(mSettingsActivity, never()).startPreferencePanel(any(Fragment.class),
+                anyString(), any(Bundle.class), anyInt(), any(CharSequence.class),
+                any(Fragment.class), anyInt());
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
new file mode 100644
index 0000000..672cc90
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.fuelgauge;
+
+import android.os.BatteryStats;
+
+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.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+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;
+import static android.os.BatteryStats.Uid.PROCESS_STATE_TOP;
+import static android.os.BatteryStats.Uid.PROCESS_STATE_TOP_SLEEPING;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Matchers.eq;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class BatteryUtilsTest {
+    // unit that used to converted ms to us
+    private static final long UNIT = 1000;
+    private static final long TIME_STATE_TOP = 1500 * UNIT;
+    private static final long TIME_STATE_FOREGROUND_SERVICE = 2000 * UNIT;
+    private static final long TIME_STATE_TOP_SLEEPING = 2500 * UNIT;
+    private static final long TIME_STATE_FOREGROUND = 3000 * UNIT;
+    private static final long TIME_STATE_BACKGROUND = 6000 * UNIT;
+
+    private static final long TIME_EXPECTED_FOREGROUND = 9000;
+    private static final long TIME_EXPECTED_BACKGROUND = 6000;
+    private static final long TIME_EXPECTED_ALL = 15000;
+
+    @Mock
+    BatteryStats.Uid mUid;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        doReturn(TIME_STATE_TOP).when(mUid).getProcessStateTime(eq(PROCESS_STATE_TOP), anyLong(),
+                anyInt());
+        doReturn(TIME_STATE_FOREGROUND_SERVICE).when(mUid).getProcessStateTime(
+                eq(PROCESS_STATE_FOREGROUND_SERVICE), anyLong(), anyInt());
+        doReturn(TIME_STATE_TOP_SLEEPING).when(mUid).getProcessStateTime(
+                eq(PROCESS_STATE_TOP_SLEEPING), anyLong(), anyInt());
+        doReturn(TIME_STATE_FOREGROUND).when(mUid).getProcessStateTime(eq(PROCESS_STATE_FOREGROUND),
+                anyLong(), anyInt());
+        doReturn(TIME_STATE_BACKGROUND).when(mUid).getProcessStateTime(eq(PROCESS_STATE_BACKGROUND),
+                anyLong(), anyInt());
+    }
+
+    @Test
+    public void testGetProcessTimeMs_typeForeground_timeCorrect() {
+        final long time = BatteryUtils.getProcessTimeMs(BatteryUtils.StatusType.FOREGROUND, mUid,
+                BatteryStats.STATS_SINCE_CHARGED);
+
+        assertThat(time).isEqualTo(TIME_EXPECTED_FOREGROUND);
+    }
+
+    @Test
+    public void testGetProcessTimeMs_typeBackground_timeCorrect() {
+        final long time = BatteryUtils.getProcessTimeMs(BatteryUtils.StatusType.BACKGROUND, mUid,
+                BatteryStats.STATS_SINCE_CHARGED);
+
+        assertThat(time).isEqualTo(TIME_EXPECTED_BACKGROUND);
+    }
+
+    @Test
+    public void testGetProcessTimeMs_typeAll_timeCorrect() {
+        final long time = BatteryUtils.getProcessTimeMs(BatteryUtils.StatusType.ALL, mUid,
+                BatteryStats.STATS_SINCE_CHARGED);
+
+        assertThat(time).isEqualTo(TIME_EXPECTED_ALL);
+    }
+
+    @Test
+    public void testGetProcessTimeMs_uidNull_returnZero() {
+        final long time = BatteryUtils.getProcessTimeMs(BatteryUtils.StatusType.ALL, null,
+                BatteryStats.STATS_SINCE_CHARGED);
+
+        assertThat(time).isEqualTo(0);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceControllerTest.java
new file mode 100644
index 0000000..5fa2c0d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceControllerTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.inputmethod;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.hardware.input.InputManager;
+import android.support.v7.preference.Preference;
+import android.view.InputDevice;
+
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.shadow.ShadowInputDevice;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class PhysicalKeyboardPreferenceControllerTest {
+
+    @Mock
+    private Context mContext;
+    @Mock
+    private InputManager mIm;
+    @Mock
+    private Preference mPreference;
+
+    private PhysicalKeyboardPreferenceController mController;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        when(mContext.getSystemService(Context.INPUT_SERVICE)).thenReturn(mIm);
+        mController = new PhysicalKeyboardPreferenceController(mContext, null /* lifecycle */);
+    }
+
+    @After
+    public void tearDown() {
+        ShadowInputDevice.reset();
+    }
+
+    @Test
+    public void shouldAlwaysBeAvailable() {
+        assertThat(mController.isAvailable()).isTrue();
+    }
+
+    @Test
+    @Config(shadows = {
+            ShadowInputDevice.class,
+    })
+    public void updateState_noKeyboard_setDisconnectedSummary() {
+        ShadowInputDevice.sDeviceIds = new int[]{};
+        mController.updateState(mPreference);
+
+        verify(mPreference).setSummary(R.string.disconnected);
+    }
+
+    @Test
+    @Config(shadows = ShadowInputDevice.class)
+    public void updateState_hasKeyboard_setSummaryToKeyboardName() {
+        final InputDevice device = mock(InputDevice.class);
+        when(device.isVirtual()).thenReturn(false);
+        when(device.isFullKeyboard()).thenReturn(true);
+        when(device.getName()).thenReturn("test_keyboard");
+        ShadowInputDevice.sDeviceIds = new int[]{0};
+        ShadowInputDevice.addDevice(0, device);
+
+        mController.updateState(mPreference);
+
+        verify(mPreference).setSummary(device.getName());
+    }
+
+}
diff --git a/tests/robotests/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceControllerTest.java
new file mode 100644
index 0000000..3256950
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/inputmethod/VirtualKeyboardPreferenceControllerTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.inputmethod;
+
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.support.v7.preference.Preference;
+import android.view.inputmethod.InputMethodInfo;
+import android.view.inputmethod.InputMethodManager;
+
+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.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class VirtualKeyboardPreferenceControllerTest {
+
+    @Mock
+    private Context mContext;
+    @Mock
+    private InputMethodManager mImm;
+    @Mock
+    private DevicePolicyManager mDpm;
+    @Mock
+    private PackageManager mPm;
+    @Mock
+    private Preference mPreference;
+
+    private VirtualKeyboardPreferenceController mController;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE)).thenReturn(mDpm);
+        when(mContext.getSystemService(Context.INPUT_METHOD_SERVICE)).thenReturn(mImm);
+        when(mContext.getPackageManager()).thenReturn(mPm);
+        mController = new VirtualKeyboardPreferenceController(mContext);
+    }
+
+    @Test
+    public void shouldAlwaysBeAvailable() {
+        assertThat(mController.isAvailable()).isTrue();
+    }
+
+    @Test
+    public void updateState_noEnabledIMEs_setEmptySummary() {
+        mController.updateState(mPreference);
+
+        verify(mPreference).setSummary(R.string.summary_empty);
+    }
+
+    @Test
+    public void updateState_singleIme_setImeLabelToSummary() {
+        when(mDpm.getPermittedInputMethodsForCurrentUser()).thenReturn(null);
+        final ComponentName componentName = new ComponentName("pkg", "cls");
+        final List<InputMethodInfo> imis = new ArrayList<>();
+        imis.add(mock(InputMethodInfo.class));
+        when(imis.get(0).getPackageName()).thenReturn(componentName.getPackageName());
+        when(mImm.getEnabledInputMethodList()).thenReturn(imis);
+        when(imis.get(0).loadLabel(mPm)).thenReturn("label");
+
+        mController.updateState(mPreference);
+
+        verify(mPreference).setSummary("label");
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/language/LanguageAndInputSettingsTest.java b/tests/robotests/src/com/android/settings/language/LanguageAndInputSettingsTest.java
index 026264e..643e305 100644
--- a/tests/robotests/src/com/android/settings/language/LanguageAndInputSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/language/LanguageAndInputSettingsTest.java
@@ -16,7 +16,15 @@
 
 package com.android.settings.language;
 
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import android.app.Activity;
+import android.app.admin.DevicePolicyManager;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.pm.PackageManager;
@@ -48,13 +56,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-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 LanguageAndInputSettingsTest {
@@ -64,6 +65,12 @@
     @Mock
     private PackageManager mPackageManager;
     @Mock
+    private InputManager mIm;
+    @Mock
+    private InputMethodManager mImm;
+    @Mock
+    private DevicePolicyManager mDpm;
+    @Mock
     private InputMethodManager mInputMethodManager;
     private TestFragment mFragment;
 
@@ -72,8 +79,11 @@
         MockitoAnnotations.initMocks(this);
         when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mock(UserManager.class));
         when(mContext.getSystemService(Context.INPUT_SERVICE)).thenReturn(mock(InputManager.class));
+        when(mContext.getSystemService(Context.INPUT_SERVICE)).thenReturn(mIm);
         when(mContext.getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE))
                 .thenReturn(mock(TextServicesManager.class));
+        when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE)).thenReturn(mDpm);
+        when(mContext.getSystemService(Context.INPUT_METHOD_SERVICE)).thenReturn(mImm);
         mFragment = new TestFragment(mContext);
     }
 
@@ -96,6 +106,7 @@
     }
 
     @Test
+
     public void testGetPreferenceControllers_shouldAllBeCreated() {
         final List<PreferenceController> controllers = mFragment.getPreferenceControllers(mContext);
 
diff --git a/tests/robotests/src/com/android/settings/network/NetworkResetActionMenuControllerTest.java b/tests/robotests/src/com/android/settings/network/NetworkResetActionMenuControllerTest.java
index ba332b7..7cd76d3 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkResetActionMenuControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkResetActionMenuControllerTest.java
@@ -17,6 +17,14 @@
 package com.android.settings.network;
 
 
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import android.content.Context;
 import android.view.Menu;
 import android.view.MenuItem;
@@ -32,14 +40,6 @@
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
-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 NetworkResetActionMenuControllerTest {
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModePreferenceControllerTest.java
index a31fb5e..685390e 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModePreferenceControllerTest.java
@@ -21,6 +21,7 @@
 import android.content.Context;
 import android.support.v7.preference.Preference;
 
+import com.android.settings.R;
 import com.android.settings.SettingsRobolectricTestRunner;
 import com.android.settings.TestConfig;
 
@@ -30,11 +31,14 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.util.ReflectionHelpers;
 
 import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
@@ -43,23 +47,27 @@
 public class ZenModePreferenceControllerTest {
 
     @Mock
-    private Context mContext;
-    @Mock
     private Preference mPreference;
     @Mock
     private NotificationManager mNotificationManager;
     @Mock
     private Policy mPolicy;
 
+    private Context mContext;
     private ZenModePreferenceController mController;
+    private ZenModeSettings.SummaryBuilder mSummaryBuilder;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        ShadowApplication shadowApplication = ShadowApplication.getInstance();
+        shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
+        mContext = shadowApplication.getApplicationContext();
         mController = new ZenModePreferenceController(mContext);
-        when(mContext.getSystemService(Context.NOTIFICATION_SERVICE))
-            .thenReturn(mNotificationManager);
         when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
+        mSummaryBuilder = spy(new ZenModeSettings.SummaryBuilder(mContext));
+        ReflectionHelpers.setField(mController, "mSummaryBuilder", mSummaryBuilder);
+        doReturn(0).when(mSummaryBuilder).getEnabledAutomaticRulesCount();
     }
 
     @Test
@@ -72,8 +80,12 @@
         when(mPreference.isEnabled()).thenReturn(true);
 
         mController.updateState(mPreference);
+        verify(mPreference).setSummary(mContext.getString(R.string.zen_mode_settings_summary_off));
 
-        verify(mPreference).setSummary(anyString());
+        doReturn(1).when(mSummaryBuilder).getEnabledAutomaticRulesCount();
+        mController.updateState(mPreference);
+        verify(mPreference).setSummary(mContext.getResources().getQuantityString(
+            R.plurals.zen_mode_settings_summary_on, 1, 1));
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/system/FactoryResetPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/system/FactoryResetPreferenceControllerTest.java
index f41870e..1d15b42 100644
--- a/tests/robotests/src/com/android/settings/system/FactoryResetPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/system/FactoryResetPreferenceControllerTest.java
@@ -16,11 +16,10 @@
 package com.android.settings.system;
 
 import static com.google.common.truth.Truth.assertThat;
-
 import static org.mockito.Answers.RETURNS_DEEP_STUBS;
-
 import static org.mockito.Mockito.when;
 
+import android.accounts.AccountManager;
 import android.content.Context;
 import android.os.UserManager;
 
@@ -45,13 +44,17 @@
     private Context mContext;
     @Mock
     private UserManager mUserManager;
+    @Mock
+    private AccountManager mAccountManager;
 
     private FactoryResetPreferenceController mController;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mController = new FactoryResetPreferenceController(mContext, mUserManager);
+        when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+        when(mContext.getSystemService(Context.ACCOUNT_SERVICE)).thenReturn(mAccountManager);
+        mController = new FactoryResetPreferenceController(mContext);
     }
 
     @Test
@@ -68,7 +71,8 @@
         assertThat(mController.isAvailable()).isFalse();
     }
 
-    @Test public void getPreferenceKey() {
+    @Test
+    public void getPreferenceKey() {
         assertThat(mController.getPreferenceKey()).isEqualTo(FACTORY_RESET_KEY);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowInputDevice.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowInputDevice.java
new file mode 100644
index 0000000..ecb1b71
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowInputDevice.java
@@ -0,0 +1,54 @@
+/*
+ * 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.testutils.shadow;
+
+import android.view.InputDevice;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+import org.robolectric.annotation.Resetter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Implements(InputDevice.class)
+public class ShadowInputDevice extends org.robolectric.shadows.ShadowInputDevice {
+
+    public static int[] sDeviceIds;
+
+    private static Map<Integer, InputDevice> sDeviceMap = new HashMap<>();
+
+    @Implementation
+    public static int[] getDeviceIds() {
+        return sDeviceIds;
+    }
+
+    @Implementation
+    public static InputDevice getDevice(int id) {
+        return sDeviceMap.get(id);
+    }
+
+    public static void addDevice(int id, InputDevice device) {
+        sDeviceMap.put(id, device);
+    }
+
+    @Resetter
+    public static void reset() {
+        sDeviceIds = null;
+        sDeviceMap.clear();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowSecureSettings.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowSecureSettings.java
index 5dd54c0..fd4d0d2 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowSecureSettings.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowSecureSettings.java
@@ -53,6 +53,17 @@
     }
 
     @Implementation
+    public static boolean putIntForUser(ContentResolver cr, String name, int value,
+            int userHandle) {
+        return putInt(cr, name, value);
+    }
+
+    @Implementation
+    public static int getIntForUser(ContentResolver cr, String name, int def, int userHandle) {
+        return getInt(cr, name, def);
+    }
+
+    @Implementation
     public static int getInt(ContentResolver resolver, String name, int defaultValue) {
         Integer value = (Integer) mValueMap.get(name);
         return value == null ? defaultValue : value;
diff --git a/tests/robotests/src/com/android/settings/users/UserPreferenceTest.java b/tests/robotests/src/com/android/settings/users/UserPreferenceTest.java
new file mode 100644
index 0000000..031cd77
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/users/UserPreferenceTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.users;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.UserHandle;
+import android.view.View;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settingslib.RestrictedPreferenceHelper;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class UserPreferenceTest {
+
+    @Mock
+    private RestrictedPreferenceHelper mRestrictedPreferenceHelper;
+    private Context mContext;
+    private UserPreference mUserPreference;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = RuntimeEnvironment.application;
+        mUserPreference = new UserPreference(mContext, null /* attrs */, UserHandle.USER_CURRENT,
+                null /* settingsListener */, null /* deleteListener */);
+        ReflectionHelpers.setField(mUserPreference, "mHelper", mRestrictedPreferenceHelper);
+    }
+
+    @Test
+    public void testShouldHideSecondTarget_noListener_shouldHide() {
+        assertThat(mUserPreference.shouldHideSecondTarget()).isTrue();
+    }
+
+    @Test
+    public void testShouldHideSecondTarget_disabledByAdmin_shouldHide() {
+        when(mRestrictedPreferenceHelper.isDisabledByAdmin()).thenReturn(true);
+
+        assertThat(mUserPreference.shouldHideSecondTarget()).isTrue();
+    }
+
+    @Test
+    public void testShouldHideSecondTarget_hasSettingListener_shouldNotHide() {
+        ReflectionHelpers.setField(mUserPreference, "mSettingsClickListener",
+                mock(View.OnClickListener.class));
+
+        assertThat(mUserPreference.shouldHideSecondTarget()).isFalse();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
new file mode 100644
index 0000000..ed95175
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.users;
+
+import android.app.Activity;
+import android.content.pm.UserInfo;
+import android.os.UserManager;
+
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.dashboard.SummaryLoader;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+import org.robolectric.Robolectric;
+
+import static org.mockito.Matchers.anyInt;
+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 UserSettingsTest {
+
+    @Mock private UserManager mUserManager;
+    @Mock private SummaryLoader mSummaryLoader;
+    private Activity mActivity;
+    private SummaryLoader.SummaryProvider mSummaryProvider;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mActivity = spy(Robolectric.buildActivity(Activity.class).get());
+        when((Object) mActivity.getSystemService(UserManager.class)).thenReturn(mUserManager);
+
+        mSummaryProvider = UserSettings.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(
+            mActivity, mSummaryLoader);
+    }
+
+    @Test
+    public void setListening_shouldSetSummaryWithUserName() {
+        final String name = "John";
+        final UserInfo userInfo = new UserInfo();
+        userInfo.name = name;
+        when(mUserManager.getUserInfo(anyInt())).thenReturn(userInfo);
+
+        mSummaryProvider.setListening(true);
+
+        verify(mSummaryLoader).setSummary(mSummaryProvider,
+            mActivity.getString(R.string.users_summary, name));
+    }
+
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/WriteWifiConfigToNfcDialogTest.java b/tests/robotests/src/com/android/settings/wifi/WriteWifiConfigToNfcDialogTest.java
index 6e45cde..000f2fa 100644
--- a/tests/robotests/src/com/android/settings/wifi/WriteWifiConfigToNfcDialogTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WriteWifiConfigToNfcDialogTest.java
@@ -46,10 +46,8 @@
         shadows = ShadowNfcAdapter.class
 )
 public class WriteWifiConfigToNfcDialogTest {
-    private static final int NETWORK_ID = 17;
-
     @Mock Activity mActivity;
-    @Mock WifiManager mWifiManager;
+    @Mock WifiManagerWrapper mWifiManager;
 
     private WriteWifiConfigToNfcDialog mWriteWifiConfigToNfcDialog;
 
@@ -61,7 +59,7 @@
                 .thenReturn(ReflectionHelpers.newInstance(InputMethodManager.class));
 
         mWriteWifiConfigToNfcDialog = new WriteWifiConfigToNfcDialog(RuntimeEnvironment.application,
-                NETWORK_ID, 0 /* security */, mWifiManager);
+                0 /* security */, mWifiManager);
         mWriteWifiConfigToNfcDialog.setOwnerActivity(mActivity);
         mWriteWifiConfigToNfcDialog.onCreate(null /* savedInstanceState */);
     }
@@ -73,7 +71,7 @@
 
     @Test
     public void testOnClick_nfcConfigurationTokenDoesNotContainPasswordHex() {
-        when(mWifiManager.getWpsNfcConfigurationToken(NETWORK_ID)).thenReturn("blah");
+        when(mWifiManager.getCurrentNetworkWpsNfcConfigurationToken()).thenReturn("blah");
 
         mWriteWifiConfigToNfcDialog.onClick(null);
 
@@ -82,7 +80,7 @@
 
     @Test
     public void testOnClick_nfcConfigurationTokenIsNull() {
-        when(mWifiManager.getWpsNfcConfigurationToken(NETWORK_ID)).thenReturn(null);
+        when(mWifiManager.getCurrentNetworkWpsNfcConfigurationToken()).thenReturn(null);
 
         mWriteWifiConfigToNfcDialog.onClick(null);
 
@@ -92,7 +90,7 @@
     @Test
     public void testOnClick_nfcConfigurationTokenContainsPasswordHex() {
         // This is the corresponding passwordHex for an empty string password.
-        when(mWifiManager.getWpsNfcConfigurationToken(NETWORK_ID)).thenReturn("10270000");
+        when(mWifiManager.getCurrentNetworkWpsNfcConfigurationToken()).thenReturn("10270000");
 
         mWriteWifiConfigToNfcDialog.onClick(null);
 
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
index a7e12b3..88a63b3 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
@@ -84,8 +84,6 @@
         MockitoAnnotations.initMocks(this);
 
         mLifecycle = new Lifecycle();
-        mController = new WifiDetailPreferenceController(
-                mockAccessPoint, mContext, mLifecycle, mockWifiManager);
 
         when(mockAccessPoint.getConfig()).thenReturn(mockWifiConfig);
         when(mockAccessPoint.getLevel()).thenReturn(LEVEL);
@@ -93,11 +91,13 @@
         when(mockAccessPoint.getRssi()).thenReturn(RSSI);
         when(mockAccessPoint.getSecurityString(false)).thenReturn(SECURITY);
 
+        mController = new WifiDetailPreferenceController(
+                mockAccessPoint, mContext, mLifecycle, mockWifiManager);
+
         setupMockedPreferenceScreen();
 
-        when (mockWifiInfo.getRssi()).thenReturn(RSSI);
+        when(mockWifiInfo.getRssi()).thenReturn(RSSI);
         when(mockWifiManager.getConnectionInfo()).thenReturn(mockWifiInfo);
-        when(mockWifiManager.getWifiApConfiguration()).thenReturn(mockWifiConfig);
     }
 
     private void setupMockedPreferenceScreen() {
@@ -139,7 +139,6 @@
         mController.onResume();
 
         verify(mockWifiManager).getConnectionInfo();
-        verify(mockWifiManager).getWifiApConfiguration();
     }
 
     @Test
@@ -178,4 +177,29 @@
 
         verify(mockSignalStrengthPref).setDetailText(expectedStrength);
     }
+
+    @Test
+    public void forgetNetwork_ephemeral() {
+        WifiConfiguration wifiConfiguration = new WifiConfiguration();
+        wifiConfiguration.SSID = "ssid";
+        // WifiConfiguration#isEphemeral will not be visible in robolectric until O is supported
+        wifiConfiguration.ephemeral = true;
+        when(mockAccessPoint.getConfig()).thenReturn(wifiConfiguration);
+
+        mController = new WifiDetailPreferenceController(
+                mockAccessPoint, mContext, mLifecycle, mockWifiManager);
+
+        mController.forgetNetwork();
+
+        verify(mockWifiManager).disableEphemeralNetwork(wifiConfiguration.SSID);
+    }
+
+    @Test
+    public void forgetNetwork_saved() {
+        mockWifiConfig.networkId = 5;
+
+        mController.forgetNetwork();
+
+        verify(mockWifiManager).forget(mockWifiConfig.networkId, null);
+    }
 }