Merge "VPN settings: update strings for always-on VPN"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 7b853cc..81b2524 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -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">
@@ -943,8 +943,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 +1186,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 +1965,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 +1997,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 +2734,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 +2763,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/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/values/strings.xml b/res/values/strings.xml
index 9a59a7e..0bd17b6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2936,6 +2936,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>
@@ -2957,6 +2961,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] -->
@@ -3462,11 +3472,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] -->
@@ -4079,14 +4089,30 @@
     <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 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] -->
+    <!-- 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 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] -->
+    <!-- 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] -->
@@ -4114,6 +4140,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] -->
@@ -4270,6 +4303,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>
 
@@ -4780,6 +4816,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>
 
@@ -5599,6 +5647,8 @@
     <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>
@@ -6292,9 +6342,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>
 
@@ -6304,6 +6351,9 @@
         <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</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>
 
@@ -6374,7 +6424,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>
@@ -6383,7 +6433,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>
@@ -6434,32 +6484,38 @@
     <!-- [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>
@@ -6573,12 +6629,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>
 
@@ -6592,7 +6665,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>
@@ -6622,10 +6695,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>
@@ -6637,7 +6719,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>
@@ -6994,11 +7076,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] -->
@@ -7011,12 +7095,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">
@@ -7046,8 +7133,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>
@@ -8299,9 +8397,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] -->
@@ -8310,6 +8408,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>
@@ -8369,6 +8469,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>
 
@@ -8439,4 +8566,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/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/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/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/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/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..5fb6bbe 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;
@@ -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,8 +584,6 @@
 
         updateFeatureSummary(Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED,
                 mCaptioningPreferenceScreen);
-        updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
-                mDisplayMagnificationPreferenceScreen);
         updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
                 mDisplayDaltonizerPreferenceScreen);
 
@@ -665,7 +591,7 @@
 
         updateAutoclickSummary(mAutoclickPreferenceScreen);
 
-        updateAccessibilityShortcut();
+        updateAccessibilityShortcut(mAccessibilityShortcutPreferenceScreen);
     }
 
     private void updateFeatureSummary(String prefKey, Preference pref) {
@@ -714,35 +640,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..4a55ea9
--- /dev/null
+++ b/src/com/android/settings/accessibility/MagnificationPreferenceFragment.java
@@ -0,0 +1,173 @@
+/*
+ * 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.content.ContentResolver;
+import android.content.Context;
+import android.os.Bundle;
+import android.provider.SearchIndexableResource;
+import android.provider.Settings;
+import android.support.v7.preference.Preference;
+import android.view.View;
+
+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";
+
+    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 int getConfigurationWarningStringResourceForSecureSettingsKey(String key,
+            ContentResolver resolver) {
+        if (Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED.equals(key)) {
+            if (Settings.Secure.getInt(resolver,
+                    Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0) == 1) {
+                // TODO(b/34720082): Only report a config warning when nav-bar is not mapped to mag
+                return R.string.accessibility_screen_magnification_navbar_configuration_warning;
+            }
+        }
+
+        return -1;
+    }
+
+    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..19cde08 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,100 @@
         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 int warningRes =
+                MagnificationPreferenceFragment
+                        .getConfigurationWarningStringResourceForSecureSettingsKey(
+                        mPreferenceKey, getContentResolver());
+        if (warningRes != -1) {
+            mConfigWarningPreference.setSummary(warningRes);
+        }
+        mConfigWarningPreference.setVisible(warningRes != -1);
+    }
+
     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/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/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/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/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/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/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index f88d830..aca6a15 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;
@@ -173,6 +175,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/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/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..edaf408 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -577,12 +577,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;
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/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/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/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/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);