Merge "Fix sensitive labels for font size settings." into nyc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 32ec381..49c6790 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -825,11 +825,14 @@
                 android:value="30" />
             <meta-data android:name="com.android.settings.title"
                 android:resource="@string/zen_mode_automation_suggestion_title" />
+            <meta-data android:name="com.android.settings.summary"
+                android:resource="@string/zen_mode_automation_suggestion_summary" />
         </activity>
 
         <activity android:name="Settings$WallpaperSuggestionActivity"
                 android:label="@string/wallpaper_settings_title"
                 android:exported="true"
+                android:icon="@drawable/ic_wallpaper"
                 android:taskAffinity="">
             <intent-filter android:priority="1">
                 <action android:name="android.intent.action.MAIN" />
@@ -839,6 +842,8 @@
                 android:value="com.android.settings.WallpaperTypeSettings" />
             <meta-data android:name="com.android.settings.title"
                 android:resource="@string/wallpaper_suggestion_title" />
+            <meta-data android:name="com.android.settings.summary"
+                android:resource="@string/wallpaper_suggestion_summary" />
         </activity>
 
         <activity android:name="Settings$ZenModeScheduleRuleSettingsActivity"
@@ -1553,6 +1558,8 @@
                 android:value="android.hardware.fingerprint" />
             <meta-data android:name="com.android.settings.title"
                 android:resource="@string/suggestion_additional_fingerprints" />
+            <meta-data android:name="com.android.settings.summary"
+                android:resource="@string/suggestion_additional_fingerprints_summary" />
         </activity>
 
         <activity android:name=".fingerprint.FingerprintSettings" android:exported="false"/>
@@ -2698,6 +2705,8 @@
                 android:value="10" />
             <meta-data android:name="com.android.settings.title"
                 android:resource="@string/wifi_calling_suggestion_title" />
+            <meta-data android:name="com.android.settings.summary"
+                android:resource="@string/wifi_calling_suggestion_summary" />
         </activity>
 
         <provider
diff --git a/res/drawable/ic_wallpaper.xml b/res/drawable/ic_wallpaper.xml
new file mode 100644
index 0000000..c46df83
--- /dev/null
+++ b/res/drawable/ic_wallpaper.xml
@@ -0,0 +1,25 @@
+<!--
+    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="24.0dp"
+        android:height="24.0dp"
+        android:viewportWidth="24.0"
+        android:viewportHeight="24.0"
+        android:tint="?android:attr/colorAccent">
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M4.0,4.0l7.0,0.0L11.0,2.0L4.0,2.0c-1.1,0.0 -2.0,0.9 -2.0,2.0l0.0,7.0l2.0,0.0L4.0,4.0zm6.0,9.0l-4.0,5.0l12.0,0.0l-3.0,-4.0 -2.03,2.71L10.0,13.0zm7.0,-4.5c0.0,-0.83 -0.67,-1.5 -1.5,-1.5S14.0,7.67 14.0,8.5s0.67,1.5 1.5,1.5S17.0,9.33 17.0,8.5zM20.0,2.0l-7.0,0.0l0.0,2.0l7.0,0.0l0.0,7.0l2.0,0.0L22.0,4.0c0.0,-1.1 -0.9,-2.0 -2.0,-2.0zm0.0,18.0l-7.0,0.0l0.0,2.0l7.0,0.0c1.1,0.0 2.0,-0.9 2.0,-2.0l0.0,-7.0l-2.0,0.0l0.0,7.0zM4.0,13.0L2.0,13.0l0.0,7.0c0.0,1.0 0.9,2.0 2.0,2.0l7.0,0.0l0.0,-2.0L4.0,20.0l0.0,-7.0z"/>
+</vector>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7e5a557..5f6327a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -162,19 +162,30 @@
     <!-- Description for the button that makes interface elements larger. [CHAR_LIMIT=NONE] -->
     <string name="font_size_make_larger_desc">Make larger</string>
 
-    <!-- Do not translate. label for font size preview.  Does not need to be translated. -->
+    <!-- Sample text for font size preview. -->
     <string name="font_size_preview_text">Servez à ce monsieur une bière et des kiwis.</string>
     <string name="font_size_preview_text_headline">Sample text</string>
-    <string name="font_size_preview_text_title">Twenty Thousand Leagues Under The Sea</string>
-    <string name="font_size_preview_text_subtitle">Chapter 23: The Coral Kingdom</string>
-    <string name="font_size_preview_text_body">
-    The next day I woke with my head singularly clear. To my great surprise, I was in my own room. My companions,
-    no doubt, had been reinstated in their cabin, without having perceived it any more than I. Of what had passed
-    during the night they were as ignorant as I was, and to penetrate this mystery I only reckoned upon the chances
-    of the future.\nI then thought of quitting my room. Was I free again or a prisoner? Quite free. I opened the door,
-    went to the half deck, went up the central stairs. The panels, shut the evening before, were open. I went on to
-    the platform.\nNed Land and Conseil waited there for me. I questioned them; they knew nothing. Lost in a heavy
-    sleep in which they had been totally unconscious, they had been astonished at finding themselves in their cabin.</string>
+    <string name="font_size_preview_text_title"
+            translation_description="Title text in sample text used to illustrate how the currently selected font size will appear to the user. NOTE: Translate manually. No not adopt any copyrighted material for translation.">
+        The Wonderful Wizard of Oz
+    </string>
+    <string name="font_size_preview_text_subtitle"
+            translation_description="Subtitle text in sample text used to illustrate how the currently selected font size will appear to the user. NOTE: Translate manually. No not adopt any copyrighted material for translation.">
+        Chapter 11: The Wonderful Emerald City of Oz</string>
+    <string name="font_size_preview_text_body"
+            translation_description="Text in sample text used to illustrate how the currently selected font size will appear to the user. NOTE: Translate manually. No not adopt any copyrighted material for translation.">
+        Even with eyes protected by the green spectacles Dorothy and her friends were at first dazzled by the brilliancy of the wonderful City.
+        The streets were lined with beautiful houses all built of green marble and studded everywhere with sparkling emeralds.
+        They walked over a pavement of the same green marble, and where the blocks were joined together were rows of emeralds, set closely, and glittering in the brighness of the sun.
+        The window panes were of green glass; even the sky above the City had a green tint, and the rays of the sun were green.
+        \n\nThere were many people, men, women and children, walking about, and these were all dressed in green clothes and had greenish skins.
+        They looked at Dorothy and her strangely assorted company with wondering eyes, and the children all ran away and hid behind their mothers when they saw the Lion; but no one spoke to them.
+        Many shops stood in the street, and Dorothy saw that everything in them was green.
+        Green candy and green pop-corn were offered for sale, as well as green shoes, green hats and green clothes of all sorts.
+        At one place a man was selling green lemonade, and when the children bought it Dorothy could see that they paid for it with green pennies.
+        \n\nThere seemed to be no horses nor animals of any kind; the men carried things around in little green carts, which they pushed before them.
+        Everyone seeemed happy and contented and prosperous.
+    </string>
     <!-- Button. Chosen when they want to save the chosen text size. -->
     <string name="font_size_save">OK</string>
 
@@ -1966,7 +1977,9 @@
     <!-- 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>
+    <string name="wifi_calling_suggestion_title">Turn on Wi-Fi Calling</string>
+    <!-- Summary of suggestion to turn on wifi calling [CHAR LIMIT=60] -->
+    <string name="wifi_calling_suggestion_summary">Use Wi-Fi instead of mobile network</string>
     <!-- WFC mode [CHAR LIMIT=30] -->
     <string name="wifi_calling_mode_title">Calling preference</string>
     <!-- WFC mode dialog [CHAR LIMIT=30] -->
@@ -2131,7 +2144,9 @@
     <!-- Wallpaper settings title [CHAR LIMIT=30] -->
     <string name="wallpaper_settings_title">Wallpaper</string>
     <!-- Wallpaper suggestion title [CHAR LIMIT=30] -->
-    <string name="wallpaper_suggestion_title">Set up wallpaper</string>
+    <string name="wallpaper_suggestion_title">Change wallpaper</string>
+    <!-- Wallpaper suggestion title [CHAR LIMIT=60] -->
+    <string name="wallpaper_suggestion_summary">Personalize your screen</string>
     <!-- Wallpaper settings fragment title [CHAR LIMIT=30] -->
     <string name="wallpaper_settings_fragment_title">Choose wallpaper from</string>
     <!-- Display settings screen, trigger for screen saver options -->
@@ -5866,7 +5881,10 @@
     <string name="zen_mode_automation_settings_title">Automatic rules</string>
 
     <!--  Do not disturb: Title for the zen mode automation option Suggestion. [CHAR LIMIT=30] -->
-    <string name="zen_mode_automation_suggestion_title">Set up Do Not Disturb Schedule</string>
+    <string name="zen_mode_automation_suggestion_title">Set Do Not Disturb Schedule</string>
+
+    <!--  Do not disturb: Summary for the zen mode automation option Suggestion. [CHAR LIMIT=30] -->
+    <string name="zen_mode_automation_suggestion_summary">Silence your device at certain times</string>
 
     <!--  Do not disturb: Zen mode option: Important interruptions [CHAR LIMIT=60] -->
     <string name="zen_mode_option_important_interruptions">Priority only</string>
@@ -5955,14 +5973,20 @@
     <string name="notification_importance_default">Normal: Silently show these notifications</string>
 
     <!-- [CHAR LIMIT=100] Notification Importance slider: high importance level description -->
-    <string name="notification_importance_high">High: Show at the top of the notifications list and make sound</string>
+    <string name="notification_importance_high">High: Show at the top of the notifications list and allow sound</string>
 
     <!-- [CHAR LIMIT=100] Notification Importance slider: max importance level description -->
-    <string name="notification_importance_max">Urgent: Peek onto the screen and make sound</string>
+    <string name="notification_importance_max">Urgent: Peek onto the screen and allow sound</string>
 
     <!-- [CHAR LIMIT=60] Notification importance reset button -->
     <string name="importance_reset">Reset</string>
 
+    <!-- [CHAR LIMIT=40] Notification importance title -->
+    <string name="show_silently">Show silently</string>
+
+    <!-- [CHAR LIMIT=180] Notification importance summary -->
+    <string name="show_silently_summary">Don\'t make sound, vibrate, or peek these notifications into view on the current screen.</string>
+
     <!-- Default Apps > Default notification assistant -->
     <string name="default_notification_assistant">Notification assistant</string>
 
@@ -7177,7 +7201,10 @@
     <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>
+    <string name="suggestion_additional_fingerprints">Add another fingerprint</string>
+
+    <!-- Summary for suggestion adding more fingerprints [CHAR LIMIT=60] -->
+    <string name="suggestion_additional_fingerprints_summary">Unlock with a different fingerprint</string>
 
     <!-- Summary of battery saver when on [CHAR LIMIT=NONE] -->
     <string name="battery_saver_on_summary">On / <xliff:g name="automatic_state" example="Never turn on automatically">%1$s</xliff:g></string>
diff --git a/res/xml/app_notification_settings.xml b/res/xml/app_notification_settings.xml
index 1a2584a..37c4426 100644
--- a/res/xml/app_notification_settings.xml
+++ b/res/xml/app_notification_settings.xml
@@ -19,31 +19,44 @@
         android:key="app_notification_settings">
 
     <!-- Importance -->
+    <!-- Block -->
+    <com.android.settingslib.RestrictedSwitchPreference
+            android:key="block"
+            android:title="@string/app_notification_block_title"
+            android:summary="@string/app_notification_block_summary"
+            android:order="2" />
+    <!-- Silent -->
+    <com.android.settingslib.RestrictedSwitchPreference
+            android:key="silent"
+            android:title="@string/show_silently"
+            android:summary="@string/show_silently_summary"
+            android:order="3" />
+    <!-- Slider -->
     <com.android.settingslib.RestrictedPreference
             android:key="importance_title"
             android:title="@string/notification_importance_title"
-            android:order="2" />
+            android:order="4"/>
     <com.android.settings.notification.ImportanceSeekBarPreference
             android:key="importance"
-            android:order="3"/>
+            android:order="5"/>
 
     <com.android.settings.applications.LayoutPreference
             android:key="importance_reset_button"
             android:layout="@layout/two_buttons_panel"
-            android:order="4" />
+            android:order="6" />
 
     <!-- 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" />
+            android:order="7" />
 
     <!-- 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" />
+            android:order="8" />
 
 </PreferenceScreen>
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 1720a6b..068d534 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -821,13 +821,15 @@
                 mBtHciSnoopLog.isChecked() ? 1 : 0);
     }
 
-    private void writeWebViewProviderOptions(Object newValue) {
+    private boolean writeWebViewProviderOptions(Object newValue) {
         try {
-            mWebViewUpdateService.changeProviderAndSetting(
+            String updatedProvider = mWebViewUpdateService.changeProviderAndSetting(
                     newValue == null ? "" : newValue.toString());
             updateWebViewProviderOptions();
+            return newValue != null && newValue.equals(updatedProvider);
         } catch(RemoteException e) {
         }
+        return false;
     }
 
     private void writeDebuggerOptions() {
@@ -1942,18 +1944,6 @@
         return false;
     }
 
-    private void enableAndSetWebViewPackage(String packageName) {
-        getActivity().getPackageManager().setApplicationEnabledSetting(packageName,
-                PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0);
-        mWebViewProvider.setValue(packageName);
-        writeWebViewProviderOptions(packageName);
-    }
-
-    private void showEnableWebViewProviderAlert(final String packageName) {
-        EnableWebViewProviderDialogFragment.newInstance(packageName).show(
-                getChildFragmentManager(), EnableWebViewProviderDialogFragment.TAG);
-    }
-
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
         if (HDCP_CHECKING_KEY.equals(preference.getKey())) {
@@ -1966,19 +1956,15 @@
                 Log.e(TAG, "Tried to set a null WebView provider");
                 return false;
             }
-            String newWebViewPackageName = (String) newValue;
-            if (isPackageEnabled(newWebViewPackageName)) {
-                writeWebViewProviderOptions(newValue);
+            if (writeWebViewProviderOptions(newValue)) {
                 return true;
+            } else {
+                // The user chose a package that became invalid since the list was last updated,
+                // show a Toast to explain the situation.
+                Toast toast = Toast.makeText(getActivity(),
+                        R.string.select_webview_provider_toast_text, Toast.LENGTH_SHORT);
+                toast.show();
             }
-            // Package is disabled or uninstalled, if it is simply disabled, check if the user wants
-            // to enable it
-            if (isPackageInstalled(getActivity(), newWebViewPackageName)) {
-                showEnableWebViewProviderAlert(newWebViewPackageName);
-                return false;
-            }
-            // Package has been uninstalled (could happen if the package was uninstalled between
-            // opening and closing the setting).
             return false;
         } else if (preference == mLogdSize) {
             writeLogdSizeOption(newValue);
@@ -2137,36 +2123,6 @@
         }
     }
 
-    public static class EnableWebViewProviderDialogFragment extends DialogFragment {
-        public static final String TAG = "EnableWebViewProviderDialogFragment";
-        private static final String PACKAGE_NAME_TAG = "packageName";
-
-        public static EnableWebViewProviderDialogFragment newInstance(String packageName) {
-            EnableWebViewProviderDialogFragment fragment
-                = new EnableWebViewProviderDialogFragment();
-            Bundle args = new Bundle();
-            args.putString(PACKAGE_NAME_TAG, packageName);
-            fragment.setArguments(args);
-            return fragment;
-        }
-
-        @Override
-        public Dialog onCreateDialog(Bundle savedInstanceState) {
-            final String packageName = getArguments().getString(PACKAGE_NAME_TAG);
-
-            return new AlertDialog.Builder(getActivity())
-                .setMessage(R.string.select_webview_provider_confirmation_text)
-                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
-                    public void onClick(DialogInterface dialog, int id) {
-                        ((DevelopmentSettings)getParentFragment()).enableAndSetWebViewPackage(
-                            packageName);
-                    }
-                })
-                .setNegativeButton(android.R.string.cancel, null)
-                .create();
-        }
-    }
-
 
     /**
      * For Search.
diff --git a/src/com/android/settings/DeviceAdminSettings.java b/src/com/android/settings/DeviceAdminSettings.java
index 3adce15..ed68119 100644
--- a/src/com/android/settings/DeviceAdminSettings.java
+++ b/src/com/android/settings/DeviceAdminSettings.java
@@ -18,6 +18,7 @@
 
 import android.app.Activity;
 import android.app.AlertDialog;
+import android.app.AppGlobals;
 import android.app.ListFragment;
 import android.app.admin.DeviceAdminInfo;
 import android.app.admin.DeviceAdminReceiver;
@@ -27,11 +28,15 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.content.pm.ActivityInfo;
+import android.content.pm.IPackageManager;
 import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.pm.ResolveInfo;
 import android.content.res.Resources;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
+import android.os.RemoteException;
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.util.Log;
@@ -356,7 +361,7 @@
                             resolveInfo.activityInfo.name);
             if (alreadyAddedComponents == null
                     || !alreadyAddedComponents.contains(riComponentName)) {
-                DeviceAdminInfo deviceAdminInfo =  createDeviceAdminInfo(resolveInfo);
+                DeviceAdminInfo deviceAdminInfo =  createDeviceAdminInfo(resolveInfo.activityInfo);
                 // add only visible ones (note: active admins are added regardless of visibility)
                 if (deviceAdminInfo != null && deviceAdminInfo.isVisible()) {
                     if (!deviceAdminInfo.getActivityInfo().applicationInfo.isInternal()) {
@@ -383,27 +388,31 @@
             final int profileId) {
         if (activeAdmins != null) {
             final PackageManager packageManager = getActivity().getPackageManager();
+            final IPackageManager iPackageManager = AppGlobals.getPackageManager();
             final int n = activeAdmins.size();
             for (int i = 0; i < n; ++i) {
-                ComponentName activeAdmin = activeAdmins.get(i);
-                List<ResolveInfo> resolved = packageManager.queryBroadcastReceiversAsUser(
-                        new Intent().setComponent(activeAdmin), PackageManager.GET_META_DATA
-                                | PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS, profileId);
-                if (resolved != null) {
-                    final int resolvedMax = resolved.size();
-                    for (int j = 0; j < resolvedMax; ++j) {
-                        DeviceAdminInfo deviceAdminInfo = createDeviceAdminInfo(resolved.get(j));
-                        if (deviceAdminInfo != null) {
-                            // Don't do the applicationInfo.isInternal() check here; if an active
-                            // admin is already on SD card, just show it.
-                            DeviceAdminListItem item = new DeviceAdminListItem();
-                            item.info = deviceAdminInfo;
-                            item.name = deviceAdminInfo.loadLabel(packageManager).toString();
-                            item.active = true;
-                            mAdmins.add(item);
-                        }
-                    }
+                final ComponentName activeAdmin = activeAdmins.get(i);
+                final ActivityInfo ai;
+                try {
+                    ai = iPackageManager.getReceiverInfo(activeAdmin,
+                            PackageManager.GET_META_DATA |
+                            PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS |
+                            PackageManager.MATCH_ENCRYPTION_AWARE_AND_UNAWARE, profileId);
+                } catch (RemoteException e) {
+                    Log.w(TAG, "Unable to load component: " + activeAdmin);
+                    continue;
                 }
+                final DeviceAdminInfo deviceAdminInfo = createDeviceAdminInfo(ai);
+                if (deviceAdminInfo == null) {
+                    continue;
+                }
+                // Don't do the applicationInfo.isInternal() check here; if an active
+                // admin is already on SD card, just show it.
+                final DeviceAdminListItem item = new DeviceAdminListItem();
+                item.info = deviceAdminInfo;
+                item.name = deviceAdminInfo.loadLabel(packageManager).toString();
+                item.active = true;
+                mAdmins.add(item);
             }
         }
     }
@@ -412,16 +421,14 @@
      * Creates a device admin info object for the resolved intent that points to the component of
      * the device admin.
      *
-     * @param resolved resolved intent.
+     * @param ai ActivityInfo for the admin component.
      * @return new {@link DeviceAdminInfo} object or null if there was an error.
      */
-    private DeviceAdminInfo createDeviceAdminInfo(ResolveInfo resolved) {
+    private DeviceAdminInfo createDeviceAdminInfo(ActivityInfo ai) {
         try {
-            return new DeviceAdminInfo(getActivity(), resolved);
-        } catch (XmlPullParserException e) {
-            Log.w(TAG, "Skipping " + resolved.activityInfo, e);
-        } catch (IOException e) {
-            Log.w(TAG, "Skipping " + resolved.activityInfo, e);
+            return new DeviceAdminInfo(getActivity(), ai);
+        } catch (XmlPullParserException|IOException e) {
+            Log.w(TAG, "Skipping " + ai, e);
         }
         return null;
     }
diff --git a/src/com/android/settings/UserCredentialsSettings.java b/src/com/android/settings/UserCredentialsSettings.java
index 41bcf43..e688450 100644
--- a/src/com/android/settings/UserCredentialsSettings.java
+++ b/src/com/android/settings/UserCredentialsSettings.java
@@ -27,8 +27,13 @@
 import android.os.Bundle;
 import android.os.Parcel;
 import android.os.Parcelable;
+import android.os.RemoteException;
 import android.security.Credentials;
+import android.security.IKeyChainService;
+import android.security.KeyChain;
+import android.security.KeyChain.KeyChainConnection;
 import android.security.KeyStore;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -120,21 +125,49 @@
                     .setNegativeButton(R.string.trusted_credentials_remove_label,
                             new DialogInterface.OnClickListener() {
                                 @Override public void onClick(DialogInterface dialog, int id) {
-                                    final KeyStore ks = KeyStore.getInstance();
-                                    Credentials.deleteAllTypesForAlias(ks, item.alias);
+                                    new RemoveCredentialsTask(getContext(), getTargetFragment())
+                                            .execute(item.alias);
                                     dialog.dismiss();
                                 }
                             })
                     .create();
         }
 
-        @Override
-        public void onDismiss(DialogInterface dialog) {
-            final Fragment target = getTargetFragment();
-            if (target instanceof UserCredentialsSettings) {
-                ((UserCredentialsSettings) target).refreshItems();
+        private class RemoveCredentialsTask extends AsyncTask<String, Void, Void> {
+            private Context context;
+            private Fragment targetFragment;
+
+            public RemoveCredentialsTask(Context context, Fragment targetFragment) {
+                this.context = context;
+                this.targetFragment = targetFragment;
             }
-            super.onDismiss(dialog);
+
+            @Override
+            protected Void doInBackground(String... aliases) {
+                try {
+                    final KeyChainConnection conn = KeyChain.bind(getContext());
+                    try {
+                        IKeyChainService keyChain = conn.getService();
+                        for (String alias : aliases) {
+                            keyChain.removeKeyPair(alias);
+                        }
+                    } catch (RemoteException e) {
+                        Log.w(TAG, "Removing credentials", e);
+                    } finally {
+                        conn.close();
+                    }
+                } catch (InterruptedException e) {
+                    Log.w(TAG, "Connecting to keychain", e);
+                }
+                return null;
+            }
+
+            @Override
+            protected void onPostExecute(Void result) {
+                if (targetFragment instanceof UserCredentialsSettings) {
+                    ((UserCredentialsSettings) targetFragment).refreshItems();
+                }
+            }
         }
     }
 
diff --git a/src/com/android/settings/applications/DefaultEmergencyPreference.java b/src/com/android/settings/applications/DefaultEmergencyPreference.java
index 2a37633..1d23263 100644
--- a/src/com/android/settings/applications/DefaultEmergencyPreference.java
+++ b/src/com/android/settings/applications/DefaultEmergencyPreference.java
@@ -111,11 +111,9 @@
                 continue;
             }
 
-            // Get earliest installed app, but prioritize system apps.
-            if (bestMatch == null
-                    || !isSystemApp(bestMatch) && isSystemApp(packageInfo)
-                    || isSystemApp(bestMatch) == isSystemApp(packageInfo)
-                    && bestMatch.firstInstallTime > packageInfo.firstInstallTime) {
+            // Get earliest installed system app.
+            if (isSystemApp(packageInfo) && (bestMatch == null ||
+                    bestMatch.firstInstallTime > packageInfo.firstInstallTime)) {
                 bestMatch = packageInfo;
             }
         }
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index a8f0fd0..0e47547 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -65,6 +65,7 @@
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
+import android.webkit.IWebViewUpdateService;
 import android.widget.Button;
 import android.widget.ImageView;
 import android.widget.TextView;
@@ -258,6 +259,16 @@
             enabled = false;
         }
 
+        try {
+            IWebViewUpdateService webviewUpdateService =
+                IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate"));
+            if (webviewUpdateService.isFallbackPackage(mAppEntry.info.packageName)) {
+                enabled = false;
+            }
+        } catch (RemoteException e) {
+            throw new RuntimeException(e);
+        }
+
         mUninstallButton.setEnabled(enabled);
         if (enabled) {
             // Register listener
diff --git a/src/com/android/settings/applications/ResetAppsHelper.java b/src/com/android/settings/applications/ResetAppsHelper.java
index 5d87204..ddcb244 100644
--- a/src/com/android/settings/applications/ResetAppsHelper.java
+++ b/src/com/android/settings/applications/ResetAppsHelper.java
@@ -30,6 +30,7 @@
 import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.os.UserHandle;
+import android.webkit.IWebViewUpdateService;
 
 import com.android.settings.R;
 
@@ -46,6 +47,7 @@
     private final PackageManager mPm;
     private final IPackageManager mIPm;
     private final INotificationManager mNm;
+    private final IWebViewUpdateService mWvus;
     private final NetworkPolicyManager mNpm;
     private final AppOpsManager mAom;
     private final Context mContext;
@@ -58,6 +60,7 @@
         mIPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
         mNm = INotificationManager.Stub.asInterface(
                 ServiceManager.getService(Context.NOTIFICATION_SERVICE));
+        mWvus = IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate"));
         mNpm = NetworkPolicyManager.from(context);
         mAom = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
     }
@@ -118,7 +121,8 @@
                     }
                     if (!app.enabled) {
                         if (mPm.getApplicationEnabledSetting(app.packageName)
-                                == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER) {
+                                == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER
+                                && !isNonEnableableFallback(app.packageName)) {
                             mPm.setApplicationEnabledSetting(app.packageName,
                                     PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
                                     PackageManager.DONT_KILL_APP);
@@ -142,4 +146,12 @@
             }
         });
     }
+
+    private boolean isNonEnableableFallback(String packageName) {
+        try {
+            return mWvus.isFallbackPackage(packageName);
+        } catch (RemoteException e) {
+            throw new RuntimeException(e);
+        }
+    }
 }
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 9aa14fc..7db915f 100644
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -496,8 +496,9 @@
 
         @Override
         public void setListening(boolean listening) {
+            BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter();
+            if (defaultAdapter == null) return;
             if (listening) {
-                BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter();
                 mEnabled = defaultAdapter.isEnabled();
                 mConnected =
                         defaultAdapter.getConnectionState() == BluetoothAdapter.STATE_CONNECTED;
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 8f30f59..f04cf2f 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -26,23 +26,15 @@
 import android.os.UserHandle;
 import android.provider.Settings;
 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;
-import android.support.v7.preference.PreferenceCategory;
 import android.util.ArrayMap;
 import android.util.Log;
 
-import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.MetricsProto.MetricsEvent;
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.AppHeader;
 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;
 
@@ -86,6 +78,8 @@
                 (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BYPASS_DND);
         mSensitive =
                 (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_SENSITIVE);
+        mBlock = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BLOCK);
+        mSilent = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_SILENT);
 
         mAppRow = mBackend.loadAppRow(mPm, mPkgInfo);
 
@@ -98,7 +92,7 @@
         rows.put(mAppRow.pkg, mAppRow);
         collectConfigActivities(rows);
 
-        setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance);
+        setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance, mAppRow.banned);
         setupPriorityPref(mAppRow.appBypassDnd);
         setupSensitivePref(mAppRow.appSensitive);
         updateDependents(mAppRow.appImportance);
@@ -111,9 +105,13 @@
         final boolean lockscreenNotificationsEnabled = getLockscreenNotificationsEnabled();
         final boolean allowPrivate = getLockscreenAllowPrivateNotifications();
 
-        setVisible(mPriority, checkCanBeVisible(Ranking.IMPORTANCE_DEFAULT, importance)
+        if (getPreferenceScreen().findPreference(mBlock.getKey()) != null) {
+            setVisible(mSilent, checkCanBeVisible(Ranking.IMPORTANCE_LOW, importance));
+            mSilent.setChecked(importance == Ranking.IMPORTANCE_DEFAULT);
+        }
+        setVisible(mPriority, checkCanBeVisible(Ranking.IMPORTANCE_LOW, importance)
                 && !mDndVisualEffectsSuppressed);
-        setVisible(mSensitive, checkCanBeVisible(Ranking.IMPORTANCE_LOW, importance)
+        setVisible(mSensitive, checkCanBeVisible(Ranking.IMPORTANCE_HIGH, importance)
                 && lockscreenSecure && lockscreenNotificationsEnabled && allowPrivate);
     }
 
@@ -121,7 +119,7 @@
         if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
             return true;
         }
-        return importance > minImportanceVisible;
+        return importance >= minImportanceVisible;
     }
 
     private boolean getLockscreenNotificationsEnabled() {
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index a58edf7..895d38d 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -46,12 +46,15 @@
 abstract public class NotificationSettingsBase extends SettingsPreferenceFragment {
     private static final String TAG = "NotifiSettingsBase";
     private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+    private static final String TUNER_SETTING = "show_importance_slider";
 
     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 static final String KEY_BLOCK = "block";
+    protected static final String KEY_SILENT = "silent";
 
     protected PackageManager mPm;
     protected final NotificationBackend mBackend = new NotificationBackend();
@@ -66,7 +69,10 @@
     protected LayoutPreference mImportanceReset;
     protected RestrictedSwitchPreference mPriority;
     protected RestrictedSwitchPreference mSensitive;
+    protected RestrictedSwitchPreference mBlock;
+    protected RestrictedSwitchPreference mSilent;
     protected EnforcedAdmin mSuspendedAppsAdmin;
+    protected boolean mShowSlider = false;
 
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
@@ -119,6 +125,7 @@
 
         mSuspendedAppsAdmin = RestrictedLockUtils.checkIfApplicationIsSuspended(
                 mContext, mPkg, mUserId);
+        mShowSlider = Settings.Secure.getInt(getContentResolver(), TUNER_SETTING, 0) == 1;
     }
 
     @Override
@@ -143,54 +150,94 @@
         if (mImportanceTitle != null) {
             mImportanceTitle.setDisabledByAdmin(mSuspendedAppsAdmin);
         }
+        if (mBlock != null) {
+            mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
+        }
+        if (mSilent != null) {
+            mSilent.setDisabledByAdmin(mSuspendedAppsAdmin);
+        }
     }
 
-    protected void setupImportancePrefs(boolean isSystemApp, int importance) {
-        mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
-        mImportanceTitle.setDisabledByAdmin(mSuspendedAppsAdmin);
-        if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
-            mImportance.setVisible(false);
-            mImportanceReset.setVisible(false);
-            mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
-        } else {
-            mImportanceTitle.setOnPreferenceClickListener(null);
-        }
-
-        mImportanceTitle.setSummary(getProgressSummary(importance));
-        mImportance.setSystemApp(isSystemApp);
-        mImportance.setMinimumProgress(
-                isSystemApp ? Ranking.IMPORTANCE_LOW : Ranking.IMPORTANCE_NONE);
-        mImportance.setMax(Ranking.IMPORTANCE_MAX);
-        mImportance.setProgress(importance);
-        mImportance.setCallback(new ImportanceSeekBarPreference.Callback() {
-            @Override
-            public void onImportanceChanged(int progress) {
-                mBackend.setImportance(mPkg, mUid, 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) {
-                if (mSuspendedAppsAdmin != null) {
-                    RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
-                            getActivity(), mSuspendedAppsAdmin);
-                    return;
-                }
-
-                mBackend.setImportance(mPkg, mUid, Ranking.IMPORTANCE_UNSPECIFIED);
-                mImportanceReset.setVisible(false);
+    protected void setupImportancePrefs(boolean isSystemApp, int importance, boolean banned) {
+        if (mShowSlider) {
+            setVisible(mBlock, false);
+            setVisible(mSilent, false);
+            mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
+            mImportanceTitle.setDisabledByAdmin(mSuspendedAppsAdmin);
+            if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
                 mImportance.setVisible(false);
+                mImportanceReset.setVisible(false);
                 mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
-                mImportanceTitle.setSummary(getProgressSummary(Ranking.IMPORTANCE_UNSPECIFIED));
-                updateDependents(Ranking.IMPORTANCE_UNSPECIFIED);
+            } else {
+                mImportanceTitle.setOnPreferenceClickListener(null);
             }
-        });
-        mImportanceReset.findViewById(R.id.right_button).setVisibility(View.INVISIBLE);
+
+            mImportanceTitle.setSummary(getProgressSummary(importance));
+            mImportance.setSystemApp(isSystemApp);
+            mImportance.setMinimumProgress(
+                    isSystemApp ? Ranking.IMPORTANCE_LOW : Ranking.IMPORTANCE_NONE);
+            mImportance.setMax(Ranking.IMPORTANCE_MAX);
+            mImportance.setProgress(importance);
+            mImportance.setCallback(new ImportanceSeekBarPreference.Callback() {
+                @Override
+                public void onImportanceChanged(int progress) {
+                    mBackend.setImportance(mPkg, mUid, 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) {
+                    if (mSuspendedAppsAdmin != null) {
+                        RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
+                                getActivity(), mSuspendedAppsAdmin);
+                        return;
+                    }
+
+                    mBackend.setImportance(mPkg, mUid, 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);
+        } else {
+            setVisible(mImportance, false);
+            setVisible(mImportanceReset, false);
+            setVisible(mImportanceTitle, false);
+            boolean blocked = importance == Ranking.IMPORTANCE_NONE || banned;
+            mBlock.setChecked(blocked);
+            mBlock.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+                @Override
+                public boolean onPreferenceChange(Preference preference, Object newValue) {
+                    final boolean blocked = (Boolean) newValue;
+                    final int importance =
+                            blocked ? Ranking.IMPORTANCE_NONE :Ranking.IMPORTANCE_UNSPECIFIED;
+                    mBackend.setImportance(mPkgInfo.packageName, mUid, importance);
+                    updateDependents(importance);
+                    return true;
+                }
+            });
+
+            mSilent.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+                @Override
+                public boolean onPreferenceChange(Preference preference, Object newValue) {
+                    final boolean silenced = (Boolean) newValue;
+                    final int importance =
+                            silenced ? Ranking.IMPORTANCE_DEFAULT : Ranking.IMPORTANCE_UNSPECIFIED;
+                    mBackend.setImportance(mPkgInfo.packageName, mUid, importance);
+                    updateDependents(importance);
+                    return true;
+                }
+            });
+            updateDependents(banned ? Ranking.IMPORTANCE_NONE : importance);
+        }
     }
 
     private String getProgressSummary(int progress) {