Merge "New activity for handling dialogs of remote bugreports" into nyc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index edb63c1..ceea92e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2551,7 +2551,7 @@
             <meta-data android:name="com.android.settings.category"
                        android:value="com.android.settings.category.device" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                android:value="com.android.settings.applications.ManageApplications" />
+                android:value="com.android.settings.applications.NotificationApps" />
         </activity>
 
         <!-- Show application-level notification settings (app passed in as extras) -->
diff --git a/res/drawable/ic_info.xml b/res/drawable/ic_info_outline.xml
similarity index 100%
rename from res/drawable/ic_info.xml
rename to res/drawable/ic_info_outline.xml
diff --git a/res/layout/accessibility_settings_for_suw.xml b/res/layout/accessibility_settings_for_suw.xml
new file mode 100644
index 0000000..a02c516
--- /dev/null
+++ b/res/layout/accessibility_settings_for_suw.xml
@@ -0,0 +1,35 @@
+<?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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <FrameLayout
+        android:id="@+id/suw_main_content"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1" />
+
+    <com.android.setupwizardlib.view.NavigationBar
+        android:id="@+id/suw_navigation_bar"
+        style="@style/SuwNavBarTheme"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/suw_navbar_height" />
+
+</LinearLayout>
diff --git a/res/layout/admin_support_details_dialog.xml b/res/layout/admin_support_details_dialog.xml
index c796cc4..51e31b9 100644
--- a/res/layout/admin_support_details_dialog.xml
+++ b/res/layout/admin_support_details_dialog.xml
@@ -27,7 +27,7 @@
         <ImageView android:id="@+id/admin_support_icon"
                 android:layout_width="@dimen/admin_details_dialog_icon_size"
                 android:layout_height="@dimen/admin_details_dialog_icon_size"
-                android:src="@drawable/ic_settings_lock_outline"
+                android:src="@drawable/ic_info"
                 android:scaleType="fitCenter"
                 android:contentDescription="@null" />
         <TextView
diff --git a/res/layout/preference_user_delete_widget.xml b/res/layout/preference_user_delete_widget.xml
deleted file mode 100644
index 9c1ba72..0000000
--- a/res/layout/preference_user_delete_widget.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 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.
--->
-
-<!-- Used by UserPreference to show the trash icon -->
-<LinearLayout
-        xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="wrap_content"
-        android:layout_height="match_parent"
-        android:orientation="horizontal">
-    <View
-        android:id="@+id/divider_manage"
-        android:layout_width="2dip"
-        android:layout_height="match_parent"
-        android:layout_marginTop="5dip"
-        android:layout_marginBottom="5dip"
-        android:background="@android:drawable/divider_horizontal_dark" />
-    <ImageView
-        android:id="@+id/manage_user"
-        android:layout_width="wrap_content"
-        android:layout_height="fill_parent"
-        android:paddingStart="16dip"
-        android:paddingEnd="16dip"
-        android:src="@drawable/ic_sysbar_quicksettings"
-        android:contentDescription="@string/settings_label"
-        android:layout_gravity="center"
-        android:background="?android:attr/selectableItemBackground" />
-    <View
-        android:id="@+id/divider_delete"
-        android:layout_width="2dip"
-        android:layout_height="match_parent"
-        android:layout_marginTop="5dip"
-        android:layout_marginBottom="5dip"
-        android:background="@android:drawable/divider_horizontal_dark" />
-    <ImageView
-        android:id="@+id/trash_user"
-        android:layout_width="wrap_content"
-        android:layout_height="fill_parent"
-        android:paddingStart="16dip"
-        android:paddingEnd="16dip"
-        android:src="@drawable/ic_menu_delete"
-        android:contentDescription="@string/user_delete_user_description"
-        android:layout_gravity="center"
-        android:background="?android:attr/selectableItemBackground" />
-</LinearLayout>
diff --git a/res/layout/preference_volume_slider.xml b/res/layout/preference_volume_slider.xml
index d279eb6..c5c7818 100644
--- a/res/layout/preference_volume_slider.xml
+++ b/res/layout/preference_volume_slider.xml
@@ -30,14 +30,26 @@
         android:layout_marginTop="8dip"
         android:layout_marginBottom="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" />
+        <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+            <TextView android:id="@android:id/title"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:singleLine="true"
+                android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+                android:textColor="?android:attr/textColorPrimary"
+                android:ellipsize="marquee"
+                android:fadingEdge="horizontal" />
+            <!-- Preference should place its actual preference widget here. -->
+            <LinearLayout android:id="@android:id/widget_frame"
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:gravity="end|center_vertical"
+                android:paddingStart="16dp"
+                android:orientation="vertical" />
+        </LinearLayout>
 
         <FrameLayout
             android:layout_width="match_parent"
diff --git a/res/layout/printer_dropdown_item.xml b/res/layout/printer_dropdown_item.xml
index 1209aa6..1e3f1a8 100644
--- a/res/layout/printer_dropdown_item.xml
+++ b/res/layout/printer_dropdown_item.xml
@@ -84,7 +84,7 @@
         android:layout_gravity="center_vertical"
         android:paddingLeft="16dip"
         android:contentDescription="@string/printer_info_desc"
-        android:src="@drawable/ic_info"
+        android:src="@drawable/ic_info_outline"
         android:tint="?android:attr/colorControlNormal"
         android:tintMode="src_in"
         android:visibility="gone">
diff --git a/res/layout/redaction_interstitial.xml b/res/layout/redaction_interstitial.xml
index 06dc6aa..aafeb1b 100644
--- a/res/layout/redaction_interstitial.xml
+++ b/res/layout/redaction_interstitial.xml
@@ -65,4 +65,14 @@
 
     </RadioGroup>
 
+    <CheckBox
+            android:id="@+id/lockscreen_remote_input"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/redaction_vertical_margins"
+            android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
+            android:layout_marginEnd="?android:attr/listPreferredItemPaddingEnd"
+            android:text="@string/lockscreen_remote_input"
+            android:textAppearance="?android:attr/textAppearanceMedium" />
+
 </LinearLayout>
\ No newline at end of file
diff --git a/res/layout/restricted_dialog_singlechoice.xml b/res/layout/restricted_dialog_singlechoice.xml
index 0e0fe4c..f75493e 100644
--- a/res/layout/restricted_dialog_singlechoice.xml
+++ b/res/layout/restricted_dialog_singlechoice.xml
@@ -35,10 +35,10 @@
             android:ellipsize="marquee" />
     <ImageView
             android:id="@+id/restricted_lock_icon"
-            android:layout_width="@dimen/restricted_lock_icon_size"
-            android:layout_height="@dimen/restricted_lock_icon_size"
-            android:src="@drawable/ic_settings_lock_outline"
-            android:layout_marginLeft="@dimen/restricted_lock_icon_padding"
+            android:layout_width="@dimen/restricted_icon_size"
+            android:layout_height="@dimen/restricted_icon_size"
+            android:src="@drawable/ic_info"
+            android:layout_marginLeft="@dimen/restricted_icon_padding"
             android:baselineAlignBottom="true"
             android:scaleType="centerInside"
             android:visibility="gone" />
diff --git a/res/layout/restricted_preference_user_delete_widget.xml b/res/layout/restricted_preference_user_delete_widget.xml
new file mode 100644
index 0000000..7ffb0e4
--- /dev/null
+++ b/res/layout/restricted_preference_user_delete_widget.xml
@@ -0,0 +1,60 @@
+<?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.
+-->
+
+<!-- Used by UserPreference to show the trash icon -->
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+    <include layout="@layout/restricted_icon" />
+
+    <LinearLayout android:id="@+id/user_delete_widget"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:orientation="horizontal">
+        <View
+            android:id="@+id/divider_manage"
+            android:layout_width="2dip"
+            android:layout_height="match_parent"
+            android:layout_marginTop="5dip"
+            android:layout_marginBottom="5dip"
+            android:background="@android:drawable/divider_horizontal_dark" />
+        <ImageView
+            android:id="@+id/manage_user"
+            android:layout_width="wrap_content"
+            android:layout_height="fill_parent"
+            android:paddingStart="16dip"
+            android:paddingEnd="16dip"
+            android:src="@drawable/ic_sysbar_quicksettings"
+            android:contentDescription="@string/settings_label"
+            android:layout_gravity="center"
+            android:background="?android:attr/selectableItemBackground" />
+        <View
+            android:id="@+id/divider_delete"
+            android:layout_width="2dip"
+            android:layout_height="match_parent"
+            android:layout_marginTop="5dip"
+            android:layout_marginBottom="5dip"
+            android:background="@android:drawable/divider_horizontal_dark" />
+        <ImageView
+            android:id="@+id/trash_user"
+            android:layout_width="wrap_content"
+            android:layout_height="fill_parent"
+            android:paddingStart="16dip"
+            android:paddingEnd="16dip"
+            android:src="@drawable/ic_menu_delete"
+            android:contentDescription="@string/user_delete_user_description"
+            android:layout_gravity="center"
+            android:background="?android:attr/selectableItemBackground" />
+    </LinearLayout>
+</merge>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 25e35d0..f04224f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5974,7 +5974,7 @@
     <string name="notification_importance_default">Normal: Allow these notification to make sounds</string>
 
     <!-- [CHAR LIMIT=100] Notification Importance slider: high importance level description -->
-    <string name="notification_importance_high">High: Peek onto the screen and allow sound and allow sound</string>
+    <string name="notification_importance_high">High: Peek onto the screen and allow sound</string>
 
     <!-- [CHAR LIMIT=100] Notification Importance slider: max importance level description -->
     <string name="notification_importance_max">Urgent: Show at the top of the notifications list, peek onto the screen and allow sound</string>
@@ -6434,6 +6434,8 @@
    <string name="notifications_enabled">Normal</string>
    <!-- App notification summary with notifications disabled [CHAR LIMIT=40] -->
    <string name="notifications_disabled">Blocked</string>
+    <!-- App notification summary with notifications disabled [CHAR LIMIT=40] -->
+    <string name="notifications_silenced">Silenced</string>
    <!-- App notification summary with 2 items [CHAR LIMIT=15] -->
    <string name="notifications_two_items"><xliff:g id="notif_state" example="Priority">%1$s</xliff:g> / <xliff:g id="notif_state" example="Priority">%2$s</xliff:g></string>
    <!-- App notification summary with 3 items [CHAR LIMIT=15] -->
@@ -6476,6 +6478,14 @@
     <string name="filter_notif_blocked_apps">Blocked</string>
     <!-- Label for showing apps with domain URLs (data URI with http or https) in list [CHAR LIMIT=30] -->
     <string name="filter_with_domain_urls_apps">With domain URLs</string>
+    <!-- Label for showing apps with priority notifications in list [CHAR LIMIT=30] -->
+    <string name="filter_notif_priority_apps">Overrides Do Not Disturb</string>
+    <!-- Label for showing apps redacting sensitive notifications in list [CHAR LIMIT=30] -->
+    <string name="filter_notif_sensitive_apps">No sensitive content on lock screen</string>
+    <!-- Label for showing apps hiding notifications from lockscreen [CHAR LIMIT=30] -->
+    <string name="filter_notif_hide_notifications_apps">Never shown on lock screen</string>
+    <!-- Filter label for apps that the user has silenced [CHAR LIMIT=40] -->
+    <string name="filter_notif_silent">Shown silently</string>
 
     <!-- Title for advanced application management settings [CHAR LIMIT=30] -->
     <string name="advanced_apps">Advanced</string>
@@ -6984,6 +6994,12 @@
     <!-- Summary of data usage [CHAR LIMIT=NONE] -->
     <string name="data_usage_summary_format"><xliff:g id="amount" example="50%">%1$s</xliff:g> of data used</string>
 
+    <!-- Summary of notifications [CHAR LIMIT=NONE] -->
+    <string name="notification_summary"><xliff:g id="count" example="24">%1$d</xliff:g> apps blocked from sending</string>
+
+    <!-- Summary of notifications when no apps are blocked [CHAR LIMIT=NONE] -->
+    <string name="notification_summary_none">All apps allowed to send</string>
+
     <!-- Summary of apps [CHAR LIMIT=NONE] -->
     <string name="apps_summary"><xliff:g id="count" example="24">%1$d</xliff:g> apps installed</string>
     <!-- Example summary of apps used in Setup Wizard preview screen [CHAR LIMIT=NONE] -->
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 3f69a36..8dafd74 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -61,6 +61,7 @@
 import com.android.settings.applications.InstalledAppDetails;
 import com.android.settings.applications.ManageApplications;
 import com.android.settings.applications.ManageAssist;
+import com.android.settings.applications.NotificationApps;
 import com.android.settings.applications.ProcessStatsSummary;
 import com.android.settings.applications.ProcessStatsUi;
 import com.android.settings.applications.UsageAccessDetails;
@@ -259,6 +260,7 @@
             DisplaySettings.class.getName(),
             DeviceInfoSettings.class.getName(),
             ManageApplications.class.getName(),
+            NotificationApps.class.getName(),
             ManageAssist.class.getName(),
             ProcessStatsUi.class.getName(),
             NotificationStation.class.getName(),
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index e719291..5a76bf3 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -48,6 +48,8 @@
 import android.net.Uri;
 import android.os.BatteryManager;
 import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
 import android.os.IBinder;
 import android.os.INetworkManagementService;
 import android.os.RemoteException;
@@ -1045,10 +1047,18 @@
     }
 
     public static List<String> getNonIndexable(int xml, Context context) {
-        List<String> ret = new ArrayList<>();
-        PreferenceManager manager = new PreferenceManager(context);
-        PreferenceScreen screen = manager.inflateFromResource(context, xml, null);
-        checkPrefs(screen, ret);
+        HandlerThread thread = new HandlerThread("Index_" + xml);
+        thread.start();
+        final List<String> ret = new ArrayList<>();
+        new Handler(thread.getLooper()).post(new Runnable() {
+            @Override
+            public void run() {
+                PreferenceManager manager = new PreferenceManager(context);
+                PreferenceScreen screen = manager.inflateFromResource(context, xml, null);
+                checkPrefs(screen, ret);
+            }
+        });
+        thread.quitSafely();
 
         return ret;
     }
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
index 0d580ba..5109edd 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
@@ -17,18 +17,22 @@
 package com.android.settings.accessibility;
 
 import android.app.Fragment;
+import android.app.FragmentTransaction;
 import android.os.Bundle;
-import android.support.v4.widget.DrawerLayout;
 import android.text.TextUtils;
+import android.view.accessibility.AccessibilityEvent;
 import android.view.Menu;
-import android.view.MenuItem;
+import android.view.View;
 
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
 import com.android.settings.SettingsPreferenceFragment;
+import com.android.setupwizardlib.util.SystemBarHelper;
+import com.android.setupwizardlib.view.NavigationBar;
 
 public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivity {
 
+    private boolean mSendExtraWindowStateChanged;
 
     @Override
     protected void onCreate(Bundle savedState) {
@@ -36,6 +40,31 @@
 
         getActionBar().setDisplayHomeAsUpEnabled(true);
         setIsDrawerPresent(false);
+
+        // Hide System Nav Bar
+        SystemBarHelper.hideSystemBars(getWindow());
+
+        // Show SUW Nav Bar
+        setContentView(R.layout.accessibility_settings_for_suw);
+        NavigationBar navigationBar = (NavigationBar) findViewById(R.id.suw_navigation_bar);
+        navigationBar.getNextButton().setVisibility(View.GONE);
+        navigationBar.setNavigationBarListener(new NavigationBar.NavigationBarListener() {
+            @Override
+            public void onNavigateBack() {
+                onNavigateUp();
+            }
+
+            @Override
+            public void onNavigateNext() {
+                // Do nothing. We don't show this button.
+            }
+        });
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        mSendExtraWindowStateChanged = false;
     }
 
     @Override
@@ -45,21 +74,58 @@
     }
 
     @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
+    public boolean onNavigateUp() {
         onBackPressed();
+
+        // Clear accessibility focus and let the screen reader announce the new title.
+        getWindow().getDecorView()
+                .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
+
         return true;
     }
 
     @Override
     public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes,
             CharSequence titleText, Fragment resultTo, int resultRequestCode) {
+        // Set the title.
         if (!TextUtils.isEmpty(titleText)) {
             setTitle(titleText);
         } else if (titleRes > 0) {
             setTitle(getString(titleRes));
         }
 
+        // Start the new Fragment.
         args.putInt(SettingsPreferenceFragment.HELP_URI_RESOURCE_KEY, 0);
         startPreferenceFragment(Fragment.instantiate(this, fragmentClass, args), true);
+        mSendExtraWindowStateChanged = true;
+    }
+
+    @Override
+    public void onAttachFragment(Fragment fragment) {
+        if (mSendExtraWindowStateChanged) {
+            // Clear accessibility focus and let the screen reader announce the new title.
+            getWindow().getDecorView()
+                    .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
+        }
+    }
+
+    /**
+     * Start a new fragment.
+     *
+     * @param fragment The fragment to start
+     * @param push If true, the current fragment will be pushed onto the back stack.  If false,
+     * the current fragment will be replaced.
+     */
+    @Override
+    public void startPreferenceFragment(Fragment fragment, boolean push) {
+        FragmentTransaction transaction = getFragmentManager().beginTransaction();
+        transaction.replace(R.id.suw_main_content, fragment);
+        if (push) {
+            transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+            transaction.addToBackStack(BACK_STACK_PREFS);
+        } else {
+            transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
+        }
+        transaction.commitAllowingStateLoss();
     }
 }
diff --git a/src/com/android/settings/applications/AppStateNotificationBridge.java b/src/com/android/settings/applications/AppStateNotificationBridge.java
index f1f0896..39b502c 100644
--- a/src/com/android/settings/applications/AppStateNotificationBridge.java
+++ b/src/com/android/settings/applications/AppStateNotificationBridge.java
@@ -15,7 +15,9 @@
  */
 package com.android.settings.applications;
 
+import android.app.Notification;
 import android.content.pm.PackageManager;
+import android.service.notification.NotificationListenerService;
 
 import com.android.settings.notification.NotificationBackend;
 import com.android.settings.notification.NotificationBackend.AppRow;
@@ -63,11 +65,62 @@
 
         @Override
         public boolean filterApp(AppEntry info) {
+            if (info.extraInfo instanceof AppRow) {
+                AppRow row = (AppRow) info.extraInfo;
+                return row.banned;
+            }
+            return false;
+        }
+    };
+
+    public static final AppFilter FILTER_APP_NOTIFICATION_SILENCED = new AppFilter() {
+        @Override
+        public void init() {
+        }
+
+        @Override
+        public boolean filterApp(AppEntry info) {
             if (info == null) {
                 return false;
             }
             AppRow row = (AppRow) info.extraInfo;
-            return row.banned;
+            return row.appImportance > NotificationListenerService.Ranking.IMPORTANCE_NONE
+                    && row.appImportance < NotificationListenerService.Ranking.IMPORTANCE_DEFAULT;
+        }
+    };
+
+    public static final AppFilter FILTER_APP_NOTIFICATION_PRIORITY = new AppFilter() {
+        @Override
+        public void init() {
+        }
+
+        @Override
+        public boolean filterApp(AppEntry info) {
+            return info.extraInfo != null && ((AppRow) info.extraInfo).appBypassDnd;
+        }
+    };
+
+    public static final AppFilter FILTER_APP_NOTIFICATION_HIDE_SENSITIVE = new AppFilter() {
+        @Override
+        public void init() {
+        }
+
+        @Override
+        public boolean filterApp(AppEntry info) {
+            return info.extraInfo != null
+                    && ((AppRow) info.extraInfo).appVisOverride == Notification.VISIBILITY_PRIVATE;
+        }
+    };
+
+    public static final AppFilter FILTER_APP_NOTIFICATION_HIDE_ALL = new AppFilter() {
+        @Override
+        public void init() {
+        }
+
+        @Override
+        public boolean filterApp(AppEntry info) {
+            return info.extraInfo != null
+                    && ((AppRow) info.extraInfo).appVisOverride == Notification.VISIBILITY_SECRET;
         }
     };
 }
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 8a9c119..2eaa76f 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -50,6 +50,7 @@
 import android.os.ServiceManager;
 import android.os.UserHandle;
 import android.os.UserManager;
+import android.service.notification.NotificationListenerService;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.Preference.OnPreferenceClickListener;
 import android.support.v7.preference.PreferenceCategory;
@@ -1007,8 +1008,11 @@
     public static CharSequence getNotificationSummary(AppRow appRow, Context context) {
         if (appRow.banned) {
             return context.getString(R.string.notifications_disabled);
+        } else if (appRow.appImportance > NotificationListenerService.Ranking.IMPORTANCE_NONE
+                && appRow.appImportance < NotificationListenerService.Ranking.IMPORTANCE_DEFAULT) {
+            return context.getString(R.string.notifications_silenced);
         }
-        return context.getString(R.string.notifications_enabled);
+        return "";
     }
 
     private class MemoryUpdater extends AsyncTask<Void, Void, ProcStatsPackageEntry> {
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index f88a8ae..56661b4 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -126,12 +126,16 @@
     public static final int FILTER_APPS_ENABLED = 3;
     public static final int FILTER_APPS_DISABLED = 4;
     public static final int FILTER_APPS_BLOCKED = 5;
-    public static final int FILTER_APPS_PERSONAL = 6;
-    public static final int FILTER_APPS_WORK = 7;
-    public static final int FILTER_APPS_WITH_DOMAIN_URLS = 8;
-    public static final int FILTER_APPS_USAGE_ACCESS = 9;
-    public static final int FILTER_APPS_WITH_OVERLAY = 10;
-    public static final int FILTER_APPS_WRITE_SETTINGS = 11;
+    public static final int FILTER_APPS_SILENT = 6;
+    public static final int FILTER_APPS_SENSITIVE = 7;
+    public static final int FILTER_APPS_HIDE_NOTIFICATIONS = 8;
+    public static final int FILTER_APPS_PRIORITY = 9;
+    public static final int FILTER_APPS_PERSONAL = 10;
+    public static final int FILTER_APPS_WORK = 11;
+    public static final int FILTER_APPS_WITH_DOMAIN_URLS = 12;
+    public static final int FILTER_APPS_USAGE_ACCESS = 13;
+    public static final int FILTER_APPS_WITH_OVERLAY = 14;
+    public static final int FILTER_APPS_WRITE_SETTINGS = 15;
 
     // This is the string labels for the filter modes above, the order must be kept in sync.
     public static final int[] FILTER_LABELS = new int[]{
@@ -141,6 +145,10 @@
             R.string.filter_enabled_apps,  // Enabled
             R.string.filter_apps_disabled, // Disabled
             R.string.filter_notif_blocked_apps,   // Blocked Notifications
+            R.string.filter_notif_silent,    // Silenced Notifications
+            R.string.filter_notif_sensitive_apps, // Sensitive Notifications
+            R.string.filter_notif_hide_notifications_apps, // Sensitive Notifications
+            R.string.filter_notif_priority_apps,  // Priority Notifications
             R.string.filter_personal_apps, // Personal
             R.string.filter_work_apps,     // Work
             R.string.filter_with_domain_urls_apps,     // Domain URLs
@@ -159,6 +167,10 @@
             ApplicationsState.FILTER_ALL_ENABLED, // Enabled
             ApplicationsState.FILTER_DISABLED,    // Disabled
             AppStateNotificationBridge.FILTER_APP_NOTIFICATION_BLOCKED,   // Blocked Notifications
+            AppStateNotificationBridge.FILTER_APP_NOTIFICATION_SILENCED,   // Silenced Notifications
+            AppStateNotificationBridge.FILTER_APP_NOTIFICATION_HIDE_SENSITIVE, // Sensitive Notifications
+            AppStateNotificationBridge.FILTER_APP_NOTIFICATION_HIDE_ALL, // Hide all Notifications
+            AppStateNotificationBridge.FILTER_APP_NOTIFICATION_PRIORITY,  // Priority Notifications
             ApplicationsState.FILTER_PERSONAL,    // Personal
             ApplicationsState.FILTER_WORK,        // Work
             ApplicationsState.FILTER_WITH_DOMAIN_URLS,   // Apps with Domain URLs
@@ -343,6 +355,10 @@
         }
         if (mListType == LIST_TYPE_NOTIFICATION) {
             mFilterAdapter.enableFilter(FILTER_APPS_BLOCKED);
+            mFilterAdapter.enableFilter(FILTER_APPS_SILENT);
+            mFilterAdapter.enableFilter(FILTER_APPS_SENSITIVE);
+            mFilterAdapter.enableFilter(FILTER_APPS_HIDE_NOTIFICATIONS);
+            mFilterAdapter.enableFilter(FILTER_APPS_PRIORITY);
         }
         if (mListType == LIST_TYPE_HIGH_POWER) {
             mFilterAdapter.enableFilter(FILTER_APPS_POWER_WHITELIST_ALL);
diff --git a/src/com/android/settings/applications/NotificationApps.java b/src/com/android/settings/applications/NotificationApps.java
new file mode 100644
index 0000000..05b450d
--- /dev/null
+++ b/src/com/android/settings/applications/NotificationApps.java
@@ -0,0 +1,129 @@
+/*
+ * 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.applications;
+
+import android.app.Activity;
+import android.app.Application;
+import android.content.Context;
+import com.android.settings.R;
+import com.android.settings.applications.AppStateBaseBridge.Callback;
+import com.android.settings.dashboard.SummaryLoader;
+import com.android.settings.dashboard.SummaryLoader.SummaryProvider;
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.applications.ApplicationsState;
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
+import com.android.settingslib.applications.ApplicationsState.Callbacks;
+
+import java.util.ArrayList;
+
+/**
+ * Extension of ManageApplications with no changes other than having its own
+ * SummaryProvider.
+ */
+public class NotificationApps extends ManageApplications {
+
+    private static class SummaryProvider implements SummaryLoader.SummaryProvider,
+            Callbacks, Callback {
+
+        private final Context mContext;
+        private final SummaryLoader mLoader;
+
+        private final ApplicationsState mAppState;
+        private final ApplicationsState.Session mSession;
+        private final NotificationBackend mNotifBackend;
+        private final AppStateNotificationBridge mExtraInfoBridge;
+
+        private SummaryProvider(Context context, SummaryLoader loader) {
+            mContext = context;
+            mLoader = loader;
+            mAppState =
+                    ApplicationsState.getInstance((Application) context.getApplicationContext());
+            mSession = mAppState.newSession(this);
+            mNotifBackend = new NotificationBackend();
+            mExtraInfoBridge = new AppStateNotificationBridge(mContext.getPackageManager(),
+                    mAppState, this, mNotifBackend);
+        }
+
+        @Override
+        public void setListening(boolean listening) {
+            if (listening) {
+                mSession.resume();
+                mExtraInfoBridge.resume();
+            } else {
+                mSession.pause();
+                mExtraInfoBridge.pause();
+            }
+        }
+
+        private void updateSummary(ArrayList<AppEntry> apps) {
+            if (apps == null) return;
+            if (apps.size() == 0) {
+                mLoader.setSummary(this, mContext.getString(R.string.notification_summary_none));
+            } else {
+                mLoader.setSummary(this, mContext.getString(R.string.notification_summary,
+                        apps.size()));
+            }
+        }
+
+        @Override
+        public void onRebuildComplete(ArrayList<AppEntry> apps) {
+            updateSummary(apps);
+        }
+
+        @Override
+        public void onExtraInfoUpdated() {
+            updateSummary(mSession.rebuild(
+                    AppStateNotificationBridge.FILTER_APP_NOTIFICATION_BLOCKED,
+                    ApplicationsState.ALPHA_COMPARATOR));
+        }
+
+        @Override
+        public void onPackageListChanged() {
+        }
+
+        @Override
+        public void onLauncherInfoChanged() {
+        }
+
+        @Override
+        public void onLoadEntriesCompleted() {
+        }
+
+        @Override
+        public void onRunningStateChanged(boolean running) {
+        }
+
+        @Override
+        public void onPackageIconChanged() {
+        }
+
+        @Override
+        public void onPackageSizeChanged(String packageName) {
+        }
+
+        @Override
+        public void onAllSizesComputed() {
+        }
+    }
+
+    public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
+            = new SummaryLoader.SummaryProviderFactory() {
+        @Override
+        public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
+                                                                   SummaryLoader summaryLoader) {
+            return new SummaryProvider(activity, summaryLoader);
+        }
+    };
+}
diff --git a/src/com/android/settings/notification/NotificationLockscreenPreference.java b/src/com/android/settings/notification/NotificationLockscreenPreference.java
index 60f451f..969aed1 100644
--- a/src/com/android/settings/notification/NotificationLockscreenPreference.java
+++ b/src/com/android/settings/notification/NotificationLockscreenPreference.java
@@ -85,7 +85,7 @@
     }
 
     private static int checkboxVisibilityForSelectedIndex(int selected, boolean showRemoteAtAll) {
-        return selected == 0 && showRemoteAtAll ? View.VISIBLE : View.GONE;
+        return selected == 1 && showRemoteAtAll ? View.VISIBLE : View.GONE;
     }
 
     private class Listener implements DialogInterface.OnClickListener,
diff --git a/src/com/android/settings/notification/RedactionInterstitial.java b/src/com/android/settings/notification/RedactionInterstitial.java
index bd1dfe8..abadb8b 100644
--- a/src/com/android/settings/notification/RedactionInterstitial.java
+++ b/src/com/android/settings/notification/RedactionInterstitial.java
@@ -24,6 +24,8 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
 import android.widget.RadioButton;
 import android.widget.RadioGroup;
 import android.widget.TextView;
@@ -74,11 +76,12 @@
     }
 
     public static class RedactionInterstitialFragment extends SettingsPreferenceFragment
-            implements RadioGroup.OnCheckedChangeListener {
+            implements RadioGroup.OnCheckedChangeListener, CompoundButton.OnCheckedChangeListener {
 
         private RadioGroup mRadioGroup;
         private RestrictedRadioButton mShowAllButton;
         private RestrictedRadioButton mRedactSensitiveButton;
+        private CheckBox mRemoteInputCheckbox;
         private int mUserId;
 
         @Override
@@ -99,6 +102,8 @@
             mShowAllButton = (RestrictedRadioButton) view.findViewById(R.id.show_all);
             mRedactSensitiveButton =
                     (RestrictedRadioButton) view.findViewById(R.id.redact_sensitive);
+            mRemoteInputCheckbox = (CheckBox) view.findViewById(R.id.lockscreen_remote_input);
+            mRemoteInputCheckbox.setOnCheckedChangeListener(this);
 
             mRadioGroup.setOnCheckedChangeListener(this);
             mUserId = Utils.getUserIdFromBundle(
@@ -150,6 +155,12 @@
             }
 
             mRadioGroup.check(checkedButtonId);
+
+            boolean allowRemoteInput = Settings.Secure.getIntForUser(getContentResolver(),
+                    Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT, 0, mUserId) != 0;
+            mRemoteInputCheckbox.setChecked(!allowRemoteInput);
+
+            updateRemoteInputCheckboxVisibility();
         }
 
         @Override
@@ -161,6 +172,21 @@
                     Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, show ? 1 : 0, mUserId);
             Settings.Secure.putIntForUser(getContentResolver(),
                     Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, enabled ? 1 : 0, mUserId);
+
+            updateRemoteInputCheckboxVisibility();
+        }
+
+        @Override
+        public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
+            if (buttonView == mRemoteInputCheckbox) {
+                Settings.Secure.putIntForUser(getContentResolver(),
+                        Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT, checked ? 0 : 1, mUserId);
+            }
+        }
+
+        private void updateRemoteInputCheckboxVisibility() {
+            boolean visible = mRadioGroup.getCheckedRadioButtonId() == R.id.show_all;
+            mRemoteInputCheckbox.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
         }
     }
 }
diff --git a/src/com/android/settings/search/Ranking.java b/src/com/android/settings/search/Ranking.java
index 94b010c..80eb6d4 100644
--- a/src/com/android/settings/search/Ranking.java
+++ b/src/com/android/settings/search/Ranking.java
@@ -21,13 +21,11 @@
 import com.android.settings.DevelopmentSettings;
 import com.android.settings.DeviceInfoSettings;
 import com.android.settings.DisplaySettings;
-import com.android.settings.HomeSettings;
 import com.android.settings.LegalSettings;
 import com.android.settings.PrivacySettings;
 import com.android.settings.ScreenPinningSettings;
 import com.android.settings.SecuritySettings;
 import com.android.settings.WallpaperTypeSettings;
-import com.android.settings.WifiCallingSettings;
 import com.android.settings.WirelessSettings;
 import com.android.settings.accessibility.AccessibilitySettings;
 import com.android.settings.accounts.AccountSettings;
@@ -69,25 +67,24 @@
     public static final int RANK_SIM = 3;
     public static final int RANK_DATA_USAGE = 4;
     public static final int RANK_WIRELESS = 5;
-    public static final int RANK_HOME = 6;
-    public static final int RANK_DISPLAY = 7;
-    public static final int RANK_WALLPAPER = 8;
-    public static final int RANK_NOTIFICATIONS = 9;
-    public static final int RANK_SOUND = 10;
-    public static final int RANK_APPS = 11;
-    public static final int RANK_STORAGE = 12;
-    public static final int RANK_POWER_USAGE = 13;
-    public static final int RANK_USERS = 14;
-    public static final int RANK_LOCATION = 15;
-    public static final int RANK_SECURITY = 16;
-    public static final int RANK_ACCOUNT = 17;
-    public static final int RANK_IME = 18;
-    public static final int RANK_PRIVACY = 19;
-    public static final int RANK_DATE_TIME = 20;
-    public static final int RANK_ACCESSIBILITY = 21;
-    public static final int RANK_PRINTING = 22;
-    public static final int RANK_DEVELOPEMENT = 23;
-    public static final int RANK_DEVICE_INFO = 24;
+    public static final int RANK_DISPLAY = 6;
+    public static final int RANK_WALLPAPER = 7;
+    public static final int RANK_NOTIFICATIONS = 8;
+    public static final int RANK_SOUND = 9;
+    public static final int RANK_APPS = 10;
+    public static final int RANK_STORAGE = 11;
+    public static final int RANK_POWER_USAGE = 12;
+    public static final int RANK_USERS = 13;
+    public static final int RANK_LOCATION = 14;
+    public static final int RANK_SECURITY = 15;
+    public static final int RANK_ACCOUNT = 16;
+    public static final int RANK_IME = 17;
+    public static final int RANK_PRIVACY = 18;
+    public static final int RANK_DATE_TIME = 19;
+    public static final int RANK_ACCESSIBILITY = 20;
+    public static final int RANK_PRINTING = 21;
+    public static final int RANK_DEVELOPEMENT = 22;
+    public static final int RANK_DEVICE_INFO = 23;
 
     public static final int RANK_UNDEFINED = -1;
     public static final int RANK_OTHERS = 1024;
@@ -117,9 +114,6 @@
         // Other wireless settinfs
         sRankMap.put(WirelessSettings.class.getName(), RANK_WIRELESS);
 
-        // Home
-        sRankMap.put(HomeSettings.class.getName(), RANK_HOME);
-
         // Display
         sRankMap.put(DisplaySettings.class.getName(), RANK_DISPLAY);
         sRankMap.put(ScreenZoomSettings.class.getName(), RANK_WIFI);
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index 73784b2..08a0d0c 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -21,14 +21,12 @@
 import com.android.settings.DevelopmentSettings;
 import com.android.settings.DeviceInfoSettings;
 import com.android.settings.DisplaySettings;
-import com.android.settings.HomeSettings;
 import com.android.settings.LegalSettings;
 import com.android.settings.PrivacySettings;
 import com.android.settings.R;
 import com.android.settings.ScreenPinningSettings;
 import com.android.settings.SecuritySettings;
 import com.android.settings.WallpaperTypeSettings;
-import com.android.settings.WifiCallingSettings;
 import com.android.settings.WirelessSettings;
 import com.android.settings.accessibility.AccessibilitySettings;
 import com.android.settings.accounts.AccountSettings;
@@ -124,13 +122,6 @@
                         WirelessSettings.class.getName(),
                         R.drawable.ic_settings_more));
 
-        sResMap.put(HomeSettings.class.getName(),
-                new SearchIndexableResource(
-                        Ranking.getRankForClassName(HomeSettings.class.getName()),
-                        NO_DATA_RES_ID,
-                        HomeSettings.class.getName(),
-                        R.drawable.ic_settings_home));
-
         sResMap.put(ScreenZoomSettings.class.getName(),
                 new SearchIndexableResource(
                         Ranking.getRankForClassName(ScreenZoomSettings.class.getName()),
diff --git a/src/com/android/settings/users/RestrictionUtils.java b/src/com/android/settings/users/RestrictionUtils.java
index 33b6a95..a5cecde 100644
--- a/src/com/android/settings/users/RestrictionUtils.java
+++ b/src/com/android/settings/users/RestrictionUtils.java
@@ -78,9 +78,8 @@
     public static void setRestrictions(Context context, ArrayList<RestrictionEntry> entries,
             UserHandle user) {
         UserManager um = UserManager.get(context);
-
         for (RestrictionEntry entry : entries) {
-            um.setUserRestriction(entry.getKey(), !entry.getSelectedState());
+            um.setUserRestriction(entry.getKey(), !entry.getSelectedState(), user);
         }
     }
 }
diff --git a/src/com/android/settings/users/UserPreference.java b/src/com/android/settings/users/UserPreference.java
index eff8b9a..1f24018 100644
--- a/src/com/android/settings/users/UserPreference.java
+++ b/src/com/android/settings/users/UserPreference.java
@@ -71,7 +71,7 @@
             OnClickListener deleteListener) {
         super(context, attrs);
         if (deleteListener != null || settingsListener != null) {
-            setWidgetLayoutResource(R.layout.preference_user_delete_widget);
+            setWidgetLayoutResource(R.layout.restricted_preference_user_delete_widget);
         }
         mDeleteClickListener = deleteListener;
         mSettingsClickListener = settingsListener;
@@ -89,37 +89,42 @@
 
     @Override
     public void onBindViewHolder(PreferenceViewHolder view) {
-        UserManager um = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
-        View deleteDividerView = view.findViewById(R.id.divider_delete);
-        View manageDividerView = view.findViewById(R.id.divider_manage);
-        View deleteView = view.findViewById(R.id.trash_user);
-        if (deleteView != null) {
-            if (mDeleteClickListener != null
-                    && !um.hasUserRestriction(UserManager.DISALLOW_REMOVE_USER)) {
-                deleteView.setOnClickListener(mDeleteClickListener);
-                deleteView.setTag(this);
-            } else {
-                deleteView.setVisibility(View.GONE);
-                deleteDividerView.setVisibility(View.GONE);
-            }
-        }
+        super.onBindViewHolder(view);
         final boolean disabledByAdmin = isDisabledByAdmin();
-        ImageView manageView = (ImageView) view.findViewById(R.id.manage_user);
-        if (manageView != null) {
-            if (mSettingsClickListener != null) {
-                manageView.setOnClickListener(mSettingsClickListener);
-                manageView.setTag(this);
-                if (mDeleteClickListener != null) {
+        dimIcon(disabledByAdmin);
+        View userDeleteWidget = view.findViewById(R.id.user_delete_widget);
+        if (userDeleteWidget != null) {
+            userDeleteWidget.setVisibility(disabledByAdmin ? View.GONE : View.VISIBLE);
+        }
+        if (!disabledByAdmin) {
+            UserManager um = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
+            View deleteDividerView = view.findViewById(R.id.divider_delete);
+            View manageDividerView = view.findViewById(R.id.divider_manage);
+            View deleteView = view.findViewById(R.id.trash_user);
+            if (deleteView != null) {
+                if (mDeleteClickListener != null
+                        && !um.hasUserRestriction(UserManager.DISALLOW_REMOVE_USER)) {
+                    deleteView.setOnClickListener(mDeleteClickListener);
+                    deleteView.setTag(this);
+                } else {
+                    deleteView.setVisibility(View.GONE);
+                    deleteDividerView.setVisibility(View.GONE);
+                }
+            }
+            ImageView manageView = (ImageView) view.findViewById(R.id.manage_user);
+            if (manageView != null) {
+                if (mSettingsClickListener != null) {
+                    manageView.setOnClickListener(mSettingsClickListener);
+                    manageView.setTag(this);
+                    if (mDeleteClickListener != null) {
+                        manageDividerView.setVisibility(View.GONE);
+                    }
+                } else {
+                    manageView.setVisibility(View.GONE);
                     manageDividerView.setVisibility(View.GONE);
                 }
-            } else {
-                manageView.setVisibility(View.GONE);
-                manageDividerView.setVisibility(View.GONE);
             }
-            manageView.setImageAlpha(disabledByAdmin ? ALPHA_DISABLED : ALPHA_ENABLED);
         }
-        super.onBindViewHolder(view);
-        dimIcon(disabledByAdmin);
     }
 
     private int getSerialNumber() {