diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index ef0536f..620fbd2 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2760,8 +2760,8 @@
 
         <activity android:name="ShowAdminSupportDetailsDialog"
                 android:theme="@style/Transparent"
-                android:excludeFromRecents="true">
-
+                android:excludeFromRecents="true"
+                android:launchMode="singleTop">
             <intent-filter>
                 <action android:name="android.settings.SHOW_ADMIN_SUPPORT_DETAILS" />
                 <category android:name="android.intent.category.DEFAULT" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9644171..097062b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5926,12 +5926,6 @@
     <!-- Notification Settings: Title for the option managing notifications per application. [CHAR LIMIT=30] -->
     <string name="app_notifications_title">Notifications</string>
 
-    <!-- Sound & notification > Notification section: Title for the option managing notifications per topic. [CHAR LIMIT=30] -->
-    <string name="topic_notifications_title">Topic notifications</string>
-
-    <!-- [CHAR LIMIT=100] Notification topic list header -->
-    <string name="notification_topic_categories">Categories</string>
-
     <!-- [CHAR LIMIT=100] Notification importance slider title -->
     <string name="notification_importance_title">Importance</string>
 
@@ -6407,9 +6401,7 @@
    <!-- App notification summary with notifications enabled [CHAR LIMIT=40] -->
    <string name="notifications_enabled">Normal</string>
    <!-- App notification summary with notifications disabled [CHAR LIMIT=40] -->
-   <string name="notifications_disabled">Fully Blocked</string>
-   <!-- App notification summary with notifications disabled [CHAR LIMIT=40] -->
-   <string name="notifications_partially_disabled">Partially Blocked</string>
+   <string name="notifications_disabled">Blocked</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] -->
@@ -6981,17 +6973,17 @@
 
     <!-- TODO: Update these strings with the finalized ones. -->
     <!-- Title for dialog displayed when user clicks on a setting locked by an admin [CHAR LIMIT=30] -->
-    <string name="disabled_by_policy_title">Disabled by policy</string>
+    <string name="disabled_by_policy_title">Action not allowed</string>
     <!-- Shown when the user tries to change a settings locked by an admin [CHAR LIMIT=200] -->
-    <string name="default_admin_support_msg">Disabled by your organisation\'s administrator.\nContact them to learn more.</string>
+    <string name="default_admin_support_msg">This action is disabled. Contact your organisation\'s administrator to learn more.</string>
     <!-- Shown in dialog to allow user to see more information about the device admin [CHAR LIMIT=30] -->
     <string name="admin_support_more_info">More details</string>
     <!-- Shown in admin details page to warn user about policies the admin can set in a work profile. [CHAR LIMIT=NONE] -->
-    <string name="admin_profile_owner_message">Your administrator has the ability to monitor and manage settings, corporate access, apps, permissions, and data associated with the profile, including network activity and your device\'s location information.</string>
+    <string name="admin_profile_owner_message">Your administrator can monitor and manage apps and data associated with your work profile, including settings, permissions, corporate access, network activity, and the device\'s location information.</string>
     <!-- Shown in admin details page to warn user about policies the admin can set on a user. [CHAR LIMIT=NONE] -->
-    <string name="admin_profile_owner_user_message">Your administrator has the ability to monitor and manage settings, corporate access, apps, permissions, and data associated with this user, including network activity and your device\'s location information.</string>
+    <string name="admin_profile_owner_user_message">Your administrator can monitor and manage apps and data associated with this user, including settings, permissions, corporate access, network activity, and the device\'s location information.</string>
     <!-- Shown in admin details page to warn user about policies the admin can set on a device. [CHAR LIMIT=NONE] -->
-    <string name="admin_device_owner_message">Your administrator has the ability to monitor and manage settings, corporate access, apps, permissions, and data associated with this device, including network activity and your device\'s location information.</string>
+    <string name="admin_device_owner_message">Your administrator can monitor and manage apps and data associated with this device, including settings, permissions, corporate access, network activity, and the device\'s location information.</string>
 
     <!-- Turn off a conditional state of the device (e.g. airplane mode, or hotspot) [CHAR LIMIT=30] -->
     <string name="condition_turn_off">Turn off</string>
diff --git a/res/xml/app_notification_settings.xml b/res/xml/app_notification_settings.xml
index b98c6b2..1a2584a 100644
--- a/res/xml/app_notification_settings.xml
+++ b/res/xml/app_notification_settings.xml
@@ -18,7 +18,6 @@
         android:title="@string/app_notifications_title"
         android:key="app_notification_settings">
 
-    <!-- Apps without topics -->
     <!-- Importance -->
     <com.android.settingslib.RestrictedPreference
             android:key="importance_title"
@@ -47,17 +46,4 @@
             android:summary="@string/app_notification_override_dnd_summary"
             android:order="6" />
 
-    <!-- Apps with topics -->
-    <!-- Block -->
-    <com.android.settingslib.RestrictedSwitchPreference
-            android:key="block"
-            android:title="@string/app_notification_block_title"
-            android:summary="@string/app_notification_block_summary"
-            android:order="7" />
-
-    <PreferenceCategory
-            android:key="categories"
-            android:title="@string/notification_topic_categories"
-            android:order="8" />
-
 </PreferenceScreen>
diff --git a/src/com/android/settings/ShowAdminSupportDetailsDialog.java b/src/com/android/settings/ShowAdminSupportDetailsDialog.java
index bc7168f..eccd9ea 100644
--- a/src/com/android/settings/ShowAdminSupportDetailsDialog.java
+++ b/src/com/android/settings/ShowAdminSupportDetailsDialog.java
@@ -37,40 +37,59 @@
 import android.widget.ImageView;
 import android.widget.TextView;
 
+import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
 public class ShowAdminSupportDetailsDialog extends Activity
         implements DialogInterface.OnDismissListener {
 
-    private final String TAG = "AdminSupportDialog";
+    private static final String TAG = "AdminSupportDialog";
 
     private DevicePolicyManager mDpm;
 
+    private EnforcedAdmin mEnforcedAdmin;
+    private View mDialogView;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mDpm = getSystemService(DevicePolicyManager.class);
-        ComponentName admin = null;
-        int userId = UserHandle.myUserId();
-        Intent intent = getIntent();
-        if (intent != null) {
-            // Only allow apps with MANAGE_DEVICE_ADMINS permission to specify admin and user.
-            if (checkIfCallerHasPermission(android.Manifest.permission.MANAGE_DEVICE_ADMINS)) {
-                admin = intent.getParcelableExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN);
-                userId = intent.getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
-            }
-        }
+        mEnforcedAdmin = getAdminDetailsFromIntent(getIntent());
 
-        View rootView = LayoutInflater.from(this).inflate(
+        mDialogView = LayoutInflater.from(this).inflate(
                 R.layout.admin_support_details_dialog, null);
-        setAdminSupportDetails(rootView, admin, userId);
+        setAdminSupportDetails(mDialogView, mEnforcedAdmin.component, mEnforcedAdmin.userId);
 
         new AlertDialog.Builder(this)
-                .setView(rootView)
+                .setView(mDialogView)
                 .setPositiveButton(R.string.okay, null)
                 .setOnDismissListener(this)
                 .show();
     }
 
+    @Override
+    public void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
+        EnforcedAdmin admin = getAdminDetailsFromIntent(intent);
+        if (!mEnforcedAdmin.equals(admin)) {
+            mEnforcedAdmin = admin;
+            setAdminSupportDetails(mDialogView, mEnforcedAdmin.component, mEnforcedAdmin.userId);
+        }
+    }
+
+    private EnforcedAdmin getAdminDetailsFromIntent(Intent intent) {
+        EnforcedAdmin admin = new EnforcedAdmin(null, UserHandle.myUserId());
+        if (intent == null) {
+            return admin;
+        }
+        // Only allow apps with MANAGE_DEVICE_ADMINS permission to specify admin and user.
+        if (checkIfCallerHasPermission(android.Manifest.permission.MANAGE_DEVICE_ADMINS)) {
+            admin.component = intent.getParcelableExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN);
+            admin.userId = intent.getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
+        }
+        return admin;
+    }
+
     private boolean checkIfCallerHasPermission(String permission) {
         IActivityManager am = ActivityManagerNative.getDefault();
         try {
diff --git a/src/com/android/settings/applications/AppStateNotificationBridge.java b/src/com/android/settings/applications/AppStateNotificationBridge.java
index c7b78af..f1f0896 100644
--- a/src/com/android/settings/applications/AppStateNotificationBridge.java
+++ b/src/com/android/settings/applications/AppStateNotificationBridge.java
@@ -67,7 +67,7 @@
                 return false;
             }
             AppRow row = (AppRow) info.extraInfo;
-            return row.banned || row.bannedTopics;
+            return row.banned;
         }
     };
 }
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index a8e8eae..80335fc 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -842,8 +842,6 @@
     public static CharSequence getNotificationSummary(AppRow appRow, Context context) {
         if (appRow.banned) {
             return context.getString(R.string.notifications_disabled);
-        } else if (appRow.bannedTopics) {
-            return context.getString(R.string.notifications_partially_disabled);
         }
         return context.getString(R.string.notifications_enabled);
     }
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index b3b15af..8f30f59 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -17,11 +17,14 @@
 package com.android.settings.notification;
 
 import android.app.Notification;
+import android.app.NotificationManager;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.ResolveInfo;
 import android.os.Bundle;
+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;
@@ -32,6 +35,7 @@
 
 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;
@@ -50,16 +54,12 @@
     private static final String TAG = "AppNotificationSettings";
     private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
 
-    private static final String KEY_BLOCK = "block";
-    private static final String KEY_CATEGORIES = "categories";
-
     private static final Intent APP_NOTIFICATION_PREFS_CATEGORY_INTENT
             = new Intent(Intent.ACTION_MAIN)
                 .addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES);
 
-    private RestrictedSwitchPreference mBlock;
-    private PreferenceCategory mCategories;
     private AppRow mAppRow;
+    private boolean mDndVisualEffectsSuppressed;
 
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
@@ -79,8 +79,6 @@
         super.onCreate(savedInstanceState);
 
         addPreferencesFromResource(R.xml.app_notification_settings);
-        mCategories = (PreferenceCategory) findPreference(KEY_CATEGORIES);
-        mBlock = (RestrictedSwitchPreference) findPreference(KEY_BLOCK);
         mImportance = (ImportanceSeekBarPreference) findPreference(KEY_IMPORTANCE);
         mImportanceReset = (LayoutPreference) findPreference(KEY_IMPORTANCE_RESET);
         mImportanceTitle = (RestrictedPreference) findPreference(KEY_IMPORTANCE_TITLE);
@@ -91,84 +89,49 @@
 
         mAppRow = mBackend.loadAppRow(mPm, mPkgInfo);
 
+        NotificationManager.Policy policy =
+                NotificationManager.from(mContext).getNotificationPolicy();
+        mDndVisualEffectsSuppressed = policy == null ? false : policy.suppressedVisualEffects != 0;
+
         // load settings intent
         ArrayMap<String, AppRow> rows = new ArrayMap<String, AppRow>();
         rows.put(mAppRow.pkg, mAppRow);
         collectConfigActivities(rows);
 
-        // Add topics
-        List<Notification.Topic> topics = mBackend.getTopics(mPkg, mUid);
-        if (topics.size() <= 1) {
-            removeAppPrefs();
-            setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance);
-            setupPriorityPref(mAppRow.appBypassDnd);
-            setupSensitivePref(mAppRow.appSensitive);
-        } else {
-            removeTopicPrefs();
-            setupBlockSwitch();
-            for (Notification.Topic topic : topics) {
-                RestrictedPreference topicPreference = new RestrictedPreference(getPrefContext());
-                topicPreference.setDisabledByAdmin(mSuspendedAppsAdmin);
-                topicPreference.setKey(topic.getId());
-                topicPreference.setTitle(topic.getLabel());
-                // Create intent for this preference.
-                Bundle topicArgs = new Bundle();
-                topicArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);
-                topicArgs.putParcelable(TopicNotificationSettings.ARG_TOPIC, topic);
-                topicArgs.putBoolean(AppHeader.EXTRA_HIDE_INFO_BUTTON, true);
-                topicArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg);
-                topicArgs.putParcelable(TopicNotificationSettings.ARG_PACKAGE_INFO, mPkgInfo);
-
-                Intent topicIntent = Utils.onBuildStartFragmentIntent(getActivity(),
-                        TopicNotificationSettings.class.getName(),
-                        topicArgs, null, R.string.topic_notifications_title, null, false);
-                topicPreference.setIntent(topicIntent);
-                mCategories.addPreference(topicPreference);
-            }
-        }
+        setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance);
+        setupPriorityPref(mAppRow.appBypassDnd);
+        setupSensitivePref(mAppRow.appSensitive);
+        updateDependents(mAppRow.appImportance);
     }
 
     @Override
-    protected void updateDependents(int progress) {
-        updateDependents(progress == Ranking.IMPORTANCE_NONE);
+    protected void updateDependents(int importance) {
+        final boolean lockscreenSecure = new LockPatternUtils(getActivity()).isSecure(
+                UserHandle.myUserId());
+        final boolean lockscreenNotificationsEnabled = getLockscreenNotificationsEnabled();
+        final boolean allowPrivate = getLockscreenAllowPrivateNotifications();
+
+        setVisible(mPriority, checkCanBeVisible(Ranking.IMPORTANCE_DEFAULT, importance)
+                && !mDndVisualEffectsSuppressed);
+        setVisible(mSensitive, checkCanBeVisible(Ranking.IMPORTANCE_LOW, importance)
+                && lockscreenSecure && lockscreenNotificationsEnabled && allowPrivate);
     }
 
-    private void removeTopicPrefs() {
-        setVisible(mImportance, false);
-        setVisible(mImportanceReset, false);
-        setVisible(mImportanceTitle, false);
-        setVisible(mPriority, false);
-        setVisible(mSensitive, false);
+    protected boolean checkCanBeVisible(int minImportanceVisible, int importance) {
+        if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
+            return true;
+        }
+        return importance > minImportanceVisible;
     }
 
-    private void removeAppPrefs() {
-        setVisible(mBlock, false);
-        setVisible(mCategories, false);
+    private boolean getLockscreenNotificationsEnabled() {
+        return Settings.Secure.getInt(getContentResolver(),
+                Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
     }
 
-    private void updateDependents(boolean banned) {
-        mBlock.setEnabled(!mAppRow.systemApp);
-        mCategories.setEnabled(!banned);
-    }
-
-    private void setupBlockSwitch() {
-        mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
-        mBlock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
-            @Override
-            public boolean onPreferenceChange(Preference preference, Object newValue) {
-                final boolean banned = (Boolean) newValue;
-                if (banned) {
-                    MetricsLogger.action(getActivity(), MetricsEvent.ACTION_BAN_APP_NOTES, mPkg);
-                }
-                final boolean success = mBackend.setNotificationsBanned(mPkg, mUid, banned);
-                if (success) {
-                    updateDependents(banned);
-                }
-                return success;
-            }
-        });
-        mBlock.setChecked(mAppRow.banned);
-        updateDependents(mAppRow.banned);
+    private boolean getLockscreenAllowPrivateNotifications() {
+        return Settings.Secure.getInt(getContentResolver(),
+                Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0) != 0;
     }
 
     private List<ResolveInfo> queryNotificationConfigActivities() {
diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java
index 8dd6a4c..772fa19 100644
--- a/src/com/android/settings/notification/NotificationBackend.java
+++ b/src/com/android/settings/notification/NotificationBackend.java
@@ -15,8 +15,6 @@
  */
 package com.android.settings.notification;
 
-import com.google.android.collect.Lists;
-
 import android.app.INotificationManager;
 import android.app.Notification;
 import android.content.Context;
@@ -24,15 +22,12 @@
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
-import android.content.pm.ParceledListSlice;
 import android.graphics.drawable.Drawable;
 import android.os.ServiceManager;
 import android.service.notification.NotificationListenerService;
 import android.util.Log;
 import com.android.settingslib.Utils;
 
-import java.util.List;
-
 public class NotificationBackend {
     private static final String TAG = "NotificationBackend";
 
@@ -51,10 +46,9 @@
         }
         row.icon = app.loadIcon(pm);
         row.banned = getNotificationsBanned(row.pkg, row.uid);
-        row.appImportance = getImportance(row.pkg, row.uid, null);
-        row.appBypassDnd = getBypassZenMode(row.pkg, row.uid, null);
-        row.appSensitive = getSensitive(row.pkg, row.uid, null);
-        row.bannedTopics = hasBannedTopics(row.pkg, row.uid);
+        row.appImportance = getImportance(row.pkg, row.uid);
+        row.appBypassDnd = getBypassZenMode(row.pkg, row.uid);
+        row.appSensitive = getSensitive(row.pkg, row.uid);
         return row;
     }
 
@@ -64,31 +58,6 @@
         return row;
     }
 
-    public TopicRow loadTopicRow(PackageManager pm, PackageInfo app, Notification.Topic topic) {
-        final TopicRow row = new TopicRow();
-        row.pkg = app.packageName;
-        row.uid = app.applicationInfo.uid;
-        row.label = topic.getLabel();
-        row.icon = app.applicationInfo.loadIcon(pm);
-        row.systemApp = Utils.isSystemPackage(pm, app);
-        row.topic = topic;
-        row.priority = getBypassZenMode(row.pkg, row.uid, row.topic);
-        row.sensitive = getSensitive(row.pkg, row.uid, row.topic);
-        row.banned = getNotificationsBanned(row.pkg, row.uid);
-        row.importance = getImportance(row.pkg, row.uid, row.topic);
-        return row;
-    }
-
-    public boolean setNotificationsBanned(String pkg, int uid, boolean banned) {
-        try {
-            sINM.setNotificationsEnabledForPackage(pkg, uid, !banned);
-            return true;
-        } catch (Exception e) {
-           Log.w(TAG, "Error calling NoMan", e);
-           return false;
-        }
-    }
-
     public boolean getNotificationsBanned(String pkg, int uid) {
         try {
             final boolean enabled = sINM.areNotificationsEnabledForPackage(pkg, uid);
@@ -99,19 +68,18 @@
         }
     }
 
-    public boolean getBypassZenMode(String pkg, int uid, Notification.Topic topic) {
+    public boolean getBypassZenMode(String pkg, int uid) {
         try {
-            return sINM.getPriority(pkg, uid, topic) == Notification.PRIORITY_MAX;
+            return sINM.getPriority(pkg, uid) == Notification.PRIORITY_MAX;
         } catch (Exception e) {
             Log.w(TAG, "Error calling NoMan", e);
             return false;
         }
     }
 
-    public boolean setBypassZenMode(String pkg, int uid, Notification.Topic topic,
-            boolean bypassZen) {
+    public boolean setBypassZenMode(String pkg, int uid, boolean bypassZen) {
         try {
-            sINM.setPriority(pkg, uid, topic,
+            sINM.setPriority(pkg, uid,
                     bypassZen ? Notification.PRIORITY_MAX : Notification.PRIORITY_DEFAULT);
             return true;
         } catch (Exception e) {
@@ -120,19 +88,18 @@
         }
     }
 
-    public boolean getSensitive(String pkg, int uid, Notification.Topic topic) {
+    public boolean getSensitive(String pkg, int uid) {
         try {
-            return sINM.getVisibilityOverride(pkg, uid, topic)
-                    == Notification.VISIBILITY_PRIVATE;
+            return sINM.getVisibilityOverride(pkg, uid) == Notification.VISIBILITY_PRIVATE;
         } catch (Exception e) {
             Log.w(TAG, "Error calling NoMan", e);
             return false;
         }
     }
 
-    public boolean setSensitive(String pkg, int uid, Notification.Topic topic, boolean sensitive) {
+    public boolean setSensitive(String pkg, int uid, boolean sensitive) {
         try {
-            sINM.setVisibilityOverride(pkg, uid, topic,
+            sINM.setVisibilityOverride(pkg, uid,
                     sensitive ? Notification.VISIBILITY_PRIVATE
                             : NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE);
             return true;
@@ -142,9 +109,9 @@
         }
     }
 
-    public boolean setImportance(String pkg, int uid, Notification.Topic topic, int importance) {
+    public boolean setImportance(String pkg, int uid, int importance) {
         try {
-            sINM.setImportance(pkg, uid, topic, importance);
+            sINM.setImportance(pkg, uid, importance);
             return true;
         } catch (Exception e) {
             Log.w(TAG, "Error calling NoMan", e);
@@ -152,34 +119,15 @@
         }
     }
 
-    public int getImportance(String pkg, int uid, Notification.Topic topic) {
+    public int getImportance(String pkg, int uid) {
         try {
-            return sINM.getImportance(pkg, uid, topic);
+            return sINM.getImportance(pkg, uid);
         } catch (Exception e) {
             Log.w(TAG, "Error calling NoMan", e);
             return NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED;
         }
     }
 
-    public List<Notification.Topic> getTopics(String pkg, int uid) {
-        try {
-            final ParceledListSlice<Notification.Topic> parceledList = sINM.getTopics(pkg, uid);
-            return parceledList.getList();
-        } catch (Exception e) {
-            Log.w(TAG, "Error calling NoMan", e);
-            return Lists.newArrayList();
-        }
-    }
-
-    public boolean hasBannedTopics(String pkg, int uid) {
-        try {
-            return sINM.hasBannedTopics(pkg, uid);
-        } catch (Exception e) {
-            Log.w(TAG, "Error calling NoMan", e);
-            return false;
-        }
-    }
-
     static class Row {
         public String section;
     }
@@ -196,13 +144,5 @@
         public int appImportance;
         public boolean appBypassDnd;
         public boolean appSensitive;
-        public boolean bannedTopics;
-    }
-
-    public static class TopicRow extends AppRow {
-        public Notification.Topic topic;
-        public boolean priority;
-        public boolean sensitive;
-        public int importance;
     }
 }
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index 7f7dfd5..a58edf7 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -47,9 +47,6 @@
     private static final String TAG = "NotifiSettingsBase";
     private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
 
-    protected static final String ARG_PACKAGE_INFO = "arg_info";
-    protected static final String ARG_TOPIC = "arg_topic";
-
     protected static final String KEY_BYPASS_DND = "bypass_dnd";
     protected static final String KEY_SENSITIVE = "sensitive";
     protected static final String KEY_IMPORTANCE = "importance";
@@ -64,7 +61,6 @@
     protected int mUserId;
     protected String mPkg;
     protected PackageInfo mPkgInfo;
-    protected Notification.Topic mTopic;
     protected ImportanceSeekBarPreference mImportance;
     protected RestrictedPreference mImportanceTitle;
     protected LayoutPreference mImportanceReset;
@@ -113,11 +109,7 @@
         mUserId = UserHandle.getUserId(mUid);
 
         if (DEBUG) Log.d(TAG, "Load details for pkg=" + mPkg + " uid=" + mUid);
-        mPkgInfo = args != null && args.containsKey(ARG_PACKAGE_INFO)
-                ? (PackageInfo) args.getParcelable(ARG_PACKAGE_INFO) : null;
-        if (mPkgInfo == null) {
-            mPkgInfo = findPackageInfo(mPkg, mUid);
-        }
+        mPkgInfo = findPackageInfo(mPkg, mUid);
         if (mPkgInfo == null) {
             Log.w(TAG, "Failed to find package info: " + Settings.EXTRA_APP_PACKAGE + " was " + mPkg
                     + ", " + Settings.EXTRA_APP_UID + " was " + mUid);
@@ -125,10 +117,6 @@
             return;
         }
 
-        // Will be null for app wide settings.
-        mTopic = args != null && args.containsKey(ARG_TOPIC)
-                ? (Notification.Topic) args.getParcelable(ARG_TOPIC) : null;
-
         mSuspendedAppsAdmin = RestrictedLockUtils.checkIfApplicationIsSuspended(
                 mContext, mPkg, mUserId);
     }
@@ -177,7 +165,7 @@
         mImportance.setCallback(new ImportanceSeekBarPreference.Callback() {
             @Override
             public void onImportanceChanged(int progress) {
-                mBackend.setImportance(mPkg, mUid, mTopic, progress);
+                mBackend.setImportance(mPkg, mUid, progress);
                 mImportanceTitle.setSummary(getProgressSummary(progress));
                 updateDependents(progress);
             }
@@ -194,7 +182,7 @@
                     return;
                 }
 
-                mBackend.setImportance(mPkg, mUid, mTopic, Ranking.IMPORTANCE_UNSPECIFIED);
+                mBackend.setImportance(mPkg, mUid, Ranking.IMPORTANCE_UNSPECIFIED);
                 mImportanceReset.setVisible(false);
                 mImportance.setVisible(false);
                 mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
@@ -231,7 +219,7 @@
             @Override
             public boolean onPreferenceChange(Preference preference, Object newValue) {
                 final boolean bypassZenMode = (Boolean) newValue;
-                return mBackend.setBypassZenMode(mPkgInfo.packageName, mUid, mTopic, bypassZenMode);
+                return mBackend.setBypassZenMode(mPkgInfo.packageName, mUid, bypassZenMode);
             }
         });
     }
@@ -243,7 +231,7 @@
             @Override
             public boolean onPreferenceChange(Preference preference, Object newValue) {
                 final boolean sensitive = (Boolean) newValue;
-                return mBackend.setSensitive(mPkgInfo.packageName, mUid, mTopic, sensitive);
+                return mBackend.setSensitive(mPkgInfo.packageName, mUid, sensitive);
             }
         });
     }
@@ -287,7 +275,7 @@
             new Preference.OnPreferenceClickListener() {
                 @Override
                 public boolean onPreferenceClick(Preference preference) {
-                    mBackend.setImportance(mPkg, mUid, mTopic, Ranking.IMPORTANCE_DEFAULT);
+                    mBackend.setImportance(mPkg, mUid, Ranking.IMPORTANCE_DEFAULT);
                     mImportance.setProgress(Ranking.IMPORTANCE_DEFAULT);
                     mImportanceTitle.setSummary(getProgressSummary(Ranking.IMPORTANCE_DEFAULT));
                     mImportance.setVisible(true);
diff --git a/src/com/android/settings/notification/TopicNotificationSettings.java b/src/com/android/settings/notification/TopicNotificationSettings.java
deleted file mode 100644
index c1df2de..0000000
--- a/src/com/android/settings/notification/TopicNotificationSettings.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification;
-
-import 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.applications.LayoutPreference;
-import com.android.settings.notification.NotificationBackend.TopicRow;
-import com.android.settingslib.RestrictedPreference;
-import com.android.settingslib.RestrictedSwitchPreference;
-
-import android.app.NotificationManager;
-import android.os.Bundle;
-import android.os.UserHandle;
-import android.provider.Settings;
-import android.service.notification.NotificationListenerService.Ranking;
-
-/** These settings are per topic, so should not be returned in global search results. */
-public class TopicNotificationSettings extends NotificationSettingsBase {
-    private static final String TAG = "TopicNotiSettings";
-    private TopicRow mTopicRow;
-    private boolean mDndVisualEffectsSuppressed;
-
-    @Override
-    public void onActivityCreated(Bundle savedInstanceState) {
-        super.onActivityCreated(savedInstanceState);
-        if (mTopicRow == null) return;
-        AppHeader.createAppHeader(
-                this, mTopicRow.icon, mTopicRow.label, mTopicRow.pkg, mTopicRow.uid);
-    }
-
-    @Override
-    protected int getMetricsCategory() {
-        return MetricsEvent.NOTIFICATION_TOPIC_NOTIFICATION;
-    }
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        NotificationManager.Policy policy =
-                NotificationManager.from(mContext).getNotificationPolicy();
-        mDndVisualEffectsSuppressed = policy == null ? false : policy.suppressedVisualEffects != 0;
-
-        if (mTopic == null) {
-            toastAndFinish();
-            return;
-        }
-
-        addPreferencesFromResource(R.xml.topic_notification_settings);
-        mTopicRow = mBackend.loadTopicRow(mPm, mPkgInfo, mTopic);
-
-        mImportance = (ImportanceSeekBarPreference) findPreference(KEY_IMPORTANCE);
-        mImportanceReset = (LayoutPreference) findPreference(KEY_IMPORTANCE_RESET);
-        mImportanceTitle = (RestrictedPreference) findPreference(KEY_IMPORTANCE_TITLE);
-        mPriority = (RestrictedSwitchPreference) findPreference(KEY_BYPASS_DND);
-        mSensitive = (RestrictedSwitchPreference) findPreference(KEY_SENSITIVE);
-
-        setupImportancePrefs(mTopicRow.systemApp, mTopicRow.importance);
-        setupPriorityPref(mTopicRow.priority);
-        setupSensitivePref(mTopicRow.sensitive);
-
-        updateDependents(mTopicRow.importance);
-    }
-
-    @Override
-    protected void updateDependents(int importance) {
-        final boolean lockscreenSecure = new LockPatternUtils(getActivity()).isSecure(
-                UserHandle.myUserId());
-        final boolean lockscreenNotificationsEnabled = getLockscreenNotificationsEnabled();
-        final boolean allowPrivate = getLockscreenAllowPrivateNotifications();
-
-        setVisible(mPriority, checkCanBeVisible(Ranking.IMPORTANCE_DEFAULT, importance)
-                && !mDndVisualEffectsSuppressed);
-        setVisible(mSensitive, checkCanBeVisible(Ranking.IMPORTANCE_LOW, importance)
-                && lockscreenSecure && lockscreenNotificationsEnabled && allowPrivate);
-    }
-
-    protected boolean checkCanBeVisible(int minImportanceVisible, int importance) {
-        if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
-            return true;
-        }
-        return importance > minImportanceVisible;
-    }
-
-    private boolean getLockscreenNotificationsEnabled() {
-        return Settings.Secure.getInt(getContentResolver(),
-                Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
-    }
-
-    private boolean getLockscreenAllowPrivateNotifications() {
-        return Settings.Secure.getInt(getContentResolver(),
-                Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0) != 0;
-    }
-}
