Merge "Part2 - Don't add padlock if the restriction is not set by admin." into nyc-dev
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;
-    }
-}