Merge "Enable multi-dex for incremental settings builds"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4ff16f9..4e6f303 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -630,6 +630,10 @@
         <activity android:name="Settings$KeyboardLayoutPickerActivity"
                 android:label="@string/keyboard_layout_picker_title"
                 android:clearTaskOnLaunch="true">
+            <intent-filter android:priority="1">
+                <action android:name="android.settings.KEYBOARD_LAYOUT_SETTINGS" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1539,6 +1543,22 @@
             android:windowSoftInputMode="stateHidden|adjustResize"
             android:theme="@style/Theme.ConfirmDeviceCredentials"/>
 
+        <activity
+            android:name=".Settings$FingerprintSuggestionActivity"
+            android:label="@string/security_settings_fingerprint_preference_title"
+            android:icon="@drawable/ic_fingerprint">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.android.settings.suggested.category.SETTINGS_ONLY" />
+            </intent-filter>
+            <meta-data android:name="com.android.settings.dismiss"
+                android:value="10,30" />
+            <meta-data android:name="com.android.settings.require_feature"
+                android:value="android.hardware.fingerprint" />
+            <meta-data android:name="com.android.settings.title"
+                android:resource="@string/suggestion_additional_fingerprints" />
+        </activity>
+
         <activity android:name=".fingerprint.FingerprintSettings" android:exported="false"/>
         <activity android:name=".fingerprint.FingerprintEnrollFindSensor" android:exported="false"/>
         <activity android:name=".fingerprint.FingerprintEnrollEnrolling" android:exported="false"/>
@@ -1591,6 +1611,36 @@
                 android:value="true" />
         </activity>
 
+        <activity android:name=".Settings$ScreenLockSuggestionActivity"
+            android:icon="@drawable/ic_settings_security">
+            <intent-filter android:priority="1">
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.android.settings.suggested.category.LOCK_SCREEN" />
+            </intent-filter>
+            <meta-data android:name="com.android.settings.dismiss"
+                       android:value="0,30" />
+            <meta-data android:name="com.android.settings.title"
+                       android:resource="@string/suggested_lock_settings_title" />
+            <meta-data android:name="com.android.settings.summary"
+                       android:resource="@string/suggested_lock_settings_summary" />
+        </activity>
+
+        <activity android:name=".Settings$FingerprintEnrollSuggestionActivity"
+            android:icon="@drawable/ic_settings_security">
+            <intent-filter android:priority="2">
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.android.settings.suggested.category.LOCK_SCREEN" />
+            </intent-filter>
+            <meta-data android:name="com.android.settings.dismiss"
+                       android:value="0,30" />
+            <meta-data android:name="com.android.settings.require_feature"
+                android:value="android.hardware.fingerprint" />
+            <meta-data android:name="com.android.settings.title"
+                android:resource="@string/suggested_lock_settings_title" />
+            <meta-data android:name="com.android.settings.summary"
+                android:resource="@string/suggested_lock_settings_summary" />
+        </activity>
+
         <activity android:name="ChooseLockGeneric$InternalActivity" android:exported="false"
             android:label="@string/lockpassword_choose_lock_generic_header"
             android:excludeFromRecents="true"
@@ -2638,6 +2688,22 @@
                        android:value="true" />
         </activity>
 
+        <activity android:name="Settings$WifiCallingSuggestionActivity"
+                  android:label="@string/wifi_calling_settings_title"
+                  android:icon="@drawable/ic_settings_wireless"
+                  android:taskAffinity="">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.android.settings.suggested.category.SETTINGS_ONLY" />
+            </intent-filter>
+            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+                       android:value="com.android.settings.WifiCallingSettings" />
+            <meta-data android:name="com.android.settings.dismiss"
+                android:value="10" />
+            <meta-data android:name="com.android.settings.title"
+                android:resource="@string/wifi_calling_suggestion_title" />
+        </activity>
+
         <provider
             android:name=".search.SettingsSearchIndexablesProvider"
             android:authorities="com.android.settings"
@@ -2719,8 +2785,6 @@
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.applications.ManageDefaultApps" />
-            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
-                       android:value="true" />
         </activity>
 
         <!-- Conditional receivers, only enabled during silenced state, default off-->
diff --git a/res/drawable/accessibility_screen_magnification_background.xml b/res/drawable/accessibility_screen_magnification_background.xml
new file mode 100644
index 0000000..e22cfec
--- /dev/null
+++ b/res/drawable/accessibility_screen_magnification_background.xml
@@ -0,0 +1,31 @@
+<!--
+  ~ 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
+  -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="360dp"
+        android:height="184dp"
+        android:viewportWidth="360"
+        android:viewportHeight="184">
+
+    <path
+        android:fillColor="#E9F0F9"
+        android:pathData="M 0 0 H 360 V 184 H 0 V 0 Z" />
+    <path
+        android:fillColor="#444445"
+        android:pathData="M217.6,179h-75.1c-5,0-9-4-9-9V14c0-5,4-9,9-9h75.1c5,0,9,4,9,9V170C226.6,174.9,222.5,179,217.6,179z" />
+    <path
+        android:fillColor="#000000"
+        android:pathData="M 180 9.6 C 181.1045695 9.6 182 10.4954305003 182 11.6 C 182 12.7045694997 181.1045695 13.6 180 13.6 C 178.8954305 13.6 178 12.7045694997 178 11.6 C 178 10.4954305003 178.8954305 9.6 180 9.6 Z" />
+</vector>
diff --git a/res/layout/preference_importance_slider.xml b/res/layout/preference_importance_slider.xml
index 0099384..677a32b 100644
--- a/res/layout/preference_importance_slider.xml
+++ b/res/layout/preference_importance_slider.xml
@@ -23,35 +23,11 @@
         android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
         android:orientation="vertical"
         android:clickable="false"
-        android:focusable="false"
-        android:paddingTop="8dip"
-        android:paddingBottom="8dip">
-
-        <TextView
-                android:id="@android:id/title"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:singleLine="true"
-                android:textAppearance="@android:style/TextAppearance.Material.Subhead"
-                android:textColor="?android:attr/textColorPrimary"
-                android:ellipsize="marquee"
-                android:fadingEdge="horizontal" />
-
-        <TextView
-                android:id="@android:id/summary"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignStart="@android:id/title"
-                android:textAlignment="viewStart"
-                android:textAppearance="@android:style/TextAppearance.Material.Body1"
-                android:textColor="?android:attr/textColorSecondary"
-                android:maxLines="10"
-                android:minLines="2" />
+        android:focusable="false" >
 
         <FrameLayout
                 android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="6dp">
+                android:layout_height="wrap_content" >
 
             <ImageView
                     android:id="@+id/low_importance"
@@ -82,5 +58,4 @@
                     android:tint="@color/importance_icon_tint" />
 
         </FrameLayout>
-
 </LinearLayout>
diff --git a/res/layout/screen_zoom_preview.xml b/res/layout/screen_zoom_preview_1.xml
similarity index 100%
rename from res/layout/screen_zoom_preview.xml
rename to res/layout/screen_zoom_preview_1.xml
diff --git a/res/layout/screen_zoom_preview.xml b/res/layout/screen_zoom_preview_2.xml
similarity index 100%
copy from res/layout/screen_zoom_preview.xml
copy to res/layout/screen_zoom_preview_2.xml
diff --git a/res/layout/screen_zoom_preview.xml b/res/layout/screen_zoom_preview_3.xml
similarity index 100%
copy from res/layout/screen_zoom_preview.xml
copy to res/layout/screen_zoom_preview_3.xml
diff --git a/res/layout/text_description_preference.xml b/res/layout/text_description_preference.xml
index d71f078..6b8594b 100644
--- a/res/layout/text_description_preference.xml
+++ b/res/layout/text_description_preference.xml
@@ -13,11 +13,10 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-
 <TextView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@android:id/summary"
-    android:layout_width="fill_parent"
+    android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:textAppearance="@android:style/TextAppearance.Material.Body1"
     android:padding="16dip" />
diff --git a/res/layout/video_preference.xml b/res/layout/video_preference.xml
new file mode 100644
index 0000000..a6fde76
--- /dev/null
+++ b/res/layout/video_preference.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<RelativeLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/video_background"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <VideoView
+        android:id="@+id/video"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index bce8fb0..c5e554d 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -107,7 +107,7 @@
                             android:prompt="@string/wifi_eap_method"
                             android:entries="@array/wifi_eap_method" />
                 </LinearLayout>
-                
+
                 <LinearLayout android:id="@+id/l_phase2"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
@@ -145,6 +145,18 @@
                             android:prompt="@string/wifi_eap_ca_cert" />
                 </LinearLayout>
 
+                <LinearLayout android:id="@+id/no_ca_cert_warning"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:visibility="gone"
+                        style="@style/wifi_item" >
+                    <TextView
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            style="@style/wifi_item_warning"
+                            android:text="@string/wifi_do_not_validate_eap_server_warning" />
+                </LinearLayout>
+
                 <LinearLayout android:id="@+id/l_user_cert"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
@@ -301,7 +313,7 @@
                     android:layout_height="wrap_content"
                     style="@style/wifi_section"
                     android:visibility="gone">
-                <LinearLayout 
+                <LinearLayout
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         style="@style/wifi_item">
diff --git a/res/raw/accessibility_screen_magnification.mp4 b/res/raw/accessibility_screen_magnification.mp4
new file mode 100644
index 0000000..1e60fc5
--- /dev/null
+++ b/res/raw/accessibility_screen_magnification.mp4
Binary files differ
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 30aa52f..12bdfaa 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -268,4 +268,11 @@
 
     <!-- Accessibility, Font size -->
     <dimen name="font_size_preview_height">240dp</dimen>
+
+    <!-- Accessibility, Screen magnification. These values are meant to be relative values and the actual layout value will be set programmatically. -->
+    <dimen name="screen_magnification_video_background_width">750dp</dimen>
+    <dimen name="screen_magnification_video_background_height">383dp</dimen>
+    <dimen name="screen_magnification_video_width">170dp</dimen>
+    <dimen name="screen_magnification_video_height">311dp</dimen>
+    <dimen name="screen_magnification_video_margin_top">40dp</dimen>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5e58847..f32966d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -959,6 +959,13 @@
     <!-- Unlock Picker Settings --><skip />
 
     <!-- Security Picker --><skip />
+
+    <!-- Title for suggested actions for screen lock -->
+    <string name="suggested_lock_settings_title">Screen lock</string>
+
+    <!-- Summary for suggested actions for screen lock -->
+    <string name="suggested_lock_settings_summary">Protect your device</string>
+
     <!--  Title for security picker to choose the unlock method: None/Pattern/PIN/Password [CHAR LIMIT=22] -->
     <string name="lock_settings_picker_title">Choose screen lock</string>
 
@@ -1629,9 +1636,15 @@
     <!-- Hint for unchanged fields -->
     <string name="wifi_unchanged">(unchanged)</string>
     <!-- Hint for unspecified fields -->
-    <string name="wifi_unspecified">(unspecified)</string>
+    <string name="wifi_unspecified">Please select</string>
     <!-- Hint for multiple certificates being added to the configuration -->
     <string name="wifi_multiple_cert_added">(Multiple certificates added)</string>
+    <!-- Menu option for not providing an EAP user certificate -->
+    <string name="wifi_do_not_provide_eap_user_cert">Do not provide</string>
+    <!-- Menu option for not validating the EAP server -->
+    <string name="wifi_do_not_validate_eap_server">Do not validate</string>
+    <!-- Warning message displayed if user choses not to validate the EAP server -->
+    <string name="wifi_do_not_validate_eap_server_warning">No certificate specified. Your connection will not be private.</string>
     <!-- Substring of status line when Wi-Fi Protected Setup (WPS) is available and
          string is listed first [CHAR LIMIT=20]-->
     <string name="wifi_wps_available_first_item">WPS available</string>
@@ -1892,6 +1905,8 @@
 
     <!-- Wireless networks, item title to go into the WFC settings [CHAR LIMIT=30] -->
     <string name="wifi_calling_settings_title">Wi-Fi calling</string>
+    <!-- Title of suggestion to turn on wifi calling [CHAR LIMIT=30] -->
+    <string name="wifi_calling_suggestion_title">Enable Wi-Fi Calling</string>
     <!-- WFC mode [CHAR LIMIT=30] -->
     <string name="wifi_calling_mode_title">Calling preference</string>
     <!-- WFC mode dialog [CHAR LIMIT=30] -->
@@ -3750,8 +3765,6 @@
     <string name="accessibility_global_gesture_preference_summary_off">Off</string>
     <!--  Description for the preference screen to enable the global geture taht turns on accessibility. [CHAR LIMIT=none] -->
     <string name="accessibility_global_gesture_preference_description">When this feature is turned on, you can quickly enable accessibility features in two steps:\n\nStep 1: Press and hold the power button until you hear a sound or feel a vibration.\n\nStep 2: Touch and hold two fingers until you hear audio confirmation.\n\nIf the device has multiple users, using this shortcut on the lock screen temporarily enables accessibility until the device is unlocked.</string>
-    <!-- Title for the accessibility preference to enable large text. [CHAR LIMIT=35] -->
-    <string name="accessibility_toggle_large_text_preference_title">Large text</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 enable screen magnification. [CHAR LIMIT=35] -->
@@ -5830,6 +5843,9 @@
     <!-- [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: blocked importance level description -->
     <string name="notification_importance_blocked">Blocked: Never show these notifications</string>
 
@@ -5845,6 +5861,9 @@
     <!-- [CHAR LIMIT=100] Notification Importance slider: max importance level description -->
     <string name="notification_importance_max">Urgent: Peek onto the screen and make sound</string>
 
+    <!-- [CHAR LIMIT=60] Notification importance reset button -->
+    <string name="importance_reset">Reset</string>
+
     <!-- Default Apps > Default notification assistant -->
     <string name="default_notification_assistant">Notification assistant</string>
 
@@ -7009,4 +7028,19 @@
     <!-- No default home set summary [CHAR LIMIT=NONE] -->
     <string name="no_default_home">No default Home</string>
 
+    <!-- Title of the preference controlling whether the device encryption password/PIN/Pattern must be entered before being able to start the device. [CHAR LIMIT=60]-->
+    <string name="lockpattern_settings_require_cred_before_startup">Secure start-up</string>
+
+    <!-- Summary of the preference controlling whether the device encryption *pattern* must be entered before being able to start the device. [CHAR LIMIT=NONE]-->
+    <string name="lockpattern_settings_require_pattern_before_startup_summary">Require pattern to start up your device. While off, this device can\'t receive calls, messages, notifications, or alarms.</string>
+
+    <!-- Summary of the preference controlling whether the device encryption *PIN* must be entered before being able to start the device. [CHAR LIMIT=NONE]-->
+    <string name="lockpattern_settings_require_pin_before_startup_summary">Require PIN to start up your device. While off, this device can\'t receive calls, messages, notifications, or alarms.</string>
+
+    <!-- Summary of the preference controlling whether the device encryption *password* must be entered before being able to start the device. [CHAR LIMIT=NONE]-->
+    <string name="lockpattern_settings_require_password_before_startup_summary">Require password to start up your device. While off, this device can\'t receive calls, messages, notifications, or alarms.</string>
+
+    <!-- Title for suggestion adding more fingerprints [CHAR LIMIT=30] -->
+    <string name="suggestion_additional_fingerprints">Additional Fingerprints</string>
+
 </resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 7065265..df5490b 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -204,6 +204,14 @@
         <item name="android:textColor">?android:attr/textColorSecondary</item>
     </style>
 
+    <style name="wifi_item_warning">
+        <item name="android:paddingStart">8dip</item>
+        <item name="android:textSize">12sp</item>
+        <item name="android:textAlignment">viewStart</item>
+        <item name="android:textAppearance">@android:style/TextAppearance.Material.Body1</item>
+        <item name="android:textColor">@color/warning</item>
+    </style>
+
     <style name="wifi_item_content">
         <item name="android:textAlignment">viewStart</item>
         <item name="android:textAppearance">@android:style/TextAppearance.Material.Subhead</item>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 54a5a17..a59fbdc 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -43,17 +43,16 @@
             android:key="font_size_preference_screen"
             android:title="@string/title_font_size"/>
 
+        <com.android.settings.display.ScreenZoomPreference
+            android:key="screen_zoom"
+            android:title="@string/screen_zoom_title"/>
+
         <PreferenceScreen
             android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment"
             android:key="autoclick_preference_screen"
             android:title="@string/accessibility_autoclick_preference_title"/>
 
         <SwitchPreference
-                android:key="toggle_large_text_preference"
-                android:title="@string/accessibility_toggle_large_text_preference_title"
-                android:persistent="false"/>
-
-        <SwitchPreference
                 android:key="toggle_high_text_contrast_preference"
                 android:title="@string/accessibility_toggle_high_text_contrast_preference_title"
                 android:summary="@string/experimental_preference"
diff --git a/res/xml/app_notification_settings.xml b/res/xml/app_notification_settings.xml
index 3141af8..ccf242c 100644
--- a/res/xml/app_notification_settings.xml
+++ b/res/xml/app_notification_settings.xml
@@ -18,10 +18,45 @@
         android:title="@string/app_notifications_title"
         android:key="app_notification_settings">
 
-     <!-- App notification preferences -->
+    <!-- Apps without topics -->
+    <!-- Importance -->
     <Preference
-            android:key="app_settings"
-            android:title="@string/app_notification_preferences"
-            android:persistent="false" />
+            android:key="importance_title"
+            android:title="@string/notification_importance_title"
+            android:order="2" />
+    <com.android.settings.notification.ImportanceSeekBarPreference
+            android:key="importance"
+            android:order="3"/>
+
+    <com.android.settings.applications.LayoutPreference
+            android:key="importance_reset_button"
+            android:layout="@layout/two_buttons_panel"
+            android:order="4" />
+
+    <!-- Sensitive -->
+    <com.android.settingslib.RestrictedSwitchPreference
+            android:key="sensitive"
+            android:title="@string/app_notification_sensitive_title"
+            android:summary="@string/app_notification_sensitive_summary"
+            android:order="5" />
+
+    <!-- Bypass DND -->
+    <com.android.settingslib.RestrictedSwitchPreference
+            android:key="bypass_dnd"
+            android:title="@string/app_notification_override_dnd_title"
+            android:summary="@string/app_notification_override_dnd_summary"
+            android:order="6" />
+
+    <!-- Apps with topics -->
+    <!-- Block -->
+    <com.android.settingslib.RestrictedSwitchPreference
+            android:key="block"
+            android:title="@string/app_notification_block_title"
+            android:summary="@string/app_notification_block_summary"
+            android:order="7" />
+    <PreferenceCategory
+            android:key="categories"
+            android:title="@string/notification_topic_categories"
+            android:order="8" />
 
 </PreferenceScreen>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 1780765..0543ac1 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -91,14 +91,11 @@
                 android:summary="@string/tap_to_wake_summary"
                 android:persistent="false" />
 
-        <DropDownPreference
+        <PreferenceScreen
                 android:key="font_size"
                 android:title="@string/title_font_size"
-                settings:keywords="@string/keywords_display_font_size"
-                android:persistent="false"
-                android:summary="%s"
-                android:entries="@array/entries_font_size"
-                android:entryValues="@array/entryvalues_font_size" />
+                android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
+                settings:keywords="@string/keywords_display_font_size" />
 
         <com.android.settings.display.ScreenZoomPreference
                 android:key="screen_zoom"
diff --git a/res/xml/security_settings_chooser.xml b/res/xml/security_settings_chooser.xml
index af7bfeb..dd8ae55 100644
--- a/res/xml/security_settings_chooser.xml
+++ b/res/xml/security_settings_chooser.xml
@@ -15,23 +15,20 @@
 -->
 
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+                  xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
                   android:title="@string/security_settings_title">
 
     <PreferenceCategory
         android:key="security_category"
         android:title="@string/lock_settings_title">
 
-        <PreferenceScreen
+        <com.android.settings.GearPreference
             android:key="unlock_set_or_change"
             android:title="@string/unlock_set_unlock_launch_picker_title"
             android:summary="@string/unlock_set_unlock_mode_none"
+            settings:keywords="@string/keywords_lockscreen"
             android:persistent="false"/>
 
-        <com.android.settings.SingleLineSummaryPreference
-            android:key="owner_info_settings"
-            android:title="@string/owner_info_settings_title"
-            android:summary="@string/owner_info_settings_summary"/>
-
     </PreferenceCategory>
 
 </PreferenceScreen>
diff --git a/res/xml/security_settings_lockscreen.xml b/res/xml/security_settings_lockscreen.xml
index fde0446..a5aa767 100644
--- a/res/xml/security_settings_lockscreen.xml
+++ b/res/xml/security_settings_lockscreen.xml
@@ -29,12 +29,6 @@
             settings:keywords="@string/keywords_lockscreen"
             android:persistent="false"/>
 
-        <com.android.settings.SingleLineSummaryPreference
-            android:key="owner_info_settings"
-            android:enabled="false"
-            android:title="@string/owner_info_settings_title"
-            android:summary="@string/owner_info_settings_summary"/>
-
     </PreferenceCategory>
 
 </PreferenceScreen>
diff --git a/res/xml/security_settings_password.xml b/res/xml/security_settings_password.xml
index a6fe1a4..d96ca4b 100644
--- a/res/xml/security_settings_password.xml
+++ b/res/xml/security_settings_password.xml
@@ -22,30 +22,13 @@
         android:key="security_category"
         android:title="@string/lock_settings_title">
 
-        <PreferenceScreen
+        <com.android.settings.GearPreference
             android:key="unlock_set_or_change"
             android:title="@string/unlock_set_unlock_launch_picker_title"
             android:summary="@string/unlock_set_unlock_mode_password"
             settings:keywords="@string/keywords_lockscreen"
             android:persistent="false"/>
 
-        <com.android.settings.RestrictedListPreference
-            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"
-            android:persistent="false"/>
-
-        <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"/>
-
     </PreferenceCategory>
 
 </PreferenceScreen>
diff --git a/res/xml/security_settings_password_sub.xml b/res/xml/security_settings_password_sub.xml
new file mode 100644
index 0000000..653dff8
--- /dev/null
+++ b/res/xml/security_settings_password_sub.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2016 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License
+  -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+                  xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+                  android:title="@string/settings_label">
+
+        <com.android.settings.RestrictedListPreference
+                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"/>
+
+        <com.android.settings.SingleLineSummaryPreference
+                android:key="owner_info_settings"
+                android:title="@string/owner_info_settings_title"
+                android:summary="@string/owner_info_settings_summary"/>
+
+        <SwitchPreference
+            android:key="require_cred_before_startup"
+            android:title="@string/lockpattern_settings_require_cred_before_startup"
+            android:summary="@string/lockpattern_settings_require_password_before_startup_summary"/>
+
+
+</PreferenceScreen>
diff --git a/res/xml/security_settings_pattern.xml b/res/xml/security_settings_pattern.xml
index f8c4bd9..d3fd97d 100644
--- a/res/xml/security_settings_pattern.xml
+++ b/res/xml/security_settings_pattern.xml
@@ -22,34 +22,13 @@
         android:key="security_category"
         android:title="@string/lock_settings_title">
 
-        <PreferenceScreen
+        <com.android.settings.GearPreference
             android:key="unlock_set_or_change"
             android:title="@string/unlock_set_unlock_launch_picker_title"
             android:summary="@string/unlock_set_unlock_mode_pattern"
             settings:keywords="@string/keywords_lockscreen"
             android:persistent="false"/>
 
-        <SwitchPreference
-            android:key="visiblepattern"
-            android:title="@string/lockpattern_settings_enable_visible_pattern_title"/>
-
-        <com.android.settings.RestrictedListPreference
-            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"
-            android:persistent="false"/>
-
-        <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"/>
-
     </PreferenceCategory>
 
 </PreferenceScreen>
diff --git a/res/xml/security_settings_pattern_sub.xml b/res/xml/security_settings_pattern_sub.xml
new file mode 100644
index 0000000..cc6722f
--- /dev/null
+++ b/res/xml/security_settings_pattern_sub.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2016 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License
+  -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+                  xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+                  android:title="@string/settings_label">
+
+        <SwitchPreference
+                android:key="visiblepattern"
+                android:title="@string/lockpattern_settings_enable_visible_pattern_title"/>
+
+        <com.android.settings.RestrictedListPreference
+                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"/>
+
+        <com.android.settings.SingleLineSummaryPreference
+                android:key="owner_info_settings"
+                android:title="@string/owner_info_settings_title"
+                android:summary="@string/owner_info_settings_summary"/>
+
+        <SwitchPreference
+            android:key="require_cred_before_startup"
+            android:title="@string/lockpattern_settings_require_cred_before_startup"
+            android:summary="@string/lockpattern_settings_require_pattern_before_startup_summary"/>
+
+
+</PreferenceScreen>
diff --git a/res/xml/security_settings_pin.xml b/res/xml/security_settings_pin.xml
index abab140..ba19c43 100644
--- a/res/xml/security_settings_pin.xml
+++ b/res/xml/security_settings_pin.xml
@@ -22,30 +22,13 @@
         android:key="security_category"
         android:title="@string/lock_settings_title">
 
-        <PreferenceScreen
+        <com.android.settings.GearPreference
             android:key="unlock_set_or_change"
             android:title="@string/unlock_set_unlock_launch_picker_title"
             android:summary="@string/unlock_set_unlock_mode_pin"
             settings:keywords="@string/keywords_lockscreen"
             android:persistent="false"/>
 
-        <com.android.settings.RestrictedListPreference
-            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"
-            android:persistent="false"/>
-
-        <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"/>
-
     </PreferenceCategory>
 
 </PreferenceScreen>
diff --git a/res/xml/security_settings_pin_sub.xml b/res/xml/security_settings_pin_sub.xml
new file mode 100644
index 0000000..8a5f3b0
--- /dev/null
+++ b/res/xml/security_settings_pin_sub.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2016 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License
+  -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+                  xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+                  android:title="@string/settings_label">
+
+        <com.android.settings.RestrictedListPreference
+                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"/>
+
+        <com.android.settings.SingleLineSummaryPreference
+                android:key="owner_info_settings"
+                android:title="@string/owner_info_settings_title"
+                android:summary="@string/owner_info_settings_summary"/>
+
+        <SwitchPreference
+            android:key="require_cred_before_startup"
+            android:title="@string/lockpattern_settings_require_cred_before_startup"
+            android:summary="@string/lockpattern_settings_require_pin_before_startup_summary"/>
+
+
+</PreferenceScreen>
diff --git a/res/xml/security_settings_slide_sub.xml b/res/xml/security_settings_slide_sub.xml
new file mode 100644
index 0000000..1efb370
--- /dev/null
+++ b/res/xml/security_settings_slide_sub.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2016 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License
+  -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+                  xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+                  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"/>
+
+</PreferenceScreen>
diff --git a/res/xml/topic_notification_settings.xml b/res/xml/topic_notification_settings.xml
index d5f28b3..2f15500 100644
--- a/res/xml/topic_notification_settings.xml
+++ b/res/xml/topic_notification_settings.xml
@@ -19,26 +19,31 @@
         android:key="topic_notification_settings">
 
     <!-- Importance -->
+    <Preference
+            android:key="importance_title"
+            android:title="@string/notification_importance_title"
+            android:order="1" />
     <com.android.settings.notification.ImportanceSeekBarPreference
             android:key="importance"
-            android:title="@string/notification_importance_title"
-            android:order="1"
-            android:persistent="false" />
+            android:order="2" />
 
-    <!-- Bypass DND -->
-    <SwitchPreference
-            android:key="bypass_dnd"
-            android:title="@string/app_notification_override_dnd_title"
-            android:summary="@string/app_notification_override_dnd_summary"
-            android:order="2"
-            android:persistent="false" />
+    <com.android.settings.applications.LayoutPreference
+            android:key="importance_reset_button"
+            android:order="3"
+            android:layout="@layout/two_buttons_panel" />
 
     <!-- Sensitive -->
-    <SwitchPreference
+    <com.android.settingslib.RestrictedSwitchPreference
             android:key="sensitive"
             android:title="@string/app_notification_sensitive_title"
             android:summary="@string/app_notification_sensitive_summary"
-            android:order="4"
-            android:persistent="false" />
+            android:order="4" />
+
+    <!-- Bypass DND -->
+    <com.android.settingslib.RestrictedSwitchPreference
+            android:key="bypass_dnd"
+            android:title="@string/app_notification_override_dnd_title"
+            android:summary="@string/app_notification_override_dnd_summary"
+            android:order="5" />
 
 </PreferenceScreen>
diff --git a/res/xml/tts_settings.xml b/res/xml/tts_settings.xml
index 3e5e097..dbdf469 100644
--- a/res/xml/tts_settings.xml
+++ b/res/xml/tts_settings.xml
@@ -24,13 +24,16 @@
 
     <PreferenceCategory android:key="tts_general_section"
          android:title="@string/tts_general_section_title">
-        <ListPreference
+        <com.android.settings.SeekBarPreference
             android:key="tts_default_rate"
             android:title="@string/tts_default_rate_title"
             android:summary="@string/tts_default_rate_summary"
             android:persistent="false"
-            android:entries="@array/tts_rate_entries"
-            android:entryValues="@array/tts_rate_values" />
+            android:defaultValue="50"
+            android:max="400" />
+        <SwitchPreference
+            android:key="tts_default_higher_speech_rate_enabled"
+            android:title="Higher speech rate" />
     </PreferenceCategory>
 
     <Preference android:key="tts_play_example"
diff --git a/res/xml/user_settings.xml b/res/xml/user_settings.xml
index ac2685f..5944b3e 100644
--- a/res/xml/user_settings.xml
+++ b/res/xml/user_settings.xml
@@ -36,8 +36,8 @@
                 android:title="@string/user_add_on_lockscreen_menu"
                 android:summary="@string/user_add_on_lockscreen_menu_summary" />
         <Preference
-                android:key="emergency_info"
-                android:title="@string/emergency_info_title"
-                android:summary="@string/emergency_info_subtitle"/>
+            android:key="emergency_info"
+            android:title="@string/emergency_info_title"
+            android:summary="@string/emergency_info_subtitle"/>
     </PreferenceCategory>
 </PreferenceScreen>
diff --git a/src/com/android/settings/AppHeader.java b/src/com/android/settings/AppHeader.java
index 0351ed5..2b3e6c4 100644
--- a/src/com/android/settings/AppHeader.java
+++ b/src/com/android/settings/AppHeader.java
@@ -39,27 +39,38 @@
 
     public static void createAppHeader(SettingsPreferenceFragment fragment, Drawable icon,
             CharSequence label, String pkgName, int uid) {
-        createAppHeader(fragment, icon, label, pkgName, uid, 0);
+        createAppHeader(fragment, icon, label, pkgName, uid, 0, null);
+    }
+
+    public static void createAppHeader(SettingsPreferenceFragment fragment, Drawable icon,
+            CharSequence label, String pkgName, int uid, Intent externalSettings) {
+        createAppHeader(fragment, icon, label, pkgName, uid, 0, externalSettings);
     }
 
     public static void createAppHeader(Activity activity, Drawable icon, CharSequence label,
             String pkgName, int uid, ViewGroup pinnedHeader) {
         final View bar = activity.getLayoutInflater().inflate(R.layout.app_header,
                 pinnedHeader, false);
-        setupHeaderView(activity, icon, label, pkgName, uid, false, 0, bar);
+        setupHeaderView(activity, icon, label, pkgName, uid, false, 0, bar, null);
         pinnedHeader.addView(bar);
     }
 
     public static void createAppHeader(SettingsPreferenceFragment fragment, Drawable icon,
             CharSequence label, String pkgName, int uid, int tintColorRes) {
+        createAppHeader(fragment, icon, label, pkgName, uid, tintColorRes, null);
+    }
+
+    public static void createAppHeader(SettingsPreferenceFragment fragment, Drawable icon,
+            CharSequence label, String pkgName, int uid, int tintColorRes,
+            Intent externalSettings) {
         View bar = fragment.setPinnedHeaderView(R.layout.app_header);
         setupHeaderView(fragment.getActivity(), icon, label, pkgName, uid, includeAppInfo(fragment),
-                tintColorRes, bar);
+                tintColorRes, bar, externalSettings);
     }
 
     public static View setupHeaderView(final Activity activity, Drawable icon, CharSequence label,
             final String pkgName, final int uid, final boolean includeAppInfo, int tintColorRes,
-            View bar) {
+            View bar, final Intent externalSettings) {
         final ImageView appIcon = (ImageView) bar.findViewById(R.id.app_icon);
         appIcon.setImageDrawable(icon);
         if (tintColorRes != 0) {
@@ -83,6 +94,16 @@
                     }
                 }
             });
+            if (externalSettings != null) {
+                final View appSettings = bar.findViewById(R.id.app_settings);
+                appSettings.setVisibility(View.VISIBLE);
+                appSettings.setOnClickListener(new OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        activity.startActivity(externalSettings);
+                    }
+                });
+            }
         }
         return bar;
     }
diff --git a/src/com/android/settings/ChooseLockGeneric.java b/src/com/android/settings/ChooseLockGeneric.java
index b44ee48..03a3fef 100644
--- a/src/com/android/settings/ChooseLockGeneric.java
+++ b/src/com/android/settings/ChooseLockGeneric.java
@@ -37,6 +37,7 @@
 import android.security.KeyStore;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
 import android.util.EventLog;
 import android.util.Log;
 import android.view.View;
@@ -104,6 +105,7 @@
         private boolean mEncryptionRequestDisabled;
         private boolean mRequirePassword;
         private boolean mForFingerprint = false;
+        private boolean mForChangeCredRequiredForBoot = false;
         private String mUserPassword;
         private LockPatternUtils mLockPatternUtils;
         private FingerprintManager mFingerprintManager;
@@ -157,6 +159,8 @@
                     ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
             mForFingerprint = getActivity().getIntent().getBooleanExtra(
                     ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false);
+            mForChangeCredRequiredForBoot = getArguments() != null && getArguments().getBoolean(
+                    ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT);
 
             if (savedInstanceState != null) {
                 mPasswordConfirmed = savedInstanceState.getBoolean(PASSWORD_CONFIRMED);
@@ -183,6 +187,10 @@
 
             if (mPasswordConfirmed) {
                 updatePreferencesOrFinish();
+                if (mForChangeCredRequiredForBoot) {
+                    maybeEnableEncryption(mLockPatternUtils.getKeyguardStoredPasswordQuality(
+                            mUserId), false);
+                }
             } else if (!mWaitingForConfirmation) {
                 ChooseLockSettingsHelper helper =
                         new ChooseLockSettingsHelper(this.getActivity(), this);
@@ -238,6 +246,9 @@
                 // Get the intent that the encryption interstitial should start for creating
                 // the new unlock method.
                 Intent unlockMethodIntent = getIntentForUnlockMethod(quality, disabled);
+                unlockMethodIntent.putExtra(
+                        ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT,
+                        mForChangeCredRequiredForBoot);
                 final Context context = getActivity();
                 // If accessibility is enabled and the user hasn't seen this dialog before, set the
                 // default state to agree with that which is compatible with accessibility
@@ -250,6 +261,11 @@
                         mForFingerprint);
                 startActivityForResult(intent, ENABLE_ENCRYPTION_REQUEST);
             } else {
+                if (mForChangeCredRequiredForBoot) {
+                    // Welp, couldn't change it. Oh well.
+                    finish();
+                    return;
+                }
                 mRequirePassword = false; // device encryption not enabled or not device owner.
                 updateUnlockMethodAndFinish(quality, disabled);
             }
@@ -263,6 +279,14 @@
                 mPasswordConfirmed = true;
                 mUserPassword = data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
                 updatePreferencesOrFinish();
+                if (mForChangeCredRequiredForBoot) {
+                    if (!TextUtils.isEmpty(mUserPassword)) {
+                        maybeEnableEncryption(
+                                mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId), false);
+                    } else {
+                        finish();
+                    }
+                }
             } else if (requestCode == CHOOSE_LOCK_REQUEST
                     || requestCode == ENABLE_ENCRYPTION_REQUEST) {
                 if (resultCode != RESULT_CANCELED) {
@@ -273,6 +297,9 @@
                 getActivity().setResult(Activity.RESULT_CANCELED);
                 finish();
             }
+            if (requestCode == Activity.RESULT_CANCELED && mForChangeCredRequiredForBoot) {
+                finish();
+            }
         }
 
         @Override
diff --git a/src/com/android/settings/ChooseLockPassword.java b/src/com/android/settings/ChooseLockPassword.java
index 2fd012e..212aa0c 100644
--- a/src/com/android/settings/ChooseLockPassword.java
+++ b/src/com/android/settings/ChooseLockPassword.java
@@ -267,6 +267,19 @@
                     mUserId));
 
             mChooseLockSettingsHelper = new ChooseLockSettingsHelper(getActivity());
+
+            if (intent.getBooleanExtra(
+                    ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT, false)) {
+                SaveAndFinishWorker w = new SaveAndFinishWorker();
+                final boolean required = getActivity().getIntent().getBooleanExtra(
+                        EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
+                String current = intent.getStringExtra(
+                        ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
+                w.setBlocking(true);
+                w.setListener(this);
+                w.start(mChooseLockSettingsHelper.utils(), required,
+                        false, 0, current, current, mRequestedQuality, mUserId);
+            }
         }
 
         @Override
@@ -641,9 +654,11 @@
             setNextEnabled(false);
 
             mSaveAndFinishWorker = new SaveAndFinishWorker();
+            mSaveAndFinishWorker.setListener(this);
+
             getFragmentManager().beginTransaction().add(mSaveAndFinishWorker,
                     FRAGMENT_TAG_SAVE_AND_FINISH).commit();
-            mSaveAndFinishWorker.setListener(this);
+            getFragmentManager().executePendingTransactions();
 
             final boolean required = getActivity().getIntent().getBooleanExtra(
                     EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
diff --git a/src/com/android/settings/ChooseLockPattern.java b/src/com/android/settings/ChooseLockPattern.java
index 960ec1a..8aa9532 100644
--- a/src/com/android/settings/ChooseLockPattern.java
+++ b/src/com/android/settings/ChooseLockPattern.java
@@ -371,6 +371,19 @@
             Intent intent = getActivity().getIntent();
             // Only take this argument into account if it belongs to the current profile.
             mUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras());
+
+            if (intent.getBooleanExtra(
+                    ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT, false)) {
+                SaveAndFinishWorker w = new SaveAndFinishWorker();
+                final boolean required = getActivity().getIntent().getBooleanExtra(
+                        EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
+                String current = intent.getStringExtra(
+                        ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
+                w.setBlocking(true);
+                w.setListener(this);
+                w.start(mChooseLockSettingsHelper.utils(), required,
+                        false, 0, LockPatternUtils.stringToPattern(current), current, mUserId);
+            }
         }
 
         @Override
@@ -642,9 +655,11 @@
             setRightButtonEnabled(false);
 
             mSaveAndFinishWorker = new SaveAndFinishWorker();
+            mSaveAndFinishWorker.setListener(this);
+
             getFragmentManager().beginTransaction().add(mSaveAndFinishWorker,
                     FRAGMENT_TAG_SAVE_AND_FINISH).commit();
-            mSaveAndFinishWorker.setListener(this);
+            getFragmentManager().executePendingTransactions();
 
             final boolean required = getActivity().getIntent().getBooleanExtra(
                     EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
diff --git a/src/com/android/settings/ChooseLockSettingsHelper.java b/src/com/android/settings/ChooseLockSettingsHelper.java
index 1035ef1..dda8da2 100644
--- a/src/com/android/settings/ChooseLockSettingsHelper.java
+++ b/src/com/android/settings/ChooseLockSettingsHelper.java
@@ -33,6 +33,7 @@
     public static final String EXTRA_KEY_CHALLENGE = "challenge";
     public static final String EXTRA_KEY_CHALLENGE_TOKEN = "hw_auth_token";
     public static final String EXTRA_KEY_FOR_FINGERPRINT = "for_fingerprint";
+    public static final String EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT = "for_cred_req_boot";
 
 
     private LockPatternUtils mLockPatternUtils;
diff --git a/src/com/android/settings/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/ConfirmDeviceCredentialActivity.java
index 28c0515..fe22f87 100644
--- a/src/com/android/settings/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/ConfirmDeviceCredentialActivity.java
@@ -19,6 +19,8 @@
 
 import android.app.Activity;
 import android.app.KeyguardManager;
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
 import android.content.Intent;
 import android.os.Binder;
 import android.os.Bundle;
@@ -72,6 +74,10 @@
                 Log.e(TAG, "Invalid intent extra", se);
             }
         }
+        // if the client app did not hand in a title, we check whether there is a policy setting it
+        if (title == null) {
+            title = getTitleFromOrganizationName(userId);
+        }
         ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this);
         if (!helper.launchConfirmationActivity(0 /* request code */, null /* title */, title,
                 details, false /* returnCredentials */, true /* isExternal */, userId)) {
@@ -84,4 +90,10 @@
     private boolean isInternalActivity() {
         return this instanceof ConfirmDeviceCredentialActivity.InternalActivity;
     }
+
+    private String getTitleFromOrganizationName(int userId) {
+        DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(
+                Context.DEVICE_POLICY_SERVICE);
+        return (dpm != null) ? dpm.getOrganizationNameForUser(userId) : null;
+    }
 }
diff --git a/src/com/android/settings/CustomDialogPreference.java b/src/com/android/settings/CustomDialogPreference.java
index edd5416..383163f 100644
--- a/src/com/android/settings/CustomDialogPreference.java
+++ b/src/com/android/settings/CustomDialogPreference.java
@@ -29,7 +29,8 @@
 
     private CustomPreferenceDialogFragment mFragment;
 
-    public CustomDialogPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+    public CustomDialogPreference(Context context, AttributeSet attrs, int defStyleAttr,
+            int defStyleRes) {
         super(context, attrs, defStyleAttr, defStyleRes);
     }
 
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index 31e8d89..5e7407b 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -17,7 +17,6 @@
 package com.android.settings;
 
 import android.app.Activity;
-import android.app.ActivityManagerNative;
 import android.app.UiModeManager;
 import android.app.admin.DevicePolicyManager;
 import android.content.ContentResolver;
@@ -29,7 +28,6 @@
 import android.hardware.SensorManager;
 import android.os.Build;
 import android.os.Bundle;
-import android.os.RemoteException;
 import android.os.SystemProperties;
 import android.provider.SearchIndexableResource;
 import android.provider.Settings;
@@ -44,6 +42,7 @@
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.MetricsProto.MetricsEvent;
 import com.android.internal.view.RotationPolicy;
+import com.android.settings.accessibility.ToggleFontSizePreferenceFragment;
 import com.android.settings.dashboard.SummaryLoader;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
@@ -85,7 +84,7 @@
     private static final String KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE
             = "camera_double_tap_power_gesture";
 
-    private DropDownPreference mFontSizePref;
+    private Preference mFontSizePref;
 
     private final Configuration mCurConfig = new Configuration();
 
@@ -121,8 +120,7 @@
 
         mScreenTimeoutPreference = (RestrictedListPreference) findPreference(KEY_SCREEN_TIMEOUT);
 
-        mFontSizePref = (DropDownPreference) findPreference(KEY_FONT_SIZE);
-        mFontSizePref.setOnPreferenceChangeListener(this);
+        mFontSizePref = findPreference(KEY_FONT_SIZE);
 
         if (isAutomaticBrightnessAvailable(getResources())) {
             mAutoBrightnessPreference = (SwitchPreference) findPreference(KEY_AUTO_BRIGHTNESS);
@@ -339,37 +337,6 @@
         }
     }
 
-    int floatToIndex(float val) {
-        String[] indices = getResources().getStringArray(R.array.entryvalues_font_size);
-        float lastVal = Float.parseFloat(indices[0]);
-        for (int i=1; i<indices.length; i++) {
-            float thisVal = Float.parseFloat(indices[i]);
-            if (val < (lastVal + (thisVal-lastVal)*.5f)) {
-                return i-1;
-            }
-            lastVal = thisVal;
-        }
-        return indices.length-1;
-    }
-
-    public void readFontSizePreference(ListPreference pref) {
-        try {
-            mCurConfig.updateFrom(ActivityManagerNative.getDefault().getConfiguration());
-        } catch (RemoteException e) {
-            Log.w(TAG, "Unable to retrieve font size");
-        }
-
-        // mark the appropriate item in the preferences list
-        int index = floatToIndex(mCurConfig.fontScale);
-        pref.setValueIndex(index);
-
-        // report the current size in the summary text
-        final Resources res = getResources();
-        String[] fontSizeNames = res.getStringArray(R.array.entries_font_size);
-        pref.setSummary(String.format(res.getString(R.string.summary_font_size),
-                fontSizeNames[index]));
-    }
-
     @Override
     public void onResume() {
         super.onResume();
@@ -384,7 +351,7 @@
     }
 
     private void updateState() {
-        readFontSizePreference(mFontSizePref);
+        updateFontSizeSummary();
         updateScreenSaverSummary();
 
         // Update auto brightness if it is available.
@@ -433,13 +400,13 @@
         }
     }
 
-    public void writeFontSizePreference(Object objValue) {
-        try {
-            mCurConfig.fontScale = Float.parseFloat(objValue.toString());
-            ActivityManagerNative.getDefault().updatePersistentConfiguration(mCurConfig);
-        } catch (RemoteException e) {
-            Log.w(TAG, "Unable to save font size");
-        }
+    private void updateFontSizeSummary() {
+        final Resources res = mFontSizePref.getContext().getResources();
+        final String[] entries = res.getStringArray(R.array.entries_font_size);
+        final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
+        final int index = ToggleFontSizePreferenceFragment.fontSizeValueToIndex(
+                res.getConfiguration().fontScale, strEntryValues);
+        mFontSizePref.setSummary(entries[index]);
     }
 
     @Override
@@ -454,9 +421,6 @@
                 Log.e(TAG, "could not persist screen timeout setting", e);
             }
         }
-        if (KEY_FONT_SIZE.equals(key)) {
-            writeFontSizePreference(objValue);
-        }
         if (preference == mAutoBrightnessPreference) {
             boolean auto = (Boolean) objValue;
             Settings.System.putInt(getContentResolver(), SCREEN_BRIGHTNESS_MODE,
diff --git a/src/com/android/settings/GearPreference.java b/src/com/android/settings/GearPreference.java
new file mode 100644
index 0000000..30f9a68
--- /dev/null
+++ b/src/com/android/settings/GearPreference.java
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+import android.content.Context;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.util.AttributeSet;
+import android.view.View;
+
+/**
+ * A preference with a Gear on the side
+ */
+public class GearPreference extends Preference implements View.OnClickListener {
+
+    private OnGearClickListener mOnGearClickListener;
+
+    public GearPreference(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        setWidgetLayoutResource(R.layout.preference_widget_settings);
+    }
+
+    public void setOnGearClickListener(OnGearClickListener l) {
+        mOnGearClickListener = l;
+        notifyChanged();
+    }
+
+    @Override
+    public void onBindViewHolder(PreferenceViewHolder holder) {
+        super.onBindViewHolder(holder);
+        holder.findViewById(R.id.settings_button).setOnClickListener(this);
+    }
+
+    @Override
+    public void onClick(View v) {
+        if (v.getId() == R.id.settings_button) {
+            if (mOnGearClickListener != null) {
+                mOnGearClickListener.onGearClick(this);
+            }
+        }
+    }
+
+    public interface OnGearClickListener {
+        void onGearClick(GearPreference p);
+    }
+}
diff --git a/src/com/android/settings/OwnerInfoSettings.java b/src/com/android/settings/OwnerInfoSettings.java
index 7fffb11..cad0693 100644
--- a/src/com/android/settings/OwnerInfoSettings.java
+++ b/src/com/android/settings/OwnerInfoSettings.java
@@ -75,8 +75,8 @@
             mLockPatternUtils.setOwnerInfoEnabled(!TextUtils.isEmpty(info), mUserId);
             mLockPatternUtils.setOwnerInfo(info, mUserId);
 
-            if (getTargetFragment() instanceof SecuritySettings) {
-                ((SecuritySettings) getTargetFragment()).updateOwnerInfo();
+            if (getTargetFragment() instanceof SecuritySettings.SecuritySubSettings) {
+                ((SecuritySettings.SecuritySubSettings) getTargetFragment()).updateOwnerInfo();
             }
         }
     }
diff --git a/src/com/android/settings/PreviewSeekBarPreferenceFragment.java b/src/com/android/settings/PreviewSeekBarPreferenceFragment.java
index 0b4c1a9..ea8b55a 100644
--- a/src/com/android/settings/PreviewSeekBarPreferenceFragment.java
+++ b/src/com/android/settings/PreviewSeekBarPreferenceFragment.java
@@ -57,6 +57,29 @@
     private View mLarger;
     private View mSmaller;
 
+    private class onPreviewSeekBarChangeListener implements OnSeekBarChangeListener {
+        private boolean mSeekByTouch;
+
+        @Override
+        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+            setPreviewLayer(progress, true);
+            if (!mSeekByTouch) {
+                commit();
+            }
+        }
+
+        @Override
+        public void onStartTrackingTouch(SeekBar seekBar) {
+            mSeekByTouch = true;
+        }
+
+        @Override
+        public void onStopTrackingTouch(SeekBar seekBar) {
+            commit();
+            mSeekByTouch = false;
+        }
+    }
+
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
@@ -77,20 +100,7 @@
         final SeekBar seekBar = (SeekBar) content.findViewById(R.id.seek_bar);
         seekBar.setMax(max);
         seekBar.setProgress(mInitialIndex);
-        seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
-            @Override
-            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-                setPreviewLayer(progress, true);
-            }
-
-            @Override
-            public void onStartTrackingTouch(SeekBar seekBar) {
-            }
-
-            @Override
-            public void onStopTrackingTouch(SeekBar seekBar) {
-            }
-        });
+        seekBar.setOnSeekBarChangeListener(new onPreviewSeekBarChangeListener());
 
         mSmaller = content.findViewById(R.id.smaller);
         mSmaller.setOnClickListener(new OnClickListener() {
diff --git a/src/com/android/settings/RestrictedListPreference.java b/src/com/android/settings/RestrictedListPreference.java
index 35ee30d..77af19e 100644
--- a/src/com/android/settings/RestrictedListPreference.java
+++ b/src/com/android/settings/RestrictedListPreference.java
@@ -146,11 +146,10 @@
             ImageView padlock = (ImageView) root.findViewById(R.id.restricted_lock_icon);
             if (isRestrictedForEntry(entry)) {
                 text.setEnabled(false);
+                text.setChecked(false);
                 padlock.setVisibility(View.VISIBLE);
             } else {
-                if (position == mSelectedIndex) {
-                    text.setChecked(true);
-                }
+                text.setChecked(position == mSelectedIndex);
                 text.setEnabled(true);
                 padlock.setVisibility(View.GONE);
             }
diff --git a/src/com/android/settings/SaveChosenLockWorkerBase.java b/src/com/android/settings/SaveChosenLockWorkerBase.java
index 4d8964a..128bd99 100644
--- a/src/com/android/settings/SaveChosenLockWorkerBase.java
+++ b/src/com/android/settings/SaveChosenLockWorkerBase.java
@@ -20,6 +20,7 @@
 import android.content.Intent;
 import android.os.AsyncTask;
 import android.os.Bundle;
+import android.os.UserManager;
 
 import com.android.internal.widget.LockPatternUtils;
 
@@ -39,6 +40,8 @@
     protected boolean mWasSecureBefore;
     protected int mUserId;
 
+    private boolean mBlocking;
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -67,14 +70,20 @@
         mUtils.setSeparateProfileChallengeEnabled(mUserId, true);
         mWasSecureBefore = mUtils.isSecure(mUserId);
 
-        mUtils.setCredentialRequiredToDecrypt(credentialRequired);
+        if (UserManager.get(getContext()).getUserInfo(mUserId).isPrimary()) {
+            mUtils.setCredentialRequiredToDecrypt(credentialRequired);
+        }
 
         mFinished = false;
         mResultData = null;
     }
 
     protected void start() {
-        new Task().execute();
+        if (mBlocking) {
+            finish(saveAndVerifyInBackground());
+        } else {
+            new Task().execute();
+        }
     }
 
     /**
@@ -91,6 +100,10 @@
         }
     }
 
+    public void setBlocking(boolean blocking) {
+        mBlocking = blocking;
+    }
+
     private class Task extends AsyncTask<Void, Void, Intent> {
         @Override
         protected Intent doInBackground(Void... params){
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 415f4d3..3e873d4 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -28,7 +28,6 @@
 import android.content.pm.ResolveInfo;
 import android.content.pm.UserInfo;
 import android.content.res.Resources;
-import android.hardware.fingerprint.Fingerprint;
 import android.hardware.fingerprint.FingerprintManager;
 import android.os.Bundle;
 import android.os.PersistableBundle;
@@ -55,7 +54,6 @@
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.RestrictedListPreference;
 import com.android.settings.TrustAgentUtils.TrustAgentComponentInfo;
-import com.android.settings.fingerprint.FingerprintEnrollIntroduction;
 import com.android.settings.fingerprint.FingerprintSettings;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Index;
@@ -77,7 +75,8 @@
  * Gesture lock pattern settings.
  */
 public class SecuritySettings extends SettingsPreferenceFragment
-        implements OnPreferenceChangeListener, DialogInterface.OnClickListener, Indexable {
+        implements OnPreferenceChangeListener, DialogInterface.OnClickListener, Indexable,
+        GearPreference.OnGearClickListener {
 
     private static final String TAG = "SecuritySettings";
     private static final String TRUST_AGENT_CLICK_INTENT = "trust_agent_click_intent";
@@ -87,11 +86,8 @@
     // Lock Settings
     private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change";
     private static final String KEY_UNLOCK_SET_OR_CHANGE_PROFILE = "profile_challenge";
-    private static final String KEY_VISIBLE_PATTERN = "visiblepattern";
     private static final String KEY_SECURITY_CATEGORY = "security_category";
     private static final String KEY_DEVICE_ADMIN_CATEGORY = "device_admin_category";
-    private static final String KEY_LOCK_AFTER_TIMEOUT = "lock_after_timeout";
-    private static final String KEY_OWNER_INFO_SETTINGS = "owner_info_settings";
     private static final String KEY_ADVANCED_SECURITY = "advanced_security";
     private static final String KEY_MANAGE_TRUST_AGENTS = "manage_trust_agents";
 
@@ -105,16 +101,14 @@
     private static final String KEY_RESET_CREDENTIALS = "credentials_reset";
     private static final String KEY_CREDENTIALS_INSTALL = "credentials_install";
     private static final String KEY_TOGGLE_INSTALL_APPLICATIONS = "toggle_install_applications";
-    private static final String KEY_POWER_INSTANTLY_LOCKS = "power_button_instantly_locks";
     private static final String KEY_CREDENTIALS_MANAGER = "credentials_management";
     private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";
     private static final String KEY_TRUST_AGENT = "trust_agent";
     private static final String KEY_SCREEN_PINNING = "screen_pinning_settings";
 
     // These switch preferences need special handling since they're not all stored in Settings.
-    private static final String SWITCH_PREFERENCE_KEYS[] = { KEY_LOCK_AFTER_TIMEOUT,
-            KEY_VISIBLE_PATTERN, KEY_POWER_INSTANTLY_LOCKS, KEY_SHOW_PASSWORD,
-            KEY_TOGGLE_INSTALL_APPLICATIONS };
+    private static final String SWITCH_PREFERENCE_KEYS[] = {
+            KEY_SHOW_PASSWORD, KEY_TOGGLE_INSTALL_APPLICATIONS };
 
     // Only allow one trust agent on the platform.
     private static final boolean ONLY_ONE_TRUST_AGENT = true;
@@ -127,9 +121,6 @@
 
     private ChooseLockSettingsHelper mChooseLockSettingsHelper;
     private LockPatternUtils mLockPatternUtils;
-    private RestrictedListPreference mLockAfter;
-
-    private SwitchPreference mVisiblePattern;
 
     private SwitchPreference mShowPassword;
 
@@ -138,12 +129,10 @@
 
     private RestrictedSwitchPreference mToggleAppInstallation;
     private DialogInterface mWarnInstallApps;
-    private SwitchPreference mPowerButtonInstantlyLocks;
 
     private boolean mIsAdmin;
 
     private Intent mTrustAgentClickIntent;
-    private Preference mOwnerInfoPref;
 
     private int mProfileChallengeUserId;
 
@@ -232,25 +221,14 @@
             }
         }
 
+        Preference unlockSetOrChange = findPreference(KEY_UNLOCK_SET_OR_CHANGE);
+        if (unlockSetOrChange instanceof GearPreference) {
+            ((GearPreference) unlockSetOrChange).setOnGearClickListener(this);
+        }
+
         // Add options for device encryption
         mIsAdmin = mUm.isAdminUser();
 
-        mOwnerInfoPref = findPreference(KEY_OWNER_INFO_SETTINGS);
-        if (mOwnerInfoPref != null) {
-            mOwnerInfoPref.setEnabled(!mLockPatternUtils.isLockScreenDisabled(MY_USER_ID)
-                    && !mLockPatternUtils.isDeviceOwnerInfoEnabled());
-
-            if (mOwnerInfoPref.isEnabled()) {
-                mOwnerInfoPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
-                    @Override
-                    public boolean onPreferenceClick(Preference preference) {
-                        OwnerInfoSettings.show(SecuritySettings.this);
-                        return true;
-                    }
-                });
-            }
-        }
-
         if (mIsAdmin) {
             if (LockPatternUtils.isDeviceEncryptionEnabled()) {
                 // The device is currently encrypted.
@@ -269,28 +247,6 @@
             addTrustAgentSettings(securityCategory);
         }
 
-        // lock after preference
-        mLockAfter = (RestrictedListPreference) root.findPreference(KEY_LOCK_AFTER_TIMEOUT);
-        if (mLockAfter != null) {
-            setupLockAfterPreference();
-            updateLockAfterPreferenceSummary();
-        }
-
-        // visible pattern
-        mVisiblePattern = (SwitchPreference) root.findPreference(KEY_VISIBLE_PATTERN);
-
-        // lock instantly on power key press
-        mPowerButtonInstantlyLocks = (SwitchPreference) root.findPreference(
-                KEY_POWER_INSTANTLY_LOCKS);
-        Preference trustAgentPreference = root.findPreference(KEY_TRUST_AGENT);
-        if (mPowerButtonInstantlyLocks != null &&
-                trustAgentPreference != null &&
-                trustAgentPreference.getTitle().length() > 0) {
-            mPowerButtonInstantlyLocks.setSummary(getString(
-                    R.string.lockpattern_settings_power_button_instantly_locks_summary,
-                    trustAgentPreference.getTitle()));
-        }
-
         // Append the rest of the settings
         addPreferencesFromResource(R.xml.security_settings_misc);
 
@@ -522,6 +478,13 @@
     }
 
     @Override
+    public void onGearClick(GearPreference p) {
+        if (KEY_UNLOCK_SET_OR_CHANGE.equals(p.getKey())) {
+            startFragment(this, SecuritySubSettings.class.getName(), 0, 0, null);
+        }
+    }
+
+    @Override
     public void onDestroy() {
         super.onDestroy();
         if (mWarnInstallApps != null) {
@@ -529,105 +492,6 @@
         }
     }
 
-    private void setupLockAfterPreference() {
-        // Compatible with pre-Froyo
-        long currentTimeout = Settings.Secure.getLong(getContentResolver(),
-                Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, 5000);
-        mLockAfter.setValue(String.valueOf(currentTimeout));
-        mLockAfter.setOnPreferenceChangeListener(this);
-        final EnforcedAdmin admin = RestrictedLockUtils.checkIfMaximumTimeToLockIsSet(
-                getActivity());
-        if (admin != null) {
-            final long adminTimeout = (mDPM != null ? mDPM.getMaximumTimeToLock(null) : 0);
-            final long displayTimeout = Math.max(0,
-                    Settings.System.getInt(getContentResolver(), SCREEN_OFF_TIMEOUT, 0));
-            if (adminTimeout > 0) {
-                // This setting is a slave to display timeout when a device policy is enforced.
-                // As such, maxLockTimeout = adminTimeout - displayTimeout.
-                // If there isn't enough time, shows "immediately" setting.
-                disableUnusableTimeouts(Math.max(0, adminTimeout - displayTimeout), admin);
-            }
-        }
-    }
-
-    private void updateLockAfterPreferenceSummary() {
-        final String summary;
-        if (mLockAfter.isDisabledByAdmin()) {
-            summary = getString(R.string.disabled_by_policy_title);
-        } else {
-            // Update summary message with current value
-            long currentTimeout = Settings.Secure.getLong(getContentResolver(),
-                    Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, 5000);
-            final CharSequence[] entries = mLockAfter.getEntries();
-            final CharSequence[] values = mLockAfter.getEntryValues();
-            int best = 0;
-            for (int i = 0; i < values.length; i++) {
-                if (mLockAfter.isRestrictedForEntry(entries[i])) {
-                    break;
-                }
-                long timeout = Long.valueOf(values[i].toString());
-                if (currentTimeout >= timeout) {
-                    best = i;
-                }
-            }
-
-            Preference preference = getPreferenceScreen().findPreference(KEY_TRUST_AGENT);
-            if (preference != null && preference.getTitle().length() > 0) {
-                if (Long.valueOf(values[best].toString()) == 0) {
-                    summary = getString(R.string.lock_immediately_summary_with_exception,
-                            preference.getTitle());
-                } else {
-                    summary = getString(R.string.lock_after_timeout_summary_with_exception,
-                            entries[best], preference.getTitle());
-                }
-            } else {
-                summary = getString(R.string.lock_after_timeout_summary, entries[best]);
-            }
-        }
-        mLockAfter.setSummary(summary);
-    }
-
-    private void disableUnusableTimeouts(long maxTimeout, EnforcedAdmin admin) {
-        final CharSequence[] entries = mLockAfter.getEntries();
-        final CharSequence[] values = mLockAfter.getEntryValues();
-        long maxTimeoutSelectable = 0;
-        int maxTimeoutEntryIndex = -1;
-        for (int i = 0; i < values.length; i++) {
-            long timeout = Long.parseLong(values[i].toString());
-            if (timeout > maxTimeout) {
-                break;
-            }
-            maxTimeoutSelectable = timeout;
-            maxTimeoutEntryIndex = i;
-        }
-        // If there are no possible options for the user, then set this preference as
-        // disabled by admin, otherwise remove the padlock in case it was set earlier.
-        if (maxTimeoutSelectable == 0) {
-            mLockAfter.setDisabledByAdmin(admin);
-            return;
-        } else {
-            mLockAfter.setDisabledByAdmin(null);
-        }
-
-        mLockAfter.clearRestrictedItems();
-        // Set all the entries after the maximum selectable timeout as disabled by admin.
-        for (int i = maxTimeoutEntryIndex + 1; i < values.length; i++) {
-            mLockAfter.addRestrictedItem(
-                    new RestrictedItem(entries[i], values[i], admin));
-        }
-
-        final int userPreference = Integer.valueOf(mLockAfter.getValue());
-        if (userPreference <= maxTimeout) {
-            mLockAfter.setValue(String.valueOf(userPreference));
-        } else if (maxTimeoutSelectable == maxTimeout) {
-            mLockAfter.setValue(String.valueOf(maxTimeout));
-        } else {
-            // There will be no highlighted selection since nothing in the list matches
-            // maxTimeout. The user can still select anything less than maxTimeout.
-            // TODO: maybe append maxTimeout to the list and mark selected.
-        }
-    }
-
     @Override
     public void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
@@ -645,15 +509,6 @@
         createPreferenceHierarchy();
 
         final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
-        if (mVisiblePattern != null) {
-            mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled(
-                    MY_USER_ID));
-        }
-        if (mPowerButtonInstantlyLocks != null) {
-            mPowerButtonInstantlyLocks.setChecked(lockPatternUtils.getPowerButtonInstantlyLocks(
-                    MY_USER_ID));
-        }
-
         if (mShowPassword != null) {
             mShowPassword.setChecked(Settings.System.getInt(getContentResolver(),
                     Settings.System.TEXT_SHOW_PASSWORD, 1) != 0);
@@ -662,20 +517,6 @@
         if (mResetCredentials != null) {
             mResetCredentials.setEnabled(!mKeyStore.isEmpty());
         }
-
-        updateOwnerInfo();
-    }
-
-    public void updateOwnerInfo() {
-        if (mOwnerInfoPref != null) {
-            if (mLockPatternUtils.isDeviceOwnerInfoEnabled()) {
-                mOwnerInfoPref.setSummary(R.string.disabled_by_administrator_summary);
-            } else {
-                mOwnerInfoPref.setSummary(mLockPatternUtils.isOwnerInfoEnabled(MY_USER_ID)
-                        ? mLockPatternUtils.getOwnerInfo(MY_USER_ID)
-                        : getString(R.string.owner_info_settings_summary));
-            }
-        }
     }
 
     @Override
@@ -728,20 +569,7 @@
         boolean result = true;
         final String key = preference.getKey();
         final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
-        if (KEY_LOCK_AFTER_TIMEOUT.equals(key)) {
-            int timeout = Integer.parseInt((String) value);
-            try {
-                Settings.Secure.putInt(getContentResolver(),
-                        Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, timeout);
-            } catch (NumberFormatException e) {
-                Log.e("SecuritySettings", "could not persist lockAfter timeout setting", e);
-            }
-            updateLockAfterPreferenceSummary();
-        } else if (KEY_VISIBLE_PATTERN.equals(key)) {
-            lockPatternUtils.setVisiblePatternEnabled((Boolean) value, MY_USER_ID);
-        } else if (KEY_POWER_INSTANTLY_LOCKS.equals(key)) {
-            mLockPatternUtils.setPowerButtonInstantlyLocks((Boolean) value, MY_USER_ID);
-        } else if (KEY_SHOW_PASSWORD.equals(key)) {
+        if (KEY_SHOW_PASSWORD.equals(key)) {
             Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD,
                     ((Boolean) value) ? 1 : 0);
             lockPatternUtils.setVisiblePasswordEnabled((Boolean) value, MY_USER_ID);
@@ -823,6 +651,12 @@
                 result.add(sir);
             }
 
+            sir = new SearchIndexableResource(context);
+            sir.xmlResId = SecuritySubSettings.getResIdForLockUnlockSubScreen(context,
+                    lockPatternUtils);
+            sir.className = SecuritySubSettings.class.getName();
+            result.add(sir);
+
             // Append the rest of the settings
             sir = new SearchIndexableResource(context);
             sir.xmlResId = R.xml.security_settings_misc;
@@ -924,8 +758,304 @@
                 keys.add(KEY_MANAGE_TRUST_AGENTS);
             }
 
+            if (!SecuritySubSettings.canChangeRequireCredentialBeforeStartup(context)) {
+                keys.add(SecuritySubSettings.KEY_REQUIRE_CRED_BEFORE_STARTUP);
+            }
+
             return keys;
         }
     }
 
+    public static class SecuritySubSettings extends SettingsPreferenceFragment
+            implements OnPreferenceChangeListener {
+
+        private static final String KEY_VISIBLE_PATTERN = "visiblepattern";
+        private static final String KEY_LOCK_AFTER_TIMEOUT = "lock_after_timeout";
+        private static final String KEY_OWNER_INFO_SETTINGS = "owner_info_settings";
+        private static final String KEY_POWER_INSTANTLY_LOCKS = "power_button_instantly_locks";
+        private static final String KEY_REQUIRE_CRED_BEFORE_STARTUP = "require_cred_before_startup";
+
+        public static final int REQUEST_CHANGE_REQUIRE_CRED_FOR_START = 2;
+
+        // These switch preferences need special handling since they're not all stored in Settings.
+        private static final String SWITCH_PREFERENCE_KEYS[] = { KEY_LOCK_AFTER_TIMEOUT,
+                KEY_VISIBLE_PATTERN, KEY_POWER_INSTANTLY_LOCKS, KEY_REQUIRE_CRED_BEFORE_STARTUP };
+
+        private RestrictedListPreference mLockAfter;
+        private SwitchPreference mVisiblePattern;
+        private SwitchPreference mPowerButtonInstantlyLocks;
+        private Preference mOwnerInfoPref;
+
+        private LockPatternUtils mLockPatternUtils;
+        private DevicePolicyManager mDPM;
+
+        @Override
+        protected int getMetricsCategory() {
+            return MetricsEvent.SECURITY;
+        }
+
+        @Override
+        public void onCreate(Bundle icicle) {
+            super.onCreate(icicle);
+            mLockPatternUtils = new LockPatternUtils(getContext());
+            mDPM = getContext().getSystemService(DevicePolicyManager.class);
+        }
+
+        @Override
+        public void onResume() {
+            super.onResume();
+
+            createPreferenceHierarchy();
+
+            final LockPatternUtils lockPatternUtils = mLockPatternUtils;
+            if (mVisiblePattern != null) {
+                mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled(
+                        MY_USER_ID));
+            }
+            if (mPowerButtonInstantlyLocks != null) {
+                mPowerButtonInstantlyLocks.setChecked(lockPatternUtils.getPowerButtonInstantlyLocks(
+                        MY_USER_ID));
+            }
+
+            updateOwnerInfo();
+        }
+
+        @Override
+        public void onActivityResult(int requestCode, int resultCode, Intent data) {
+            super.onActivityResult(requestCode, resultCode, data);
+
+            createPreferenceHierarchy();
+        }
+
+        private void createPreferenceHierarchy() {
+            PreferenceScreen root = getPreferenceScreen();
+            if (root != null) {
+                root.removeAll();
+            }
+            root = null;
+
+            final int resid = getResIdForLockUnlockSubScreen(getActivity(),
+                    new LockPatternUtils(getContext()));
+            addPreferencesFromResource(resid);
+
+            // lock after preference
+            mLockAfter = (RestrictedListPreference) findPreference(KEY_LOCK_AFTER_TIMEOUT);
+            if (mLockAfter != null) {
+                setupLockAfterPreference();
+                updateLockAfterPreferenceSummary();
+            }
+
+            // visible pattern
+            mVisiblePattern = (SwitchPreference) findPreference(KEY_VISIBLE_PATTERN);
+
+            // lock instantly on power key press
+            mPowerButtonInstantlyLocks = (SwitchPreference) findPreference(
+                    KEY_POWER_INSTANTLY_LOCKS);
+            Preference trustAgentPreference = findPreference(KEY_TRUST_AGENT);
+            if (mPowerButtonInstantlyLocks != null &&
+                    trustAgentPreference != null &&
+                    trustAgentPreference.getTitle().length() > 0) {
+                mPowerButtonInstantlyLocks.setSummary(getString(
+                        R.string.lockpattern_settings_power_button_instantly_locks_summary,
+                        trustAgentPreference.getTitle()));
+            }
+
+            mOwnerInfoPref = findPreference(KEY_OWNER_INFO_SETTINGS);
+            if (mOwnerInfoPref != null) {
+                mOwnerInfoPref.setEnabled(!mLockPatternUtils.isLockScreenDisabled(MY_USER_ID)
+                        && !mLockPatternUtils.isDeviceOwnerInfoEnabled());
+
+                if (mOwnerInfoPref.isEnabled()) {
+                    mOwnerInfoPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+                        @Override
+                        public boolean onPreferenceClick(Preference preference) {
+                            OwnerInfoSettings.show(SecuritySubSettings.this);
+                            return true;
+                        }
+                    });
+                }
+            }
+
+            Preference requireCredForStartup = findPreference(KEY_REQUIRE_CRED_BEFORE_STARTUP);
+            if (requireCredForStartup instanceof SwitchPreference) {
+                ((SwitchPreference) requireCredForStartup).setChecked(
+                        mLockPatternUtils.isCredentialRequiredToDecrypt(false));
+                if (!canChangeRequireCredentialBeforeStartup(getContext())) {
+                    removePreference(KEY_REQUIRE_CRED_BEFORE_STARTUP);
+                }
+            }
+
+            for (int i = 0; i < SWITCH_PREFERENCE_KEYS.length; i++) {
+                final Preference pref = findPreference(SWITCH_PREFERENCE_KEYS[i]);
+                if (pref != null) pref.setOnPreferenceChangeListener(this);
+            }
+        }
+
+        static boolean canChangeRequireCredentialBeforeStartup(Context context) {
+            DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
+            return UserManager.get(context).isAdminUser()
+                    && LockPatternUtils.isDeviceEncryptionEnabled()
+                    && !dpm.getDoNotAskCredentialsOnBoot();
+        }
+
+        private void setupLockAfterPreference() {
+            // Compatible with pre-Froyo
+            long currentTimeout = Settings.Secure.getLong(getContentResolver(),
+                    Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, 5000);
+            mLockAfter.setValue(String.valueOf(currentTimeout));
+            mLockAfter.setOnPreferenceChangeListener(this);
+            final EnforcedAdmin admin = RestrictedLockUtils.checkIfMaximumTimeToLockIsSet(
+                    getActivity());
+            if (admin != null) {
+                final long adminTimeout = (mDPM != null ? mDPM.getMaximumTimeToLock(null) : 0);
+                final long displayTimeout = Math.max(0,
+                        Settings.System.getInt(getContentResolver(), SCREEN_OFF_TIMEOUT, 0));
+                if (adminTimeout > 0) {
+                    // This setting is a slave to display timeout when a device policy is enforced.
+                    // As such, maxLockTimeout = adminTimeout - displayTimeout.
+                    // If there isn't enough time, shows "immediately" setting.
+                    disableUnusableTimeouts(Math.max(0, adminTimeout - displayTimeout), admin);
+                }
+            }
+        }
+
+        private void updateLockAfterPreferenceSummary() {
+            final String summary;
+            if (mLockAfter.isDisabledByAdmin()) {
+                summary = getString(R.string.disabled_by_policy_title);
+            } else {
+                // Update summary message with current value
+                long currentTimeout = Settings.Secure.getLong(getContentResolver(),
+                        Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, 5000);
+                final CharSequence[] entries = mLockAfter.getEntries();
+                final CharSequence[] values = mLockAfter.getEntryValues();
+                int best = 0;
+                for (int i = 0; i < values.length; i++) {
+                    if (mLockAfter.isRestrictedForEntry(entries[i])) {
+                        break;
+                    }
+                    long timeout = Long.valueOf(values[i].toString());
+                    if (currentTimeout >= timeout) {
+                        best = i;
+                    }
+                }
+
+                Preference preference = findPreference(KEY_TRUST_AGENT);
+                if (preference != null && preference.getTitle().length() > 0) {
+                    if (Long.valueOf(values[best].toString()) == 0) {
+                        summary = getString(R.string.lock_immediately_summary_with_exception,
+                                preference.getTitle());
+                    } else {
+                        summary = getString(R.string.lock_after_timeout_summary_with_exception,
+                                entries[best], preference.getTitle());
+                    }
+                } else {
+                    summary = getString(R.string.lock_after_timeout_summary, entries[best]);
+                }
+            }
+            mLockAfter.setSummary(summary);
+        }
+
+        private void disableUnusableTimeouts(long maxTimeout, EnforcedAdmin admin) {
+            final CharSequence[] entries = mLockAfter.getEntries();
+            final CharSequence[] values = mLockAfter.getEntryValues();
+            long maxTimeoutSelectable = 0;
+            int maxTimeoutEntryIndex = -1;
+            for (int i = 0; i < values.length; i++) {
+                long timeout = Long.parseLong(values[i].toString());
+                if (timeout > maxTimeout) {
+                    break;
+                }
+                maxTimeoutSelectable = timeout;
+                maxTimeoutEntryIndex = i;
+            }
+            // If there are no possible options for the user, then set this preference as
+            // disabled by admin, otherwise remove the padlock in case it was set earlier.
+            if (maxTimeoutSelectable == 0) {
+                mLockAfter.setDisabledByAdmin(admin);
+                return;
+            } else {
+                mLockAfter.setDisabledByAdmin(null);
+            }
+
+            mLockAfter.clearRestrictedItems();
+            // Set all the entries after the maximum selectable timeout as disabled by admin.
+            for (int i = maxTimeoutEntryIndex + 1; i < values.length; i++) {
+                mLockAfter.addRestrictedItem(
+                        new RestrictedItem(entries[i], values[i], admin));
+            }
+
+            final int userPreference = Integer.valueOf(mLockAfter.getValue());
+            if (userPreference <= maxTimeout) {
+                mLockAfter.setValue(String.valueOf(userPreference));
+            } else if (maxTimeoutSelectable == maxTimeout) {
+                mLockAfter.setValue(String.valueOf(maxTimeout));
+            } else {
+                // There will be no highlighted selection since nothing in the list matches
+                // maxTimeout. The user can still select anything less than maxTimeout.
+                // TODO: maybe append maxTimeout to the list and mark selected.
+            }
+        }
+
+        public void updateOwnerInfo() {
+            if (mOwnerInfoPref != null) {
+                if (mLockPatternUtils.isDeviceOwnerInfoEnabled()) {
+                    mOwnerInfoPref.setSummary(R.string.disabled_by_administrator_summary);
+                } else {
+                    mOwnerInfoPref.setSummary(mLockPatternUtils.isOwnerInfoEnabled(MY_USER_ID)
+                            ? mLockPatternUtils.getOwnerInfo(MY_USER_ID)
+                            : getString(R.string.owner_info_settings_summary));
+                }
+            }
+        }
+
+        private static int getResIdForLockUnlockSubScreen(Context context,
+                LockPatternUtils lockPatternUtils) {
+            if (lockPatternUtils.isSecure(MY_USER_ID)) {
+                switch (lockPatternUtils.getKeyguardStoredPasswordQuality(MY_USER_ID)) {
+                    case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
+                        return R.xml.security_settings_pattern_sub;
+                    case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
+                    case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
+                        return R.xml.security_settings_pin_sub;
+                    case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC:
+                    case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
+                    case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
+                        return R.xml.security_settings_password_sub;
+                }
+            } else if (!lockPatternUtils.isLockScreenDisabled(MY_USER_ID)) {
+                return R.xml.security_settings_slide_sub;
+            }
+            return 0;
+        }
+
+        @Override
+        public boolean onPreferenceChange(Preference preference, Object value) {
+            String key = preference.getKey();
+            if (KEY_POWER_INSTANTLY_LOCKS.equals(key)) {
+                mLockPatternUtils.setPowerButtonInstantlyLocks((Boolean) value, MY_USER_ID);
+            } else if (KEY_LOCK_AFTER_TIMEOUT.equals(key)) {
+                int timeout = Integer.parseInt((String) value);
+                try {
+                    Settings.Secure.putInt(getContentResolver(),
+                            Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, timeout);
+                } catch (NumberFormatException e) {
+                    Log.e("SecuritySettings", "could not persist lockAfter timeout setting", e);
+                }
+                updateLockAfterPreferenceSummary();
+            } else if (KEY_VISIBLE_PATTERN.equals(key)) {
+                mLockPatternUtils.setVisiblePatternEnabled((Boolean) value, MY_USER_ID);
+            } else if (KEY_REQUIRE_CRED_BEFORE_STARTUP.equals(key)) {
+                Bundle extras = new Bundle();
+                extras.putBoolean(
+                        ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT, true);
+                startFragment(this,
+                        "com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment",
+                        R.string.lock_settings_picker_title, REQUEST_CHANGE_REQUIRE_CRED_FOR_START,
+                        extras);
+                return false;
+            }
+            return true;
+        }
+    }
 }
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 4141274..494fd3b 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -17,6 +17,8 @@
 package com.android.settings;
 
 import com.android.settings.applications.AppOpsSummary;
+import com.android.settings.fingerprint.FingerprintEnrollIntroduction;
+import com.android.settings.fingerprint.FingerprintSettings;
 
 /**
  * Top-level Settings activity
@@ -103,7 +105,6 @@
     public static class ZenModeSettingsActivity extends SettingsActivity { /* empty */ }
     public static class ZenModePrioritySettingsActivity extends SettingsActivity { /* empty */ }
     public static class ZenModeAutomationSettingsActivity extends SettingsActivity { /* empty */ }
-    public static class ZenModeAutomationSuggestionActivity extends SettingsActivity { /* empty */ }
     public static class ZenModeScheduleRuleSettingsActivity extends SettingsActivity { /* empty */ }
     public static class ZenModeEventRuleSettingsActivity extends SettingsActivity { /* empty */ }
     public static class ZenModeExternalRuleSettingsActivity extends SettingsActivity { /* empty */ }
@@ -125,7 +126,14 @@
     public static class AppWriteSettingsActivity extends SettingsActivity { /* empty */ }
     public static class ManageDefaultAppsActivity extends SettingsActivity { /* empty */ }
 
+    public static class WifiCallingSuggestionActivity extends SettingsActivity { /* empty */ }
+    public static class ZenModeAutomationSuggestionActivity extends SettingsActivity { /* empty */ }
     public static class WallpaperSuggestionActivity extends SettingsActivity { /* empty */ }
+    public static class FingerprintSuggestionActivity extends FingerprintSettings { /* empty */ }
+    public static class FingerprintEnrollSuggestionActivity extends FingerprintEnrollIntroduction {
+        /* empty */
+    }
+    public static class ScreenLockSuggestionActivity extends ChooseLockGeneric { /* empty */ }
 
     // Categories.
     public static class WirelessSettings extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsLicenseActivity.java b/src/com/android/settings/SettingsLicenseActivity.java
index 52b48bb..aa2e8dd 100644
--- a/src/com/android/settings/SettingsLicenseActivity.java
+++ b/src/com/android/settings/SettingsLicenseActivity.java
@@ -21,6 +21,7 @@
 import android.content.Intent;
 import android.net.Uri;
 import android.os.Bundle;
+import android.os.StrictMode;
 import android.os.SystemProperties;
 import android.text.TextUtils;
 import android.util.Log;
@@ -65,11 +66,14 @@
         intent.setPackage("com.android.htmlviewer");
 
         try {
+            StrictMode.disableDeathOnFileUriExposure();
             startActivity(intent);
             finish();
         } catch (ActivityNotFoundException e) {
             Log.e(TAG, "Failed to find viewer", e);
             showErrorAndFinish();
+        } finally {
+            StrictMode.enableDeathOnFileUriExposure();
         }
     }
 
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 1ca32d8..5ce5cfc 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -71,15 +71,11 @@
 public class AccessibilitySettings extends SettingsPreferenceFragment implements DialogCreatable,
         Preference.OnPreferenceChangeListener, Indexable {
 
-    private static final float LARGE_FONT_SCALE = 1.3f;
-
     // Preference categories
     private static final String SERVICES_CATEGORY = "services_category";
     private static final String SYSTEM_CATEGORY = "system_category";
 
     // Preferences
-    private static final String TOGGLE_LARGE_TEXT_PREFERENCE =
-            "toggle_large_text_preference";
     private static final String TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE =
             "toggle_high_text_contrast_preference";
     private static final String TOGGLE_INVERSION_PREFERENCE =
@@ -127,8 +123,6 @@
 
     private final Map<String, String> mLongPressTimeoutValuetoTitleMap = new HashMap<>();
 
-    private final Configuration mCurConfig = new Configuration();
-
     private final Handler mHandler = new Handler();
 
     private final Runnable mUpdateRunnable = new Runnable() {
@@ -185,7 +179,6 @@
     private PreferenceCategory mServicesCategory;
     private PreferenceCategory mSystemsCategory;
 
-    private SwitchPreference mToggleLargeTextPreference;
     private SwitchPreference mToggleHighTextContrastPreference;
     private SwitchPreference mTogglePowerButtonEndsCallPreference;
     private SwitchPreference mToggleLockScreenRotationPreference;
@@ -274,10 +267,7 @@
 
     @Override
     public boolean onPreferenceTreeClick(Preference preference) {
-        if (mToggleLargeTextPreference == preference) {
-            handleToggleLargeTextPreferenceClick();
-            return true;
-        } else if (mToggleHighTextContrastPreference == preference) {
+        if (mToggleHighTextContrastPreference == preference) {
             handleToggleTextContrastPreferenceClick();
             return true;
         } else if (mTogglePowerButtonEndsCallPreference == preference) {
@@ -302,15 +292,6 @@
         return super.onPreferenceTreeClick(preference);
     }
 
-    private void handleToggleLargeTextPreferenceClick() {
-        try {
-            mCurConfig.fontScale = mToggleLargeTextPreference.isChecked() ? LARGE_FONT_SCALE : 1;
-            ActivityManagerNative.getDefault().updatePersistentConfiguration(mCurConfig);
-        } catch (RemoteException re) {
-            /* ignore */
-        }
-    }
-
     private void handleToggleTextContrastPreferenceClick() {
         Settings.Secure.putInt(getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
@@ -368,10 +349,6 @@
         mServicesCategory = (PreferenceCategory) findPreference(SERVICES_CATEGORY);
         mSystemsCategory = (PreferenceCategory) findPreference(SYSTEM_CATEGORY);
 
-        // Large text.
-        mToggleLargeTextPreference =
-                (SwitchPreference) findPreference(TOGGLE_LARGE_TEXT_PREFERENCE);
-
         // Text contrast.
         mToggleHighTextContrastPreference =
                 (SwitchPreference) findPreference(TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE);
@@ -564,14 +541,6 @@
     }
 
     private void updateSystemPreferences() {
-        // Large text.
-        try {
-            mCurConfig.updateFrom(ActivityManagerNative.getDefault().getConfiguration());
-        } catch (RemoteException re) {
-            /* ignore */
-        }
-        mToggleLargeTextPreference.setChecked(mCurConfig.fontScale == LARGE_FONT_SCALE);
-
         // Text contrast.
         mToggleHighTextContrastPreference.setChecked(
                 Settings.Secure.getInt(getContentResolver(),
@@ -658,7 +627,7 @@
         final Resources res = getContext().getResources();
         final String[] entries = res.getStringArray(R.array.entries_font_size);
         final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
-        final int index = ToggleFontSizePreferenceFragment.floatToIndex(
+        final int index = ToggleFontSizePreferenceFragment.fontSizeValueToIndex(
                 res.getConfiguration().fontScale, strEntryValues);
         pref.setSummary(entries[index]);
     }
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
index 052f6fb..eaab57d 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
@@ -188,7 +188,7 @@
         final Resources res = getContext().getResources();
         final String[] entries = res.getStringArray(R.array.entries_font_size);
         final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
-        final int index = ToggleFontSizePreferenceFragment.floatToIndex(
+        final int index = ToggleFontSizePreferenceFragment.fontSizeValueToIndex(
                 res.getConfiguration().fontScale, strEntryValues);
         pref.setSummary(entries[index]);
     }
diff --git a/src/com/android/settings/accessibility/ToggleFontSizePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFontSizePreferenceFragment.java
index 4a8cd32..1c5d8dc 100644
--- a/src/com/android/settings/accessibility/ToggleFontSizePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFontSizePreferenceFragment.java
@@ -48,7 +48,7 @@
         final Configuration origConfig = res.getConfiguration();
         mEntries = res.getStringArray(R.array.entries_font_size);
         final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
-        mInitialIndex = floatToIndex(origConfig.fontScale, strEntryValues);
+        mInitialIndex = fontSizeValueToIndex(origConfig.fontScale, strEntryValues);
         mValues = new float[strEntryValues.length];
         for (int i = 0; i < strEntryValues.length; ++i) {
             mValues[i] = Float.parseFloat(strEntryValues[i]);
@@ -86,7 +86,7 @@
      *  Utility function that returns the index in a string array with which the represented value is
      *  the closest to a given float value.
      */
-    static int floatToIndex(float val, String[] indices) {
+    public static int fontSizeValueToIndex(float val, String[] indices) {
         float lastVal = Float.parseFloat(indices[0]);
         for (int i=1; i<indices.length; i++) {
             float thisVal = Float.parseFloat(indices[i]);
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 80719b2..041fed8 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -16,15 +16,111 @@
 
 package com.android.settings.accessibility;
 
+import android.content.ContentResolver;
+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.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.view.Display;
+import android.view.Gravity;
+import android.view.WindowManager;
+import android.widget.MediaController;
+import android.widget.RelativeLayout;
+import android.widget.VideoView;
 import com.android.internal.logging.MetricsProto.MetricsEvent;
+import com.android.settings.R;
 import com.android.settings.widget.ToggleSwitch;
 import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
 
 public class ToggleScreenMagnificationPreferenceFragment
         extends ToggleFeaturePreferenceFragment {
 
+    protected class VideoPreference extends Preference {
+        public VideoPreference(Context context) {
+            super(context);
+        }
+
+        @Override
+        public void onBindViewHolder(PreferenceViewHolder view) {
+            super.onBindViewHolder(view);
+            view.setDividerAllowedAbove(false);
+            view.setDividerAllowedBelow(false);
+            final RelativeLayout background =
+                    (RelativeLayout) view.findViewById(R.id.video_background);
+            final VideoView videoView = (VideoView) view.findViewById(R.id.video);
+
+            // Hacky adjustment for using VideoView in recycle view and positioning
+            // it on the background image
+            Resources res = getPrefContext().getResources();
+            final int backgroundWidth = res.getDimensionPixelSize(
+                    R.dimen.screen_magnification_video_background_width);
+            final int backgroundHeight = res.getDimensionPixelSize(
+                    R.dimen.screen_magnification_video_background_height);
+            final int videoWidth = res.getDimensionPixelSize(
+                    R.dimen.screen_magnification_video_width);
+            final int videoHeight = res.getDimensionPixelSize(
+                    R.dimen.screen_magnification_video_height);
+            final int videoMarginTop = res.getDimensionPixelSize(
+                    R.dimen.screen_magnification_video_margin_top);
+            final int screenWidth = getScreenWidth(getPrefContext());
+
+            RelativeLayout.LayoutParams videoLp = new RelativeLayout.LayoutParams(
+                    screenWidth * videoWidth / backgroundWidth,
+                    screenWidth * videoHeight / backgroundWidth);
+            videoLp.setMargins(0, screenWidth * videoMarginTop / backgroundWidth, 0, 0);
+            videoView.setLayoutParams(videoLp);
+
+            RelativeLayout.LayoutParams backgroundLp = new RelativeLayout.LayoutParams(
+                    screenWidth,
+                    screenWidth * backgroundHeight / backgroundWidth);
+            background.setLayoutParams(backgroundLp);
+            background.setBackgroundResource(
+                    R.drawable.accessibility_screen_magnification_background);
+            background.setGravity(Gravity.CENTER_HORIZONTAL);
+
+            // Loop the video.
+            videoView.setOnPreparedListener(new OnPreparedListener() {
+                @Override
+                public void onPrepared(MediaPlayer mediaPlayer) {
+                    mediaPlayer.setLooping(true);
+                }
+            });
+
+            videoView.setVideoURI(Uri.parse(String.format("%s://%s/%s",
+                    ContentResolver.SCHEME_ANDROID_RESOURCE,
+                    getPrefContext().getPackageName(),
+                    R.raw.accessibility_screen_magnification)));
+            videoView.setMediaController(new MediaController(getPrefContext()));
+            videoView.start();
+        }
+    }
+
+    protected VideoPreference mVideoPreference;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        mVideoPreference = new VideoPreference(getPrefContext());
+        mVideoPreference.setSelectable(false);
+        mVideoPreference.setPersistent(false);
+        mVideoPreference.setLayoutResource(R.layout.video_preference);
+
+        final PreferenceScreen preferenceScreen = getPreferenceManager().getPreferenceScreen();
+        preferenceScreen.setOrderingAsAdded(false);
+        mVideoPreference.setOrder(0);
+        mSummaryPreference.setOrder(1);
+        preferenceScreen.addPreference(mVideoPreference);
+    }
+
     @Override
     protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
         // Do nothing.
@@ -34,7 +130,7 @@
     protected void onInstallSwitchBarToggleSwitch() {
         super.onInstallSwitchBarToggleSwitch();
         mToggleSwitch.setOnBeforeCheckedChangeListener(new OnBeforeCheckedChangeListener() {
-                @Override
+            @Override
             public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
                 mSwitchBar.setCheckedInternal(checked);
                 getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, checked);
@@ -72,4 +168,12 @@
     protected int getMetricsCategory() {
         return MetricsEvent.ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION;
     }
+
+    private static int getScreenWidth(Context context) {
+        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+        Display display = wm.getDefaultDisplay();
+        Point size = new Point();
+        display.getSize(size);
+        return size.x;
+    }
 }
diff --git a/src/com/android/settings/applications/DefaultEmergencyPreference.java b/src/com/android/settings/applications/DefaultEmergencyPreference.java
index 0062625..7c9b124 100644
--- a/src/com/android/settings/applications/DefaultEmergencyPreference.java
+++ b/src/com/android/settings/applications/DefaultEmergencyPreference.java
@@ -24,6 +24,7 @@
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.os.AsyncTask;
+import android.os.UserManager;
 import android.provider.Settings;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
@@ -31,6 +32,7 @@
 import android.util.AttributeSet;
 
 import com.android.settings.AppListPreference;
+import com.android.settings.Utils;
 
 import java.util.List;
 import java.util.Objects;
@@ -135,7 +137,8 @@
 
     public static boolean isAvailable(Context context) {
         return isCapable(context)
-                && context.getPackageManager().resolveActivity(QUERY_INTENT, 0) != null;
+                && context.getPackageManager().resolveActivity(QUERY_INTENT, 0) != null
+                && !Utils.isManagedProfile(UserManager.get(context)) ;
     }
 
     public static boolean isCapable(Context context) {
diff --git a/src/com/android/settings/applications/DefaultNotificationAssistantPreference.java b/src/com/android/settings/applications/DefaultNotificationAssistantPreference.java
index 20c1a9e..186c442 100644
--- a/src/com/android/settings/applications/DefaultNotificationAssistantPreference.java
+++ b/src/com/android/settings/applications/DefaultNotificationAssistantPreference.java
@@ -25,6 +25,7 @@
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.content.pm.ServiceInfo;
+import android.os.UserManager;
 import android.provider.Settings;
 import android.service.notification.NotificationAssistantService;
 import android.util.AttributeSet;
@@ -34,6 +35,7 @@
 import java.util.List;
 
 import com.android.settings.R;
+import com.android.settings.Utils;
 import com.android.settings.notification.ManagedServiceSettings;
 
 public class DefaultNotificationAssistantPreference extends AppListPreference {
@@ -108,4 +110,8 @@
         c.emptyText = R.string.no_notification_listeners;
         return c;
     }
+
+    public static boolean isAvailable(Context context) {
+        return !Utils.isManagedProfile(UserManager.get(context));
+    }
 }
diff --git a/src/com/android/settings/applications/DefaultSmsPreference.java b/src/com/android/settings/applications/DefaultSmsPreference.java
index bf616c3..7281394 100644
--- a/src/com/android/settings/applications/DefaultSmsPreference.java
+++ b/src/com/android/settings/applications/DefaultSmsPreference.java
@@ -17,6 +17,7 @@
 
 import android.content.ComponentName;
 import android.content.Context;
+import android.os.UserManager;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
 import android.util.AttributeSet;
@@ -24,6 +25,7 @@
 import com.android.internal.telephony.SmsApplication;
 import com.android.internal.telephony.SmsApplication.SmsApplicationData;
 import com.android.settings.AppListPreference;
+import com.android.settings.Utils;
 
 import java.util.Collection;
 import java.util.Objects;
@@ -69,7 +71,7 @@
     public static boolean isAvailable(Context context) {
         TelephonyManager tm =
                 (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
-        return tm.isSmsCapable();
+        return tm.isSmsCapable() && !Utils.isManagedProfile(UserManager.get(context));
     }
 
 }
diff --git a/src/com/android/settings/applications/ManageAssist.java b/src/com/android/settings/applications/ManageAssist.java
index 24c558c..fca124f 100644
--- a/src/com/android/settings/applications/ManageAssist.java
+++ b/src/com/android/settings/applications/ManageAssist.java
@@ -18,9 +18,11 @@
 
 import android.app.AlertDialog;
 import android.content.ComponentName;
+import android.content.Context;
 import android.content.DialogInterface;
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.UserManager;
 import android.provider.Settings;
 import android.support.v14.preference.SwitchPreference;
 import android.support.v7.preference.Preference;
@@ -28,6 +30,7 @@
 import com.android.internal.logging.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.Utils;
 import com.android.settings.voice.VoiceInputListPreference;
 
 /**
@@ -175,4 +178,8 @@
         mDefaultAssitPref.setValue(assistPackage);
         updateUi();
     }
+
+    public static boolean isAvailable(Context context) {
+        return !Utils.isManagedProfile(UserManager.get(context));
+    }
 }
diff --git a/src/com/android/settings/applications/ManageDefaultApps.java b/src/com/android/settings/applications/ManageDefaultApps.java
index 77d268d..b421c9d 100644
--- a/src/com/android/settings/applications/ManageDefaultApps.java
+++ b/src/com/android/settings/applications/ManageDefaultApps.java
@@ -26,6 +26,7 @@
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.provider.SearchIndexableResource;
+import android.provider.Settings;
 import android.support.v7.preference.Preference;
 import android.text.TextUtils;
 import android.util.Log;
@@ -33,29 +34,32 @@
 import com.android.internal.content.PackageMonitor;
 import com.android.internal.logging.MetricsProto.MetricsEvent;
 import com.android.settings.R;
-import com.android.settings.SettingsPreferenceFragment;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Index;
 import com.android.settings.search.Indexable;
+import com.android.settings.utils.ProfileSettingsPreferenceFragment;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-public class ManageDefaultApps extends SettingsPreferenceFragment
+public class ManageDefaultApps extends ProfileSettingsPreferenceFragment
         implements Preference.OnPreferenceClickListener, Indexable {
 
     private static final String TAG = ManageDefaultApps.class.getSimpleName();
 
+    private static final String KEY_ASSIST_AND_VOICE_INPUT = "assist_and_voice_input";
     private static final String KEY_DEFAULT_BROWSER = "default_browser";
     private static final String KEY_DEFAULT_PHONE_APP = "default_phone_app";
     private static final String KEY_DEFAULT_EMERGENCY_APP = "default_emergency_app";
     private static final String KEY_SMS_APPLICATION = "default_sms_app";
+    private static final String KEY_DEFAULT_NOTIFICATION_ASST = "default_notification_asst_app";
 
     private DefaultBrowserPreference mDefaultBrowserPreference;
     private PackageManager mPm;
     private int myUserId;
 
+
     private static final long DELAY_UPDATE_BROWSER_MILLIS = 500;
 
     private final Handler mHandler = new Handler();
@@ -130,6 +134,7 @@
         mPm = getPackageManager();
         myUserId = UserHandle.myUserId();
 
+
         mDefaultBrowserPreference = (DefaultBrowserPreference) findPreference(KEY_DEFAULT_BROWSER);
         mDefaultBrowserPreference.setOnPreferenceChangeListener(
                 new Preference.OnPreferenceChangeListener() {
@@ -151,7 +156,7 @@
                         }
                         return result;
                     }
-        });
+                });
         final boolean isRestrictedUser = UserManager.get(getActivity())
                 .getUserInfo(myUserId).isRestricted();
 
@@ -169,6 +174,14 @@
             removePreference(KEY_DEFAULT_EMERGENCY_APP);
         }
 
+        if (!ManageAssist.isAvailable(getActivity())) {
+            removePreference(KEY_ASSIST_AND_VOICE_INPUT);
+        }
+
+        if (!DefaultNotificationAssistantPreference.isAvailable(getActivity())) {
+            removePreference(KEY_DEFAULT_NOTIFICATION_ASST);
+        }
+
         if (DefaultEmergencyPreference.isCapable(getActivity())) {
             Index.getInstance(getActivity()).updateFromClassNameResource(
                     ManageDefaultApps.class.getName(), true, true);
@@ -200,31 +213,36 @@
     }
 
     public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
-        new BaseSearchIndexProvider() {
-            @Override
-            public List<SearchIndexableResource> getXmlResourcesToIndex(
-                    Context context, boolean enabled) {
-                SearchIndexableResource sir = new SearchIndexableResource(context);
-                sir.xmlResId = R.xml.default_apps;
-                return Arrays.asList(sir);
-            }
-
-            @Override
-            public List<String> getNonIndexableKeys(Context context) {
-                final ArrayList<String> result = new ArrayList<String>();
-
-                // Remove SMS Application if the device does not support SMS
-                final boolean isRestrictedUser = UserManager.get(context)
-                        .getUserInfo(UserHandle.myUserId()).isRestricted();
-                if (!DefaultSmsPreference.isAvailable(context) || isRestrictedUser) {
-                    result.add(KEY_SMS_APPLICATION);
+            new BaseSearchIndexProvider() {
+                @Override
+                public List<SearchIndexableResource> getXmlResourcesToIndex(
+                        Context context, boolean enabled) {
+                    SearchIndexableResource sir = new SearchIndexableResource(context);
+                    sir.xmlResId = R.xml.default_apps;
+                    return Arrays.asList(sir);
                 }
 
-                if (!DefaultEmergencyPreference.isAvailable(context)) {
-                    result.add(KEY_DEFAULT_EMERGENCY_APP);
-                }
+                @Override
+                public List<String> getNonIndexableKeys(Context context) {
+                    final ArrayList<String> result = new ArrayList<String>();
 
-                return result;
-            }
-    };
+                    // Remove SMS Application if the device does not support SMS
+                    final boolean isRestrictedUser = UserManager.get(context)
+                            .getUserInfo(UserHandle.myUserId()).isRestricted();
+                    if (!DefaultSmsPreference.isAvailable(context) || isRestrictedUser) {
+                        result.add(KEY_SMS_APPLICATION);
+                    }
+
+                    if (!DefaultEmergencyPreference.isAvailable(context)) {
+                        result.add(KEY_DEFAULT_EMERGENCY_APP);
+                    }
+
+                    return result;
+                }
+            };
+
+    protected String getIntentActionString() {
+        return Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS;
+    }
+
 }
diff --git a/src/com/android/settings/dashboard/DashboardSummary.java b/src/com/android/settings/dashboard/DashboardSummary.java
index ba9136a..69fd8e7 100644
--- a/src/com/android/settings/dashboard/DashboardSummary.java
+++ b/src/com/android/settings/dashboard/DashboardSummary.java
@@ -161,6 +161,9 @@
         List<DashboardCategory> categories =
                 ((SettingsActivity) getActivity()).getDashboardCategories();
         mAdapter.setCategories(categories);
+
+        // recheck to see if any suggestions have been changed.
+        mAdapter.setSuggestions(mSuggestionParser);
         mDashboard.setAdapter(mAdapter);
 
         long delta = System.currentTimeMillis() - start;
diff --git a/src/com/android/settings/dashboard/SuggestionsChecks.java b/src/com/android/settings/dashboard/SuggestionsChecks.java
index b483ac7..d465942 100644
--- a/src/com/android/settings/dashboard/SuggestionsChecks.java
+++ b/src/com/android/settings/dashboard/SuggestionsChecks.java
@@ -18,13 +18,20 @@
 import android.app.IWallpaperManager;
 import android.app.IWallpaperManager.Stub;
 import android.app.IWallpaperManagerCallback;
+import android.app.KeyguardManager;
 import android.app.NotificationManager;
 import android.content.Context;
+import android.hardware.fingerprint.FingerprintManager;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.os.ServiceManager;
+import com.android.ims.ImsManager;
+import com.android.settings.Settings.FingerprintEnrollSuggestionActivity;
+import com.android.settings.Settings.FingerprintSuggestionActivity;
+import com.android.settings.Settings.ScreenLockSuggestionActivity;
 import com.android.settings.Settings.WallpaperSuggestionActivity;
+import com.android.settings.Settings.WifiCallingSuggestionActivity;
 import com.android.settings.Settings.ZenModeAutomationSuggestionActivity;
 import com.android.settingslib.drawer.Tile;
 
@@ -47,10 +54,35 @@
             return hasEnabledZenAutoRules();
         } else if (className.equals(WallpaperSuggestionActivity.class.getName())) {
             return hasWallpaperSet();
+        } else if (className.equals(WifiCallingSuggestionActivity.class.getName())) {
+            return isWifiCallingUnavailableOrEnabled();
+        } else if (className.equals(FingerprintSuggestionActivity.class.getName())) {
+            return isNotSingleFingerprintEnrolled();
+        } else if (className.equals(ScreenLockSuggestionActivity.class.getName())
+                || className.equals(FingerprintEnrollSuggestionActivity.class.getName())) {
+            return isDeviceSecured();
         }
         return false;
     }
 
+    private boolean isDeviceSecured() {
+        KeyguardManager km = mContext.getSystemService(KeyguardManager.class);
+        return km.isKeyguardSecure();
+    }
+
+    private boolean isNotSingleFingerprintEnrolled() {
+        FingerprintManager manager = mContext.getSystemService(FingerprintManager.class);
+        return manager == null || manager.getEnrolledFingerprints().size() != 1;
+    }
+
+    public boolean isWifiCallingUnavailableOrEnabled() {
+        if (!ImsManager.isWfcEnabledByPlatform(mContext)) {
+            return true;
+        }
+        return ImsManager.isWfcEnabledByUser(mContext)
+                && ImsManager.isNonTtyOrTtyOnVolteEnabled(mContext);
+    }
+
     private boolean hasEnabledZenAutoRules() {
         List<AutomaticZenRule> zenRules = NotificationManager.from(mContext).getAutomaticZenRules();
         final int N = zenRules.size();
diff --git a/src/com/android/settings/datausage/AppDataUsage.java b/src/com/android/settings/datausage/AppDataUsage.java
index a65f007..6a7b6b2 100644
--- a/src/com/android/settings/datausage/AppDataUsage.java
+++ b/src/com/android/settings/datausage/AppDataUsage.java
@@ -282,7 +282,7 @@
         } catch (PackageManager.NameNotFoundException e) {
         }
         AppHeader.setupHeaderView(getActivity(), mIcon, mLabel,
-                pkg, uid, AppHeader.includeAppInfo(this), 0, header);
+                pkg, uid, AppHeader.includeAppInfo(this), 0, header, null);
     }
 
     @Override
diff --git a/src/com/android/settings/datausage/CellDataPreference.java b/src/com/android/settings/datausage/CellDataPreference.java
index 73699d6..d64bef4 100644
--- a/src/com/android/settings/datausage/CellDataPreference.java
+++ b/src/com/android/settings/datausage/CellDataPreference.java
@@ -48,7 +48,7 @@
 
     private static final String TAG = "CellDataPreference";
 
-    public int mSubId;
+    public int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
     public boolean mChecked;
     public boolean mMultiSimDialog;
     private TelephonyManager mTelephonyManager;
@@ -65,8 +65,10 @@
         mTelephonyManager = TelephonyManager.from(getContext());
         mChecked = state.mChecked;
         mMultiSimDialog = state.mMultiSimDialog;
-        mSubId = state.mSubId;
-        setKey(getKey() + mSubId);
+        if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+            mSubId = state.mSubId;
+            setKey(getKey() + mSubId);
+        }
         notifyChanged();
     }
 
@@ -110,7 +112,6 @@
 
     @Override
     protected void performClick(View view) {
-        super.performClick(view);
         MetricsLogger.action(getContext(), MetricsEvent.ACTION_CELL_DATA_TOGGLE, !mChecked);
         if (mChecked) {
             // disabling data; show confirmation dialog which eventually
@@ -182,7 +183,7 @@
             setMobileDataEnabled(true);
             if (nextSir != null && currentSir != null &&
                 currentSir.getSubscriptionId() == nextSir.getSubscriptionId()) {
-                disableDataForOtherSubscriptions(currentSir);
+                disableDataForOtherSubscriptions(mSubId);
             }
             return;
         }
@@ -193,14 +194,15 @@
 
         builder.setTitle(R.string.sim_change_data_title);
         builder.setMessage(getContext().getString(R.string.sim_change_data_message,
-                    currentSir.getDisplayName(), previousName));
+                String.valueOf(currentSir != null ? currentSir.getDisplayName() : null),
+                previousName));
 
         builder.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int id) {
-                mSubscriptionManager.setDefaultDataSubId(currentSir.getSubscriptionId());
+                mSubscriptionManager.setDefaultDataSubId(mSubId);
                 setMobileDataEnabled(true);
-                disableDataForOtherSubscriptions(currentSir);
+                disableDataForOtherSubscriptions(mSubId);
             }
         });
         builder.setNegativeButton(R.string.cancel, null);
@@ -208,11 +210,11 @@
         builder.create().show();
     }
 
-    private void disableDataForOtherSubscriptions(SubscriptionInfo currentSir) {
+    private void disableDataForOtherSubscriptions(int subId) {
         List<SubscriptionInfo> subInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
         if (subInfoList != null) {
             for (SubscriptionInfo subInfo : subInfoList) {
-                if (subInfo.getSubscriptionId() != currentSir.getSubscriptionId()) {
+                if (subInfo.getSubscriptionId() != subId) {
                     mTelephonyManager.setDataEnabled(subInfo.getSubscriptionId(), false);
                 }
             }
diff --git a/src/com/android/settings/datausage/DataUsageSummary.java b/src/com/android/settings/datausage/DataUsageSummary.java
index e1936ed..3195641 100644
--- a/src/com/android/settings/datausage/DataUsageSummary.java
+++ b/src/com/android/settings/datausage/DataUsageSummary.java
@@ -138,6 +138,7 @@
         TemplatePreferenceCategory category = (TemplatePreferenceCategory)
                 inflatePreferences(R.xml.data_usage_cellular);
         category.setTemplate(getNetworkTemplate(subId), subId, services);
+        category.pushTemplates(services);
     }
 
     private void addWifiSection() {
diff --git a/src/com/android/settings/display/ScreenZoomSettings.java b/src/com/android/settings/display/ScreenZoomSettings.java
index 0ce1972..406c993 100644
--- a/src/com/android/settings/display/ScreenZoomSettings.java
+++ b/src/com/android/settings/display/ScreenZoomSettings.java
@@ -48,8 +48,9 @@
         mActivityLayoutResId = R.layout.screen_zoom_activity;
 
         // This should be replaced once the final preview sample screen is in place.
-        mPreviewSampleResIds = new int[]{R.layout.screen_zoom_preview, R.layout.screen_zoom_preview,
-                R.layout.screen_zoom_preview};
+        mPreviewSampleResIds = new int[]{R.layout.screen_zoom_preview_1,
+                R.layout.screen_zoom_preview_2,
+                R.layout.screen_zoom_preview_3};
 
         final DisplayDensityUtils density = new DisplayDensityUtils(getContext());
 
diff --git a/src/com/android/settings/fuelgauge/FakeUid.java b/src/com/android/settings/fuelgauge/FakeUid.java
index 9d3e2ad..d616010 100644
--- a/src/com/android/settings/fuelgauge/FakeUid.java
+++ b/src/com/android/settings/fuelgauge/FakeUid.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.fuelgauge;
 
+import android.os.BatteryStats;
 import android.os.BatteryStats.Timer;
 import android.os.BatteryStats.Uid;
 import android.util.ArrayMap;
@@ -73,16 +74,6 @@
     }
 
     @Override
-    public long getWifiControllerActivity(int type, int which) {
-        return 0;
-    }
-
-    @Override
-    public long getBluetoothControllerActivity(int type, int which) {
-        return 0;
-    }
-
-    @Override
     public void noteWifiRunningLocked(long elapsedRealtime) {
     }
 
@@ -258,4 +249,19 @@
     public long getCpuPowerMaUs(int which) {
         return 0;
     }
+
+    @Override
+    public BatteryStats.ControllerActivityCounter getWifiControllerActivity() {
+        return null;
+    }
+
+    @Override
+    public BatteryStats.ControllerActivityCounter getBluetoothControllerActivity() {
+        return null;
+    }
+
+    @Override
+    public BatteryStats.ControllerActivityCounter getModemControllerActivity() {
+        return null;
+    }
 }
diff --git a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
index 838989e..1318a1b 100644
--- a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
+++ b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
@@ -348,7 +348,9 @@
 
     private static String getLocaleNames(Context context) {
         final LocaleList locales = LocalePicker.getLocales();
-        return LocaleHelper.getDisplayLocaleList(locales, Locale.getDefault());
+        final Locale displayLocale = Locale.getDefault();
+        return LocaleHelper.toSentenceCase(
+                LocaleHelper.getDisplayLocaleList(locales, displayLocale), displayLocale);
     }
 
     private void saveInputMethodSelectorVisibility(String value) {
diff --git a/src/com/android/settings/localepicker/LocaleListEditor.java b/src/com/android/settings/localepicker/LocaleListEditor.java
index 24e5e53..8161036 100644
--- a/src/com/android/settings/localepicker/LocaleListEditor.java
+++ b/src/com/android/settings/localepicker/LocaleListEditor.java
@@ -155,7 +155,7 @@
         final MenuItem menuItem =
                 menu.add(Menu.NONE, MENU_ID_REMOVE, 0, R.string.locale_remove_menu);
         menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
-        menuItem.setIcon(android.R.drawable.ic_menu_delete);
+        menuItem.setIcon(R.drawable.ic_delete);
         super.onCreateOptionsMenu(menu, inflater);
         mMenu = menu;
     }
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index f3e95ab..ccb1216 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -22,8 +22,7 @@
 import android.content.pm.ApplicationInfo;
 import android.content.pm.ResolveInfo;
 import android.os.Bundle;
-import android.service.notification.NotificationListenerService;
-import android.support.v14.preference.SwitchPreference;
+import android.service.notification.NotificationListenerService.Ranking;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.Preference.OnPreferenceChangeListener;
 import android.support.v7.preference.Preference.OnPreferenceClickListener;
@@ -37,7 +36,12 @@
 import com.android.settings.R;
 import com.android.settings.Utils;
 import com.android.settings.applications.AppInfoBase;
+import com.android.settings.applications.LayoutPreference;
 import com.android.settings.notification.NotificationBackend.AppRow;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedSwitchPreference;
+import com.android.settingslib.RestrictedPreference;
+
 
 import java.util.List;
 
@@ -47,14 +51,13 @@
     private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
 
     private static final String KEY_BLOCK = "block";
-    private static final String KEY_APP_SETTINGS = "app_settings";
     private static final String KEY_CATEGORIES = "categories";
 
     private static final Intent APP_NOTIFICATION_PREFS_CATEGORY_INTENT
             = new Intent(Intent.ACTION_MAIN)
                 .addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES);
 
-    private SwitchPreference mBlock;
+    private RestrictedSwitchPreference mBlock;
     private PreferenceCategory mCategories;
     private AppRow mAppRow;
 
@@ -62,7 +65,8 @@
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
         if (mAppRow == null) return;
-        AppHeader.createAppHeader(this, mAppRow.icon, mAppRow.label, mAppRow.pkg, mAppRow.uid);
+        AppHeader.createAppHeader(this, mAppRow.icon, mAppRow.label, mAppRow.pkg, mAppRow.uid,
+                mAppRow.settingsIntent);
     }
 
     @Override
@@ -75,7 +79,16 @@
         super.onCreate(savedInstanceState);
 
         addPreferencesFromResource(R.xml.app_notification_settings);
-        getPreferenceScreen().setOrderingAsAdded(true);
+        mCategories = (PreferenceCategory) findPreference(KEY_CATEGORIES);
+        mBlock = (RestrictedSwitchPreference) findPreference(KEY_BLOCK);
+        mImportance = (ImportanceSeekBarPreference) findPreference(KEY_IMPORTANCE);
+        mImportanceReset = (LayoutPreference) findPreference(KEY_IMPORTANCE_RESET);
+        mImportanceTitle = findPreference(KEY_IMPORTANCE_TITLE);
+        mPriority =
+                (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BYPASS_DND);
+        mSensitive =
+                (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_SENSITIVE);
+
         mAppRow = mBackend.loadAppRow(mPm, mPkgInfo);
 
         // load settings intent
@@ -86,18 +99,17 @@
         // Add topics
         List<Notification.Topic> topics = mBackend.getTopics(mPkg, mUid);
         if (topics.size() <= 1) {
-            setupImportancePref(mAppRow, null, mAppRow.appImportance);
-            setupPriorityPref(null, mAppRow.appBypassDnd);
-            setupSensitivePref(null, mAppRow.appSensitive);
+            removeAppPrefs();
+            setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance);
+            setupPriorityPref(mAppRow.appBypassDnd);
+            setupSensitivePref(mAppRow.appSensitive);
         } else {
+            removeTopicPrefs();
             setupBlockSwitch();
-            mCategories = new PreferenceCategory(getPrefContext());
-            mCategories.setKey(KEY_CATEGORIES);
-            mCategories.setTitle(R.string.notification_topic_categories);
-            mCategories.setOrderingAsAdded(true);
-            getPreferenceScreen().addPreference(mCategories);
             for (Notification.Topic topic : topics) {
-                Preference topicPreference = new Preference(getPrefContext());
+                RestrictedPreference topicPreference = new RestrictedPreference(getPrefContext());
+                topicPreference.setDisabledByAdmin(
+                        RestrictedLockUtils.checkIfApplicationIsSuspended(mContext, mPkg, mUserId));
                 topicPreference.setKey(topic.getId());
                 topicPreference.setTitle(topic.getLabel());
                 // Create intent for this preference.
@@ -115,37 +127,34 @@
                 mCategories.addPreference(topicPreference);
             }
         }
-
-        if (mAppRow.settingsIntent != null) {
-            findPreference(KEY_APP_SETTINGS).setOnPreferenceClickListener(
-                    new OnPreferenceClickListener() {
-                @Override
-                public boolean onPreferenceClick(Preference preference) {
-                    mContext.startActivity(mAppRow.settingsIntent);
-                    return true;
-                }
-            });
-        } else {
-            removePreference(KEY_APP_SETTINGS);
-        }
     }
 
     @Override
     protected void updateDependents(int progress) {
-        updateDependents(progress == NotificationListenerService.Ranking.IMPORTANCE_NONE);
+        updateDependents(progress == Ranking.IMPORTANCE_NONE);
+    }
+
+    private void removeTopicPrefs() {
+        setVisible(mImportance, false);
+        setVisible(mImportanceReset, false);
+        setVisible(mImportanceTitle, false);
+        setVisible(mPriority, false);
+        setVisible(mSensitive, false);
+    }
+
+    private void removeAppPrefs() {
+        setVisible(mBlock, false);
+        setVisible(mCategories, false);
     }
 
     private void updateDependents(boolean banned) {
-        if (mBlock != null) {
-            mBlock.setEnabled(!mAppRow.systemApp);
-        }
-        if (mCategories != null) {
-            setVisible(mCategories, !banned);
-        }
+        mBlock.setEnabled(!mAppRow.systemApp);
+        mCategories.setEnabled(!banned);
     }
 
     private void setupBlockSwitch() {
-        mBlock = new SwitchPreference(getPrefContext());
+        mBlock.setDisabledByAdmin(
+                RestrictedLockUtils.checkIfApplicationIsSuspended(mContext, mPkg, mUserId));
         mBlock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
             @Override
             public boolean onPreferenceChange(Preference preference, Object newValue) {
@@ -153,17 +162,13 @@
                 if (banned) {
                     MetricsLogger.action(getActivity(), MetricsEvent.ACTION_BAN_APP_NOTES, mPkg);
                 }
-                final boolean success =  mBackend.setNotificationsBanned(mPkg, mUid, banned);
+                final boolean success = mBackend.setNotificationsBanned(mPkg, mUid, banned);
                 if (success) {
                     updateDependents(banned);
                 }
                 return success;
             }
         });
-        mBlock.setKey(KEY_BLOCK);
-        mBlock.setTitle(R.string.app_notification_block_title);
-        mBlock.setSummary(R.string.app_notification_block_summary);
-        getPreferenceScreen().addPreference(mBlock);
         mBlock.setChecked(mAppRow.banned);
         updateDependents(mAppRow.banned);
     }
diff --git a/src/com/android/settings/notification/ImportanceSeekBarPreference.java b/src/com/android/settings/notification/ImportanceSeekBarPreference.java
index 920fcc3..aff9688 100644
--- a/src/com/android/settings/notification/ImportanceSeekBarPreference.java
+++ b/src/com/android/settings/notification/ImportanceSeekBarPreference.java
@@ -20,12 +20,10 @@
 import com.android.settings.SeekBarPreference;
 
 import android.content.Context;
-import android.service.notification.NotificationListenerService;
 import android.support.v7.preference.PreferenceViewHolder;
 import android.util.AttributeSet;
 import android.widget.ImageView;
 import android.widget.SeekBar;
-import android.widget.TextView;
 
 /**
  * A slider preference that controls notification importance.
@@ -35,8 +33,6 @@
     private static final String TAG = "ImportanceSeekBarPref";
 
     private Callback mCallback;
-    private TextView mSummaryTextView;
-    private String mSummary;
     private int mMinProgress;
     private boolean mSystemApp;
 
@@ -64,6 +60,7 @@
 
     public void setMinimumProgress(int minProgress) {
         mMinProgress = minProgress;
+        notifyChanged();
     }
 
     public void setSystemApp(boolean systemApp) {
@@ -74,17 +71,12 @@
     @Override
     public void onBindViewHolder(PreferenceViewHolder view) {
         super.onBindViewHolder(view);
-        mSummaryTextView = (TextView) view.findViewById(com.android.internal.R.id.summary);
         if (mSystemApp) {
             ((ImageView) view.findViewById(R.id.low_importance)).getDrawable().setTint(
                     getContext().getColor(R.color.importance_disabled_tint));
         }
-    }
-
-    @Override
-    public void setProgress(int progress) {
-        mSummary = getProgressSummary(progress);
-        super.setProgress(progress);
+        view.setDividerAllowedAbove(false);
+        view.setDividerAllowedBelow(false);
     }
 
     @Override
@@ -94,37 +86,11 @@
             seekBar.setProgress(mMinProgress);
             progress = mMinProgress;
         }
-        mSummary = getProgressSummary(progress);
-        if (mSummaryTextView != null) {
-            mSummaryTextView.setText(mSummary);
-        }
         if (fromTouch) {
             mCallback.onImportanceChanged(progress);
         }
     }
 
-    @Override
-    public CharSequence getSummary() {
-        return mSummary;
-    }
-
-    private String getProgressSummary(int progress) {
-        switch (progress) {
-            case NotificationListenerService.Ranking.IMPORTANCE_NONE:
-                return getContext().getString(R.string.notification_importance_blocked);
-            case NotificationListenerService.Ranking.IMPORTANCE_LOW:
-                return getContext().getString(R.string.notification_importance_low);
-            case NotificationListenerService.Ranking.IMPORTANCE_DEFAULT:
-                return getContext().getString(R.string.notification_importance_default);
-            case NotificationListenerService.Ranking.IMPORTANCE_HIGH:
-                return getContext().getString(R.string.notification_importance_high);
-            case NotificationListenerService.Ranking.IMPORTANCE_MAX:
-                return getContext().getString(R.string.notification_importance_max);
-            default:
-                return "";
-        }
-    }
-
     public interface Callback {
         void onImportanceChanged(int progress);
     }
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index a669d95..740f8c1 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -19,6 +19,9 @@
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
 import com.android.settings.applications.AppInfoBase;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedSwitchPreference;
+import com.android.settings.applications.LayoutPreference;
 
 import android.app.Notification;
 import android.content.Context;
@@ -27,34 +30,45 @@
 import android.content.pm.PackageManager;
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.os.Bundle;
+import android.os.UserHandle;
 import android.provider.Settings;
 import android.service.notification.NotificationListenerService.Ranking;
-import android.support.v14.preference.SwitchPreference;
 import android.support.v7.preference.Preference;
 import android.text.TextUtils;
 import android.util.Log;
+import android.view.View;
+import android.widget.Button;
 import android.widget.Toast;
 
+import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
 abstract public class NotificationSettingsBase extends SettingsPreferenceFragment {
     private static final String TAG = "NotifiSettingsBase";
     private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
 
     protected static final String ARG_PACKAGE_INFO = "arg_info";
+    protected static final String ARG_TOPIC = "arg_topic";
 
     protected static final String KEY_BYPASS_DND = "bypass_dnd";
     protected static final String KEY_SENSITIVE = "sensitive";
     protected static final String KEY_IMPORTANCE = "importance";
+    protected static final String KEY_IMPORTANCE_TITLE = "importance_title";
+    protected static final String KEY_IMPORTANCE_RESET = "importance_reset_button";
 
     protected PackageManager mPm;
     protected final NotificationBackend mBackend = new NotificationBackend();
     protected Context mContext;
     protected boolean mCreated;
     protected int mUid;
+    protected int mUserId;
     protected String mPkg;
     protected PackageInfo mPkgInfo;
+    protected Notification.Topic mTopic;
     protected ImportanceSeekBarPreference mImportance;
-    protected SwitchPreference mPriority;
-    protected SwitchPreference mSensitive;
+    protected Preference mImportanceTitle;
+    protected LayoutPreference mImportanceReset;
+    protected RestrictedSwitchPreference mPriority;
+    protected RestrictedSwitchPreference mSensitive;
 
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
@@ -94,6 +108,7 @@
             toastAndFinish();
             return;
         }
+        mUserId = UserHandle.getUserId(mUid);
 
         if (DEBUG) Log.d(TAG, "Load details for pkg=" + mPkg + " uid=" + mUid);
         mPkgInfo = args != null && args.containsKey(ARG_PACKAGE_INFO)
@@ -107,75 +122,116 @@
             toastAndFinish();
             return;
         }
+
+        // Will be null for app wide settings.
+        mTopic = args != null && args.containsKey(ARG_TOPIC)
+                ? (Notification.Topic) args.getParcelable(ARG_TOPIC) : null;
     }
 
     @Override
     public void onResume() {
         super.onResume();
-        if (mUid != -1 && getPackageManager().getPackagesForUid(mUid) == null) {
+        if ((mUid != -1 && getPackageManager().getPackagesForUid(mUid) == null)) {
             // App isn't around anymore, must have been removed.
             finish();
+            return;
+        }
+        EnforcedAdmin admin = RestrictedLockUtils.checkIfApplicationIsSuspended(
+                mContext, mPkg, mUserId);
+        if (mImportance != null) {
+            mImportance.setDisabledByAdmin(admin);
+        }
+        if (mPriority != null) {
+            mPriority.setDisabledByAdmin(admin);
+        }
+        if (mSensitive != null) {
+            mSensitive.setDisabledByAdmin(admin);
         }
     }
 
-    protected void setupImportancePref(final NotificationBackend.AppRow appRow,
-            final Notification.Topic topic, int importance) {
-        if (mImportance == null) {
-            mImportance = new ImportanceSeekBarPreference(getPrefContext());
-            mImportance.setTitle(R.string.notification_importance_title);
-            mImportance.setKey(KEY_IMPORTANCE);
-            getPreferenceScreen().addPreference(mImportance);
+    protected void setupImportancePrefs(boolean isSystemApp, int importance) {
+        mImportance.setDisabledByAdmin(
+                RestrictedLockUtils.checkIfApplicationIsSuspended(mContext, mPkg, mUserId));
+        if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
+            mImportance.setVisible(false);
+            mImportanceReset.setVisible(false);
+            mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
+        } else {
+            mImportanceTitle.setOnPreferenceClickListener(null);
         }
-        mImportance.setSystemApp(appRow.systemApp);
+
+        mImportanceTitle.setSummary(getProgressSummary(importance));
+        mImportance.setSystemApp(isSystemApp);
         mImportance.setMinimumProgress(
-                appRow.systemApp ? Ranking.IMPORTANCE_LOW : Ranking.IMPORTANCE_NONE);
+                isSystemApp ? Ranking.IMPORTANCE_LOW : Ranking.IMPORTANCE_NONE);
         mImportance.setMax(Ranking.IMPORTANCE_MAX);
-        // TODO: stop defaulting to 'normal' in the UI when there are mocks for this scenario.
-        importance = importance == Ranking.IMPORTANCE_UNSPECIFIED
-                        ? Ranking.IMPORTANCE_DEFAULT
-                        : importance;
         mImportance.setProgress(importance);
         mImportance.setCallback(new ImportanceSeekBarPreference.Callback() {
             @Override
             public void onImportanceChanged(int progress) {
-                mBackend.setImportance(appRow.pkg, appRow.uid, topic, progress);
+                mBackend.setImportance(mPkg, mUid, mTopic, progress);
+                mImportanceTitle.setSummary(getProgressSummary(progress));
                 updateDependents(progress);
             }
         });
+
+        Button button = (Button) mImportanceReset.findViewById(R.id.left_button);
+        button.setText(R.string.importance_reset);
+        button.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                mBackend.setImportance(mPkg, mUid, mTopic, Ranking.IMPORTANCE_UNSPECIFIED);
+                mImportanceReset.setVisible(false);
+                mImportance.setVisible(false);
+                mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
+                mImportanceTitle.setSummary(getProgressSummary(Ranking.IMPORTANCE_UNSPECIFIED));
+                updateDependents(Ranking.IMPORTANCE_UNSPECIFIED);
+            }
+        });
+        mImportanceReset.findViewById(R.id.right_button).setVisibility(View.INVISIBLE);
     }
 
-    protected void setupPriorityPref(final Notification.Topic topic, boolean priority) {
-        if (mPriority == null) {
-            mPriority = new SwitchPreference(getPrefContext());
-            mPriority.setTitle(R.string.app_notification_override_dnd_title);
-            mPriority.setSummary(R.string.app_notification_override_dnd_summary);
-            mPriority.setKey(KEY_BYPASS_DND);
-            getPreferenceScreen().addPreference(mPriority);
+    private String getProgressSummary(int progress) {
+        switch (progress) {
+            case Ranking.IMPORTANCE_NONE:
+                return mContext.getString(R.string.notification_importance_blocked);
+            case Ranking.IMPORTANCE_LOW:
+                return mContext.getString(R.string.notification_importance_low);
+            case Ranking.IMPORTANCE_DEFAULT:
+                return mContext.getString(R.string.notification_importance_default);
+            case Ranking.IMPORTANCE_HIGH:
+                return mContext.getString(R.string.notification_importance_high);
+            case Ranking.IMPORTANCE_MAX:
+                return mContext.getString(R.string.notification_importance_max);
+            case Ranking.IMPORTANCE_UNSPECIFIED:
+                return mContext.getString(R.string.notification_importance_none);
+            default:
+                return "";
         }
+    }
+
+    protected void setupPriorityPref(boolean priority) {
+        mPriority.setDisabledByAdmin(
+                RestrictedLockUtils.checkIfApplicationIsSuspended(mContext, mPkg, mUserId));
         mPriority.setChecked(priority);
         mPriority.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
             @Override
             public boolean onPreferenceChange(Preference preference, Object newValue) {
                 final boolean bypassZenMode = (Boolean) newValue;
-                return mBackend.setBypassZenMode(mPkgInfo.packageName, mUid, topic, bypassZenMode);
+                return mBackend.setBypassZenMode(mPkgInfo.packageName, mUid, mTopic, bypassZenMode);
             }
         });
     }
 
-    protected void setupSensitivePref(final Notification.Topic topic, boolean sensitive) {
-        if (mSensitive == null) {
-            mSensitive = new SwitchPreference(getPrefContext());
-            mSensitive.setTitle(R.string.app_notification_sensitive_title);
-            mSensitive.setSummary(R.string.app_notification_sensitive_summary);
-            mSensitive.setKey(KEY_SENSITIVE);
-            getPreferenceScreen().addPreference(mSensitive);
-        }
+    protected void setupSensitivePref(boolean sensitive) {
+        mSensitive.setDisabledByAdmin(
+                RestrictedLockUtils.checkIfApplicationIsSuspended(mContext, mPkg, mUserId));
         mSensitive.setChecked(sensitive);
         mSensitive.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
             @Override
             public boolean onPreferenceChange(Preference preference, Object newValue) {
                 final boolean sensitive = (Boolean) newValue;
-                return mBackend.setSensitive(mPkgInfo.packageName, mUid, topic, sensitive);
+                return mBackend.setSensitive(mPkgInfo.packageName, mUid, mTopic, sensitive);
             }
         });
     }
@@ -214,4 +270,18 @@
         }
         return null;
     }
+
+    private Preference.OnPreferenceClickListener showEditableImportance =
+            new Preference.OnPreferenceClickListener() {
+                @Override
+                public boolean onPreferenceClick(Preference preference) {
+                    mBackend.setImportance(mPkg, mUid, mTopic, Ranking.IMPORTANCE_DEFAULT);
+                    mImportance.setProgress(Ranking.IMPORTANCE_DEFAULT);
+                    mImportanceTitle.setSummary(getProgressSummary(Ranking.IMPORTANCE_DEFAULT));
+                    mImportance.setVisible(true);
+                    mImportanceReset.setVisible(true);
+                    mImportanceTitle.setOnPreferenceClickListener(null);
+                    return true;
+                }
+            };
 }
diff --git a/src/com/android/settings/notification/TopicNotificationSettings.java b/src/com/android/settings/notification/TopicNotificationSettings.java
index 96104e4..bbbcade 100644
--- a/src/com/android/settings/notification/TopicNotificationSettings.java
+++ b/src/com/android/settings/notification/TopicNotificationSettings.java
@@ -20,33 +20,19 @@
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.AppHeader;
 import com.android.settings.R;
-import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.applications.AppInfoBase;
+import com.android.settings.applications.LayoutPreference;
 import com.android.settings.notification.NotificationBackend.TopicRow;
+import com.android.settingslib.RestrictedSwitchPreference;
 
-import android.app.Notification;
 import android.app.NotificationManager;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
 import android.os.Bundle;
 import android.os.UserHandle;
 import android.provider.Settings;
-import android.service.notification.NotificationListenerService;
 import android.service.notification.NotificationListenerService.Ranking;
-import android.support.v14.preference.SwitchPreference;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.Preference.OnPreferenceChangeListener;
-import android.util.Log;
-import android.widget.Toast;
 
 /** These settings are per topic, so should not be returned in global search results. */
 public class TopicNotificationSettings extends NotificationSettingsBase {
     private static final String TAG = "TopicNotiSettings";
-
-    protected static final String ARG_TOPIC = "arg_topic";
-
     private TopicRow mTopicRow;
     private boolean mDndVisualEffectsSuppressed;
 
@@ -71,25 +57,23 @@
                 NotificationManager.from(mContext).getNotificationPolicy();
         mDndVisualEffectsSuppressed = policy == null ? false : policy.suppressedVisualEffects != 0;
 
-        Bundle args = getArguments();
-        final Notification.Topic topic = args != null && args.containsKey(ARG_TOPIC)
-                ? (Notification.Topic) args.getParcelable(ARG_TOPIC) : null;
-        if (topic == null) {
+        if (mTopic == null) {
             toastAndFinish();
             return;
         }
 
         addPreferencesFromResource(R.xml.topic_notification_settings);
-        mTopicRow = mBackend.loadTopicRow(mPm, mPkgInfo, topic);
+        mTopicRow = mBackend.loadTopicRow(mPm, mPkgInfo, mTopic);
 
         mImportance = (ImportanceSeekBarPreference) findPreference(KEY_IMPORTANCE);
-        setupImportancePref(mTopicRow, mTopicRow.topic, mTopicRow.importance);
+        mImportanceReset = (LayoutPreference) findPreference(KEY_IMPORTANCE_RESET);
+        mImportanceTitle = findPreference(KEY_IMPORTANCE_TITLE);
+        mPriority = (RestrictedSwitchPreference) findPreference(KEY_BYPASS_DND);
+        mSensitive = (RestrictedSwitchPreference) findPreference(KEY_SENSITIVE);
 
-        mPriority = (SwitchPreference) findPreference(KEY_BYPASS_DND);
-        setupPriorityPref(mTopicRow.topic, mTopicRow.priority);
-
-        mSensitive = (SwitchPreference) findPreference(KEY_SENSITIVE);
-        setupSensitivePref(mTopicRow.topic, mTopicRow.sensitive);
+        setupImportancePrefs(mTopicRow.systemApp, mTopicRow.importance);
+        setupPriorityPref(mTopicRow.priority);
+        setupSensitivePref(mTopicRow.sensitive);
 
         updateDependents(mTopicRow.importance);
     }
@@ -101,13 +85,19 @@
         final boolean lockscreenNotificationsEnabled = getLockscreenNotificationsEnabled();
         final boolean allowPrivate = getLockscreenAllowPrivateNotifications();
 
-
-        setVisible(mPriority, importance > NotificationListenerService.Ranking.IMPORTANCE_DEFAULT
+        setVisible(mPriority, checkCanBeVisible(Ranking.IMPORTANCE_DEFAULT, importance)
                 && !mDndVisualEffectsSuppressed);
-        setVisible(mSensitive, (importance > NotificationListenerService.Ranking.IMPORTANCE_LOW)
+        setVisible(mSensitive, checkCanBeVisible(Ranking.IMPORTANCE_LOW, importance)
                 && lockscreenSecure && lockscreenNotificationsEnabled && allowPrivate);
     }
 
+    protected boolean checkCanBeVisible(int minImportanceVisible, int importance) {
+        if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
+            return true;
+        }
+        return importance > minImportanceVisible;
+    }
+
     private boolean getLockscreenNotificationsEnabled() {
         return Settings.Secure.getInt(getContentResolver(),
                 Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
diff --git a/src/com/android/settings/print/PrintSettingsFragment.java b/src/com/android/settings/print/PrintSettingsFragment.java
index 537f5de..b59c297 100644
--- a/src/com/android/settings/print/PrintSettingsFragment.java
+++ b/src/com/android/settings/print/PrintSettingsFragment.java
@@ -33,8 +33,6 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
-import android.os.UserHandle;
-import android.os.UserManager;
 import android.print.PrintJob;
 import android.print.PrintJobId;
 import android.print.PrintJobInfo;
@@ -52,22 +50,18 @@
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemSelectedListener;
 import android.widget.Button;
-import android.widget.Spinner;
 import android.widget.TextView;
 
 import com.android.internal.content.PackageMonitor;
 import com.android.internal.logging.MetricsProto.MetricsEvent;
 import com.android.settings.DialogCreatable;
 import com.android.settings.R;
-import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.utils.ProfileSettingsPreferenceFragment;
 import com.android.settings.dashboard.SummaryLoader;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
 import com.android.settings.search.SearchIndexableRaw;
-import com.android.settingslib.drawer.UserAdapter;
 
 import java.text.DateFormat;
 import java.util.ArrayList;
@@ -76,8 +70,8 @@
 /**
  * Fragment with the top level print settings.
  */
-public class PrintSettingsFragment extends SettingsPreferenceFragment
-        implements DialogCreatable, Indexable, OnItemSelectedListener, OnClickListener {
+public class PrintSettingsFragment extends ProfileSettingsPreferenceFragment
+        implements DialogCreatable, Indexable, OnClickListener {
     public static final String TAG = "PrintSettingsFragment";
     private static final int LOADER_ID_PRINT_JOBS_LOADER = 1;
 
@@ -122,8 +116,6 @@
     private PreferenceCategory mPrintServicesCategory;
 
     private PrintJobsController mPrintJobsController;
-    private UserAdapter mProfileSpinnerAdapter;
-    private Spinner mSpinner;
     private Button mAddNewServiceButton;
 
     @Override
@@ -188,14 +180,11 @@
 
         contentRoot.addView(emptyView);
         setEmptyView(emptyView);
+    }
 
-        final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
-        mProfileSpinnerAdapter = UserAdapter.createUserSpinnerAdapter(um, getActivity());
-        if (mProfileSpinnerAdapter != null) {
-            mSpinner = (Spinner) setPinnedHeaderView(R.layout.spinner_view);
-            mSpinner.setAdapter(mProfileSpinnerAdapter);
-            mSpinner.setOnItemSelectedListener(this);
-        }
+    @Override
+    protected String getIntentActionString() {
+        return Settings.ACTION_PRINT_SETTINGS;
     }
 
     private void updateServicesPreferences() {
@@ -327,24 +316,6 @@
     }
 
     @Override
-    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
-        UserHandle selectedUser = mProfileSpinnerAdapter.getUserHandle(position);
-        if (selectedUser.getIdentifier() != UserHandle.myUserId()) {
-            Intent intent = new Intent(Settings.ACTION_PRINT_SETTINGS);
-            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
-            getActivity().startActivityAsUser(intent, selectedUser);
-            // Go back to default selection, which is the first one
-            mSpinner.setSelection(0);
-        }
-    }
-
-    @Override
-    public void onNothingSelected(AdapterView<?> parent) {
-        // Nothing to do
-    }
-
-    @Override
     public void onClick(View v) {
         if (mAddNewServiceButton == v) {
             final Intent addNewServiceIntent = createAddNewServiceIntentOrNull();
diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java
index 2d30ecf..be10dd3 100644
--- a/src/com/android/settings/tts/TextToSpeechSettings.java
+++ b/src/com/android/settings/tts/TextToSpeechSettings.java
@@ -26,7 +26,7 @@
 import android.speech.tts.TextToSpeech.EngineInfo;
 import android.speech.tts.TtsEngines;
 import android.speech.tts.UtteranceProgressListener;
-import android.support.v7.preference.ListPreference;
+import android.support.v14.preference.SwitchPreference;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceCategory;
 import android.text.TextUtils;
@@ -35,6 +35,7 @@
 
 import com.android.internal.logging.MetricsProto.MetricsEvent;
 import com.android.settings.R;
+import com.android.settings.SeekBarPreference;
 import com.android.settings.SettingsActivity;
 import com.android.settings.SettingsPreferenceFragment;
 import com.android.settings.tts.TtsEnginePreference.RadioButtonGroupState;
@@ -49,6 +50,7 @@
 
 import static android.provider.Settings.Secure.TTS_DEFAULT_RATE;
 import static android.provider.Settings.Secure.TTS_DEFAULT_SYNTH;
+import static android.provider.Settings.Secure.TTS_DEFAULT_HIGHER_SPEECH_RATE_ENABLED;
 
 public class TextToSpeechSettings extends SettingsPreferenceFragment implements
         Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener,
@@ -63,6 +65,10 @@
     /** Preference key for the TTS rate selection dialog. */
     private static final String KEY_DEFAULT_RATE = "tts_default_rate";
 
+    /** Preference key for the TTS advanced speech rate switch. */
+    private static final String KEY_HIGHER_RATE_SWITCH =
+        "tts_default_higher_speech_rate_enabled";
+
     /** Preference key for the TTS status field. */
     private static final String KEY_STATUS = "tts_status";
 
@@ -78,14 +84,26 @@
     private static final int GET_SAMPLE_TEXT = 1983;
     private static final int VOICE_DATA_INTEGRITY_CHECK = 1977;
 
+    /**
+     * Maximum speech rate values.
+     */
+    private static final int MAX_SPEECH_RATE = 400;
+    private static final int MAX_HIGHER_SPEECH_RATE = 600;
+
     private PreferenceCategory mEnginePreferenceCategory;
-    private ListPreference mDefaultRatePref;
+    private SeekBarPreference mDefaultRatePref;
+    private SwitchPreference mHigherRateSwitchPref;
     private Preference mPlayExample;
     private Preference mEngineStatus;
 
     private int mDefaultRate = TextToSpeech.Engine.DEFAULT_RATE;
 
     /**
+     * Whether higher speech rate is enabled.
+     */
+    private boolean mHigherRateSwitch = false;
+
+    /**
      * The currently selected engine.
      */
     private String mCurrentEngine;
@@ -161,7 +179,8 @@
 
         mEnginePreferenceCategory = (PreferenceCategory) findPreference(
                 KEY_ENGINE_PREFERENCE_SECTION);
-        mDefaultRatePref = (ListPreference) findPreference(KEY_DEFAULT_RATE);
+        mDefaultRatePref = (SeekBarPreference) findPreference(KEY_DEFAULT_RATE);
+        mHigherRateSwitchPref = (SwitchPreference) findPreference(KEY_HIGHER_RATE_SWITCH);
 
         mEngineStatus = findPreference(KEY_STATUS);
         updateEngineStatus(R.string.tts_status_checking);
@@ -223,13 +242,25 @@
         // Set up the default rate.
         try {
             mDefaultRate = android.provider.Settings.Secure.getInt(resolver, TTS_DEFAULT_RATE);
+            mHigherRateSwitch = android.provider.Settings.Secure.getInt(resolver,
+                    TTS_DEFAULT_HIGHER_SPEECH_RATE_ENABLED) == 1;
         } catch (SettingNotFoundException e) {
             // Default rate setting not found, initialize it
             mDefaultRate = TextToSpeech.Engine.DEFAULT_RATE;
+            mHigherRateSwitch = false;
         }
-        mDefaultRatePref.setValue(String.valueOf(mDefaultRate));
+        mDefaultRatePref.setProgress(mDefaultRate);
         mDefaultRatePref.setOnPreferenceChangeListener(this);
 
+        mHigherRateSwitchPref.setChecked(mHigherRateSwitch);
+        mHigherRateSwitchPref.setOnPreferenceChangeListener(this);
+
+        if (mHigherRateSwitch) {
+            mDefaultRatePref.setMax(MAX_HIGHER_SPEECH_RATE);
+        } else {
+            mDefaultRatePref.setMax(MAX_SPEECH_RATE);
+        }
+
         mCurrentEngine = mTts.getCurrentEngine();
 
         SettingsActivity activity = null;
@@ -447,7 +478,7 @@
     public boolean onPreferenceChange(Preference preference, Object objValue) {
         if (KEY_DEFAULT_RATE.equals(preference.getKey())) {
             // Default rate
-            mDefaultRate = Integer.parseInt((String) objValue);
+            mDefaultRate = ((Integer) objValue).intValue();
             try {
                 android.provider.Settings.Secure.putInt(getContentResolver(),
                         TTS_DEFAULT_RATE, mDefaultRate);
@@ -458,8 +489,21 @@
             } catch (NumberFormatException e) {
                 Log.e(TAG, "could not persist default TTS rate setting", e);
             }
+        } else if (KEY_HIGHER_RATE_SWITCH.equals(preference.getKey())) {
+            // Adjust range of speech rate depending on switch setting.
+            mHigherRateSwitch = ((Boolean) objValue).booleanValue();
+            try {
+              android.provider.Settings.Secure.putInt(getContentResolver(),
+                  TTS_DEFAULT_HIGHER_SPEECH_RATE_ENABLED, mHigherRateSwitch ? 1 : 0);
+              if (mHigherRateSwitch) {
+                mDefaultRatePref.setMax(MAX_HIGHER_SPEECH_RATE);
+              } else {
+                mDefaultRatePref.setMax(MAX_SPEECH_RATE);
+              }
+            } catch (NumberFormatException e) {
+              Log.e(TAG, "could not persist default higher speech rate setting", e);
+            }
         }
-
         return true;
     }
 
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index bf03ff9..c9cdeb8 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -27,6 +27,7 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.SharedPreferences;
+import android.content.pm.ResolveInfo;
 import android.content.pm.UserInfo;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
@@ -42,6 +43,7 @@
 import android.support.v14.preference.SwitchPreference;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.Preference.OnPreferenceClickListener;
+import android.support.v7.preference.PreferenceCategory;
 import android.support.v7.preference.PreferenceGroup;
 import android.support.v7.preference.PreferenceScreen;
 import android.util.Log;
@@ -102,6 +104,9 @@
     private static final String KEY_USER_ME = "user_me";
     private static final String KEY_ADD_USER = "user_add";
     private static final String KEY_EMERGENCY_INFO = "emergency_info";
+    private static final String KEY_LOCK_SCREEN_SETTINGS = "lock_screen_settings";
+
+    private static final String ACTION_EDIT_EMERGENCY_INFO = "android.settings.EDIT_EMERGENGY_INFO";
 
     private static final int MENU_REMOVE_USER = Menu.FIRST;
 
@@ -232,7 +237,14 @@
         mLockScreenSettings = (PreferenceGroup) findPreference("lock_screen_settings");
         mAddUserWhenLocked = (RestrictedSwitchPreference) findPreference("add_users_when_locked");
         mEmergencyInfoPreference = findPreference(KEY_EMERGENCY_INFO);
-        mEmergencyInfoPreference.setOnPreferenceClickListener(this);
+        if(emergencyInfoActivityPresent()) {
+            mEmergencyInfoPreference.setOnPreferenceClickListener(this);
+        } else {
+            // Remove this view if the emergency info package is not found.
+            PreferenceCategory lockScreenSettingsCategory =
+                    (PreferenceCategory) findPreference(KEY_LOCK_SCREEN_SETTINGS);
+            lockScreenSettingsCategory.removePreference(mEmergencyInfoPreference);
+        }
         loadProfile();
         setHasOptionsMenu(true);
         IntentFilter filter = new IntentFilter(Intent.ACTION_USER_REMOVED);
@@ -602,6 +614,15 @@
         }
     }
 
+    private boolean emergencyInfoActivityPresent() {
+        Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO).setPackage("com.android.emergency");
+        List<ResolveInfo> infos = getContext().getPackageManager().queryIntentActivities(intent, 0);
+        if (infos == null || infos.isEmpty()) {
+            return false;
+        }
+        return true;
+    }
+
     private void removeUserNow() {
         if (mRemovingUserId == UserHandle.myUserId()) {
             removeThisUser();
@@ -922,7 +943,7 @@
                 onAddUserClicked(USER_TYPE_USER);
             }
         } else if (pref == mEmergencyInfoPreference) {
-            Intent intent = new Intent("com.android.emergency.EDIT_EMERGENGY_INFO");
+            Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO);
             startActivity(intent);
         }
         return false;
diff --git a/src/com/android/settings/utils/ProfileSettingsPreferenceFragment.java b/src/com/android/settings/utils/ProfileSettingsPreferenceFragment.java
new file mode 100644
index 0000000..e1c4d28
--- /dev/null
+++ b/src/com/android/settings/utils/ProfileSettingsPreferenceFragment.java
@@ -0,0 +1,74 @@
+/*
+ * 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.utils;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.Spinner;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settingslib.drawer.UserAdapter;
+
+/**
+ * Base fragment class for per profile settings.
+ */
+public abstract class ProfileSettingsPreferenceFragment extends SettingsPreferenceFragment {
+
+    @Override
+    public void onViewCreated(View view, Bundle savedInstanceState) {
+        super.onViewCreated(view, savedInstanceState);
+        final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
+        final UserAdapter profileSpinnerAdapter =
+                UserAdapter.createUserSpinnerAdapter(um, getActivity());
+        if (profileSpinnerAdapter != null) {
+            final Spinner spinner = (Spinner) setPinnedHeaderView(R.layout.spinner_view);
+            spinner.setAdapter(profileSpinnerAdapter);
+            spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+                @Override
+                public void onItemSelected(AdapterView<?> parent, View view, int position,
+                                           long id) {
+                    UserHandle selectedUser = profileSpinnerAdapter.getUserHandle(position);
+                    if (selectedUser.getIdentifier() != UserHandle.myUserId()) {
+                        Intent intent = new Intent(getIntentActionString());
+                        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
+                        getActivity().startActivityAsUser(intent, selectedUser);
+                        // Go back to default selection, which is the first one
+                        spinner.setSelection(0);
+                    }
+                }
+
+                @Override
+                public void onNothingSelected(AdapterView<?> parent) {
+                    // Nothing to do
+                }
+            });
+        }
+    }
+
+    /**
+     * @return intent action string that will bring user to this fragment.
+     */
+    protected abstract String getIntentActionString();
+
+}
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 335c40b..3bb1473 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -100,14 +100,14 @@
     public static final int WIFI_EAP_METHOD_AKA_PRIME  = 6;
 
     /* These values come from "wifi_peap_phase2_entries" resource array */
-    public static final int WIFI_PEAP_PHASE2_NONE 	    = 0;
-    public static final int WIFI_PEAP_PHASE2_MSCHAPV2 	= 1;
+    public static final int WIFI_PEAP_PHASE2_NONE       = 0;
+    public static final int WIFI_PEAP_PHASE2_MSCHAPV2   = 1;
     public static final int WIFI_PEAP_PHASE2_GTC        = 2;
 
     /* Phase2 methods supported by PEAP are limited */
-    private final ArrayAdapter<String> PHASE2_PEAP_ADAPTER;
+    private final ArrayAdapter<String> mPhase2PeapAdapter;
     /* Full list of phase2 methods */
-    private final ArrayAdapter<String> PHASE2_FULL_ADAPTER;
+    private final ArrayAdapter<String> mPhase2FullAdapter;
 
     private final Handler mTextViewChangedHandler;
 
@@ -115,16 +115,20 @@
     private int mAccessPointSecurity;
     private TextView mPasswordView;
 
-    private String unspecifiedCert = "unspecified";
-    private static final int unspecifiedCertIndex = 0;
-    private String multipleCertSet = "multipleCert";
-    private static final int multipleCertSetIndex = 1;
+    private String mUnspecifiedCertString;
+    private String mMultipleCertSetString;
+    private static final int UNSPECIFIED_CERT_INDEX = 0;
+    private static final int NO_CERT_INDEX = 1;
+    private static final int MULTIPLE_CERT_SET_INDEX = 2;
+
+    private String mDoNotProvideEapUserCertString;
+    private String mDoNotValidateEapServerString;
 
     private Spinner mSecuritySpinner;
     private Spinner mEapMethodSpinner;
     private Spinner mEapCaCertSpinner;
     private Spinner mPhase2Spinner;
-    // Associated with mPhase2Spinner, one of PHASE2_FULL_ADAPTER or PHASE2_PEAP_ADAPTER
+    // Associated with mPhase2Spinner, one of mPhase2FullAdapter or mPhase2PeapAdapter
     private ArrayAdapter<String> mPhase2Adapter;
     private Spinner mEapUserCertSpinner;
     private TextView mEapIdentityView;
@@ -171,18 +175,23 @@
         final Resources res = mContext.getResources();
 
         mLevels = res.getStringArray(R.array.wifi_signal);
-        PHASE2_PEAP_ADAPTER = new ArrayAdapter<String>(
+        mPhase2PeapAdapter = new ArrayAdapter<String>(
             mContext, android.R.layout.simple_spinner_item,
             res.getStringArray(R.array.wifi_peap_phase2_entries));
-        PHASE2_PEAP_ADAPTER.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+        mPhase2PeapAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
 
-        PHASE2_FULL_ADAPTER = new ArrayAdapter<String>(
+        mPhase2FullAdapter = new ArrayAdapter<String>(
                 mContext, android.R.layout.simple_spinner_item,
                 res.getStringArray(R.array.wifi_phase2_entries));
-        PHASE2_FULL_ADAPTER.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+        mPhase2FullAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
 
-        unspecifiedCert = mContext.getString(R.string.wifi_unspecified);
-        multipleCertSet = mContext.getString(R.string.wifi_multiple_cert_added);
+        mUnspecifiedCertString = mContext.getString(R.string.wifi_unspecified);
+        mMultipleCertSetString = mContext.getString(R.string.wifi_multiple_cert_added);
+        mDoNotProvideEapUserCertString =
+            mContext.getString(R.string.wifi_do_not_provide_eap_user_cert);
+        mDoNotValidateEapServerString =
+            mContext.getString(R.string.wifi_do_not_validate_eap_server);
+
         mIpSettingsSpinner = (Spinner) mView.findViewById(R.id.ip_settings);
         mIpSettingsSpinner.setOnItemSelectedListener(this);
         mProxySettingsSpinner = (Spinner) mView.findViewById(R.id.proxy_settings);
@@ -201,10 +210,9 @@
             showIpConfigFields();
             showProxyFields();
             mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
-            ((CheckBox)mView.findViewById(R.id.wifi_advanced_togglebox))
+            ((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox))
                     .setOnCheckedChangeListener(this);
 
-
             mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
         } else {
             mConfigUi.setTitle(mAccessPoint.getSsid());
@@ -221,7 +229,7 @@
                     StaticIpConfiguration staticConfig = config.getStaticIpConfiguration();
                     if (staticConfig != null && staticConfig.ipAddress != null) {
                         addRow(group, R.string.wifi_ip_address,
-                           staticConfig.ipAddress.getAddress().getHostAddress());
+                                staticConfig.ipAddress.getAddress().getHostAddress());
                     }
                 } else {
                     mIpSettingsSpinner.setSelection(DHCP);
@@ -242,8 +250,9 @@
                     mProxySettingsSpinner.setSelection(PROXY_NONE);
                 }
                 if (config != null && config.isPasspoint()) {
-                    addRow(group, R.string.passpoint_label, String.format(
-                        mContext.getString(R.string.passpoint_content), config.providerFriendlyName));
+                    addRow(group, R.string.passpoint_label,
+                            String.format(mContext.getString(R.string.passpoint_content),
+                            config.providerFriendlyName));
                 }
             }
 
@@ -253,10 +262,10 @@
                 showIpConfigFields();
                 showProxyFields();
                 mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
-                ((CheckBox)mView.findViewById(R.id.wifi_advanced_togglebox))
-                    .setOnCheckedChangeListener(this);
+                ((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox))
+                        .setOnCheckedChangeListener(this);
                 if (showAdvancedFields) {
-                    ((CheckBox)mView.findViewById(R.id.wifi_advanced_togglebox)).setChecked(true);
+                    ((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox)).setChecked(true);
                     mView.findViewById(R.id.wifi_advanced_fields).setVisibility(View.VISIBLE);
                 }
             }
@@ -340,7 +349,7 @@
         group.addView(row);
     }
 
-    private String getSignalString(){
+    private String getSignalString() {
         final int level = mAccessPoint.getLevel();
 
         return (level > -1 && level < mLevels.length) ? mLevels[level] : null;
@@ -372,27 +381,46 @@
         boolean enabled = false;
         boolean passwordInvalid = false;
 
-        if (mPasswordView != null &&
-                ((mAccessPointSecurity == AccessPoint.SECURITY_WEP && mPasswordView.length() == 0) ||
-                        (mAccessPointSecurity == AccessPoint.SECURITY_PSK && mPasswordView.length() < 8))) {
+        if (mPasswordView != null
+                && ((mAccessPointSecurity == AccessPoint.SECURITY_WEP
+                        && mPasswordView.length() == 0)
+                    || (mAccessPointSecurity == AccessPoint.SECURITY_PSK
+                           && mPasswordView.length() < 8))) {
             passwordInvalid = true;
         }
 
-        if ((mSsidView != null && mSsidView.length() == 0) ||
-                ((mAccessPoint == null || !mAccessPoint.isSaved()) &&
-                        passwordInvalid)) {
+        if ((mSsidView != null && mSsidView.length() == 0)
+                || ((mAccessPoint == null || !mAccessPoint.isSaved()) && passwordInvalid)) {
             enabled = false;
         } else {
             enabled = ipAndProxyFieldsAreValid();
         }
-        if (mEapCaCertSpinner != null &&
-                mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE &&
-                ((String)mEapCaCertSpinner.getSelectedItem()).equals(unspecifiedCert)) {
+        if (mEapCaCertSpinner != null
+                && mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE
+                && ((String) mEapCaCertSpinner.getSelectedItem()).equals(mUnspecifiedCertString)) {
+            enabled = false;
+        }
+        if (mEapUserCertSpinner != null
+                && mView.findViewById(R.id.l_user_cert).getVisibility() != View.GONE
+                && ((String) mEapUserCertSpinner.getSelectedItem())
+                       .equals(mUnspecifiedCertString)) {
             enabled = false;
         }
         return enabled;
     }
 
+    void showWarningMessageIfAppropriate() {
+        mView.findViewById(R.id.no_ca_cert_warning).setVisibility(View.GONE);
+        if (mEapCaCertSpinner != null
+                && mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE
+                && ((String) mEapCaCertSpinner.getSelectedItem())
+                       .equals(mDoNotValidateEapServerString)) {
+            // Display warning if user chooses not to validate the EAP server with a user-supplied
+            // CA certificate in an EAP network configuration.
+            mView.findViewById(R.id.no_ca_cert_warning).setVisibility(View.VISIBLE);
+        }
+    }
+
     /* package */ WifiConfiguration getConfig() {
         if (mMode == WifiConfigUiBase.MODE_VIEW) {
             return null;
@@ -427,8 +455,8 @@
                     int length = mPasswordView.length();
                     String password = mPasswordView.getText().toString();
                     // WEP-40, WEP-104, and 256-bit WEP (WEP-232?)
-                    if ((length == 10 || length == 26 || length == 58) &&
-                            password.matches("[0-9A-Fa-f]*")) {
+                    if ((length == 10 || length == 26 || length == 58)
+                            && password.matches("[0-9A-Fa-f]*")) {
                         config.wepKeys[0] = password;
                     } else {
                         config.wepKeys[0] = '"' + password + '"';
@@ -458,7 +486,7 @@
                 switch (eapMethod) {
                     case Eap.PEAP:
                         // PEAP supports limited phase2 values
-                        // Map the index from the PHASE2_PEAP_ADAPTER to the one used
+                        // Map the index from the mPhase2PeapAdapter to the one used
                         // by the API which has the full list of PEAP methods.
                         switch(phase2Method) {
                             case WIFI_PEAP_PHASE2_NONE:
@@ -476,27 +504,36 @@
                         }
                         break;
                     default:
-                        // The default index from PHASE2_FULL_ADAPTER maps to the API
+                        // The default index from mPhase2FullAdapter maps to the API
                         config.enterpriseConfig.setPhase2Method(phase2Method);
                         break;
                 }
                 String caCert = (String) mEapCaCertSpinner.getSelectedItem();
-                if (caCert.equals(unspecifiedCert)) {
+                if (caCert.equals(mUnspecifiedCertString)
+                        || caCert.equals(mDoNotValidateEapServerString)) {
+                    // Note: |caCert| should not be able to take the value |unspecifiedCert|,
+                    // since we prevent such configurations from being saved.
                     config.enterpriseConfig.setCaCertificateAliases(null);
-                } else if (caCert.equals(multipleCertSet)) {
+                } else if (caCert.equals(mMultipleCertSetString)) {
                     if (mAccessPoint != null) {
                         if (!mAccessPoint.isSaved()) {
                             Log.e(TAG, "Multiple certs can only be set when editing saved network");
                         }
                         config.enterpriseConfig.setCaCertificateAliases(
-                                mAccessPoint.getConfig().enterpriseConfig.getCaCertificateAliases());
+                                mAccessPoint.getConfig().enterpriseConfig
+                                        .getCaCertificateAliases());
                     }
                 } else {
                     config.enterpriseConfig.setCaCertificateAliases(new String[] {caCert});
                 }
 
                 String clientCert = (String) mEapUserCertSpinner.getSelectedItem();
-                if (clientCert.equals(unspecifiedCert)) clientCert = "";
+                if (clientCert.equals(mUnspecifiedCertString)
+                        || clientCert.equals(mDoNotProvideEapUserCertString)) {
+                    // Note: |clientCert| should not be able to take the value |unspecifiedCert|,
+                    // since we prevent such configurations from being saved.
+                    clientCert = "";
+                }
                 config.enterpriseConfig.setClientCertificateAlias(clientCert);
                 if (eapMethod == Eap.SIM || eapMethod == Eap.AKA || eapMethod == Eap.AKA_PRIME) {
                     config.enterpriseConfig.setIdentity("");
@@ -533,9 +570,11 @@
     }
 
     private boolean ipAndProxyFieldsAreValid() {
-        mIpAssignment = (mIpSettingsSpinner != null &&
-                mIpSettingsSpinner.getSelectedItemPosition() == STATIC_IP) ?
-                IpAssignment.STATIC : IpAssignment.DHCP;
+        mIpAssignment =
+                (mIpSettingsSpinner != null
+                    && mIpSettingsSpinner.getSelectedItemPosition() == STATIC_IP)
+                ? IpAssignment.STATIC
+                : IpAssignment.DHCP;
 
         if (mIpAssignment == IpAssignment.STATIC) {
             mStaticIpConfiguration = new StaticIpConfiguration();
@@ -584,7 +623,7 @@
     private Inet4Address getIPv4Address(String text) {
         try {
             return (Inet4Address) NetworkUtils.numericToInetAddress(text);
-        } catch (IllegalArgumentException|ClassCastException e) {
+        } catch (IllegalArgumentException | ClassCastException e) {
             return null;
         }
     }
@@ -619,7 +658,7 @@
                 //Extract a default gateway from IP address
                 InetAddress netPart = NetworkUtils.getNetworkPart(inetAddr, networkPrefixLength);
                 byte[] addr = netPart.getAddress();
-                addr[addr.length-1] = 1;
+                addr[addr.length - 1] = 1;
                 mGatewayView.setText(InetAddress.getByAddress(addr).getHostAddress());
             } catch (RuntimeException ee) {
             } catch (java.net.UnknownHostException u) {
@@ -700,11 +739,14 @@
             mEapCaCertSpinner = (Spinner) mView.findViewById(R.id.ca_cert);
             mEapCaCertSpinner.setOnItemSelectedListener(this);
             mEapUserCertSpinner = (Spinner) mView.findViewById(R.id.user_cert);
+            mEapUserCertSpinner.setOnItemSelectedListener(this);
             mEapIdentityView = (TextView) mView.findViewById(R.id.identity);
             mEapAnonymousView = (TextView) mView.findViewById(R.id.anonymous);
 
-            loadCertificates(mEapCaCertSpinner, Credentials.CA_CERTIFICATE, false);
-            loadCertificates(mEapUserCertSpinner, Credentials.USER_PRIVATE_KEY, false);
+            loadCertificates(mEapCaCertSpinner, Credentials.CA_CERTIFICATE, false,
+                    mDoNotValidateEapServerString);
+            loadCertificates(mEapUserCertSpinner, Credentials.USER_PRIVATE_KEY, false,
+                    mDoNotProvideEapUserCertString);
 
             // Modifying an existing network
             if (mAccessPoint != null && mAccessPoint.isSaved()) {
@@ -736,14 +778,14 @@
                 }
                 String[] caCerts = enterpriseConfig.getCaCertificateAliases();
                 if (caCerts == null) {
-                    setSelection(mEapCaCertSpinner, unspecifiedCert);
+                    setSelection(mEapCaCertSpinner, mUnspecifiedCertString);
                 } else if (caCerts.length == 1) {
                     setSelection(mEapCaCertSpinner, caCerts[0]);
                 } else {
                     // Reload the cert spinner with an extra "multiple certificates added" item
                     loadCertificates(mEapCaCertSpinner,
-                            Credentials.CA_CERTIFICATE, true);
-                    mEapCaCertSpinner.setSelection(multipleCertSetIndex);
+                            Credentials.CA_CERTIFICATE, true, mDoNotValidateEapServerString);
+                    mEapCaCertSpinner.setSelection(MULTIPLE_CERT_SET_INDEX);
                 }
                 setSelection(mEapUserCertSpinner, enterpriseConfig.getClientCertificateAlias());
                 mEapIdentityView.setText(enterpriseConfig.getIdentity());
@@ -804,8 +846,8 @@
                 break;
             case WIFI_EAP_METHOD_PEAP:
                 // Reset adapter if needed
-                if (mPhase2Adapter != PHASE2_PEAP_ADAPTER) {
-                    mPhase2Adapter = PHASE2_PEAP_ADAPTER;
+                if (mPhase2Adapter != mPhase2PeapAdapter) {
+                    mPhase2Adapter = mPhase2PeapAdapter;
                     mPhase2Spinner.setAdapter(mPhase2Adapter);
                 }
                 mView.findViewById(R.id.l_phase2).setVisibility(View.VISIBLE);
@@ -814,8 +856,8 @@
                 break;
             case WIFI_EAP_METHOD_TTLS:
                 // Reset adapter if needed
-                if (mPhase2Adapter != PHASE2_FULL_ADAPTER) {
-                    mPhase2Adapter = PHASE2_FULL_ADAPTER;
+                if (mPhase2Adapter != mPhase2FullAdapter) {
+                    mPhase2Adapter = mPhase2FullAdapter;
                     mPhase2Spinner.setAdapter(mPhase2Adapter);
                 }
                 mView.findViewById(R.id.l_phase2).setVisibility(View.VISIBLE);
@@ -847,12 +889,12 @@
 
     private void setCaCertInvisible() {
         mView.findViewById(R.id.l_ca_cert).setVisibility(View.GONE);
-        mEapCaCertSpinner.setSelection(unspecifiedCertIndex);
+        mEapCaCertSpinner.setSelection(UNSPECIFIED_CERT_INDEX);
     }
 
     private void setUserCertInvisible() {
         mView.findViewById(R.id.l_user_cert).setVisibility(View.GONE);
-        mEapUserCertSpinner.setSelection(unspecifiedCertIndex);
+        mEapUserCertSpinner.setSelection(UNSPECIFIED_CERT_INDEX);
     }
 
     private void setAnonymousIdentInvisible() {
@@ -976,13 +1018,15 @@
         }
     }
 
-    private void loadCertificates(Spinner spinner, String prefix, boolean showMultipleCerts) {
+    private void loadCertificates(
+            Spinner spinner, String prefix, boolean showMultipleCerts, String noCertificateString) {
         final Context context = mConfigUi.getContext();
 
         ArrayList<String> certs = new ArrayList<String>();
-        certs.add(unspecifiedCert);
+        certs.add(UNSPECIFIED_CERT_INDEX, mUnspecifiedCertString);
+        certs.add(NO_CERT_INDEX, noCertificateString);
         if (showMultipleCerts) {
-            certs.add(multipleCertSet);
+            certs.add(MULTIPLE_CERT_SET_INDEX, mMultipleCertSetString);
         }
         certs.addAll(
                 Arrays.asList(KeyStore.getInstance().list(prefix, android.os.Process.WIFI_UID)));
@@ -1056,12 +1100,11 @@
     public void onCheckedChanged(CompoundButton view, boolean isChecked) {
         if (view.getId() == R.id.show_password) {
             int pos = mPasswordView.getSelectionEnd();
-            mPasswordView.setInputType(
-                    InputType.TYPE_CLASS_TEXT | (isChecked ?
-                            InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD :
-                                InputType.TYPE_TEXT_VARIATION_PASSWORD));
+            mPasswordView.setInputType(InputType.TYPE_CLASS_TEXT
+                    | (isChecked ? InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
+                                 : InputType.TYPE_TEXT_VARIATION_PASSWORD));
             if (pos >= 0) {
-                ((EditText)mPasswordView).setSelection(pos);
+                ((EditText) mPasswordView).setSelection(pos);
             }
         } else if (view.getId() == R.id.wifi_advanced_togglebox) {
             if (isChecked) {
@@ -1084,6 +1127,7 @@
         } else {
             showIpConfigFields();
         }
+        showWarningMessageIfAppropriate();
         enableSubmitIfAppropriate();
     }
 
@@ -1097,11 +1141,10 @@
      */
     public void updatePassword() {
         TextView passwdView = (TextView) mView.findViewById(R.id.password);
-        passwdView.setInputType(
-                InputType.TYPE_CLASS_TEXT |
-                (((CheckBox) mView.findViewById(R.id.show_password)).isChecked() ?
-                InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD :
-                InputType.TYPE_TEXT_VARIATION_PASSWORD));
+        passwdView.setInputType(InputType.TYPE_CLASS_TEXT
+                | (((CheckBox) mView.findViewById(R.id.show_password)).isChecked()
+                   ? InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
+                   : InputType.TYPE_TEXT_VARIATION_PASSWORD));
     }
 
     public AccessPoint getAccessPoint() {