Loading src/com/android/settings/notification/AppNotificationSettings.java +0 −45 Original line number Diff line number Diff line Loading @@ -61,11 +61,6 @@ public class AppNotificationSettings extends NotificationSettingsBase { private static final String TAG = "AppNotificationSettings"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final Intent APP_NOTIFICATION_PREFS_CATEGORY_INTENT = new Intent(Intent.ACTION_MAIN) .addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES); private static final String KEY_CHANNELS = "channels"; private static final String KEY_BLOCK = "block"; private DashboardFeatureProvider mDashboardFeatureProvider; Loading Loading @@ -270,46 +265,6 @@ public class AppNotificationSettings extends NotificationSettingsBase { setVisible(mBadge, !banned); } private List<ResolveInfo> queryNotificationConfigActivities() { if (DEBUG) Log.d(TAG, "APP_NOTIFICATION_PREFS_CATEGORY_INTENT is " + APP_NOTIFICATION_PREFS_CATEGORY_INTENT); final List<ResolveInfo> resolveInfos = mPm.queryIntentActivities( APP_NOTIFICATION_PREFS_CATEGORY_INTENT, 0 //PackageManager.MATCH_DEFAULT_ONLY ); return resolveInfos; } private void collectConfigActivities(ArrayMap<String, AppRow> rows) { final List<ResolveInfo> resolveInfos = queryNotificationConfigActivities(); applyConfigActivities(rows, resolveInfos); } private void applyConfigActivities(ArrayMap<String, AppRow> rows, List<ResolveInfo> resolveInfos) { if (DEBUG) Log.d(TAG, "Found " + resolveInfos.size() + " preference activities" + (resolveInfos.size() == 0 ? " ;_;" : "")); for (ResolveInfo ri : resolveInfos) { final ActivityInfo activityInfo = ri.activityInfo; final ApplicationInfo appInfo = activityInfo.applicationInfo; final AppRow row = rows.get(appInfo.packageName); if (row == null) { if (DEBUG) Log.v(TAG, "Ignoring notification preference activity (" + activityInfo.name + ") for unknown package " + activityInfo.packageName); continue; } if (row.settingsIntent != null) { if (DEBUG) Log.v(TAG, "Ignoring duplicate notification preference activity (" + activityInfo.name + ") for package " + activityInfo.packageName); continue; } row.settingsIntent = new Intent(APP_NOTIFICATION_PREFS_CATEGORY_INTENT) .setClassName(activityInfo.packageName, activityInfo.name); } } private Comparator<NotificationChannel> mChannelComparator = new Comparator<NotificationChannel>() { private final Collator sCollator = Collator.getInstance(); Loading src/com/android/settings/notification/ChannelNotificationSettings.java +9 −1 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.provider.Settings; import android.service.notification.NotificationListenerService.Ranking; import android.support.v7.preference.Preference; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; Loading Loading @@ -98,6 +99,12 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { FeatureFactory.getFactory(activity).getDashboardFeatureProvider(activity); addPreferencesFromResource(R.xml.channel_notification_settings); // load settings intent ArrayMap<String, NotificationBackend.AppRow> rows = new ArrayMap<String, NotificationBackend.AppRow>(); rows.put(mAppRow.pkg, mAppRow); collectConfigActivities(rows); mBlock = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BLOCK); mBadge = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BADGE); mImportance = (RestrictedDropDownPreference) findPreference(KEY_IMPORTANCE); Loading Loading @@ -127,8 +134,9 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { .setSummary(mAppRow.label) .setPackageName(mAppRow.pkg) .setUid(mAppRow.uid) .setAppNotifPrefIntent(mAppRow.settingsIntent) .setButtonActions(AppHeaderController.ActionType.ACTION_APP_INFO, AppHeaderController.ActionType.ACTION_NONE) AppHeaderController.ActionType.ACTION_NOTIF_PREFERENCE) .done(getPrefContext()); getPreferenceScreen().addPreference(pref); } Loading src/com/android/settings/notification/NotificationSettingsBase.java +54 −0 Original line number Diff line number Diff line Loading @@ -23,28 +23,39 @@ import com.android.settings.applications.AppInfoBase; import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedSwitchPreference; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.os.Bundle; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; import android.support.v7.preference.Preference; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; import android.widget.Toast; import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; import java.util.List; abstract public class NotificationSettingsBase extends SettingsPreferenceFragment { private static final String TAG = "NotifiSettingsBase"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final Intent APP_NOTIFICATION_PREFS_CATEGORY_INTENT = new Intent(Intent.ACTION_MAIN) .addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES); protected static final String KEY_BLOCK = "block"; protected static final String KEY_BADGE = "badge"; Loading Loading @@ -155,6 +166,49 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen getActivity().finish(); } private List<ResolveInfo> queryNotificationConfigActivities() { if (DEBUG) Log.d(TAG, "APP_NOTIFICATION_PREFS_CATEGORY_INTENT is " + APP_NOTIFICATION_PREFS_CATEGORY_INTENT); final List<ResolveInfo> resolveInfos = mPm.queryIntentActivities( APP_NOTIFICATION_PREFS_CATEGORY_INTENT, 0 //PackageManager.MATCH_DEFAULT_ONLY ); return resolveInfos; } protected void collectConfigActivities(ArrayMap<String, NotificationBackend.AppRow> rows) { final List<ResolveInfo> resolveInfos = queryNotificationConfigActivities(); applyConfigActivities(rows, resolveInfos); } private void applyConfigActivities(ArrayMap<String, NotificationBackend.AppRow> rows, List<ResolveInfo> resolveInfos) { if (DEBUG) Log.d(TAG, "Found " + resolveInfos.size() + " preference activities" + (resolveInfos.size() == 0 ? " ;_;" : "")); for (ResolveInfo ri : resolveInfos) { final ActivityInfo activityInfo = ri.activityInfo; final ApplicationInfo appInfo = activityInfo.applicationInfo; final NotificationBackend.AppRow row = rows.get(appInfo.packageName); if (row == null) { if (DEBUG) Log.v(TAG, "Ignoring notification preference activity (" + activityInfo.name + ") for unknown package " + activityInfo.packageName); continue; } if (row.settingsIntent != null) { if (DEBUG) Log.v(TAG, "Ignoring duplicate notification preference activity (" + activityInfo.name + ") for package " + activityInfo.packageName); continue; } row.settingsIntent = new Intent(APP_NOTIFICATION_PREFS_CATEGORY_INTENT) .setClassName(activityInfo.packageName, activityInfo.name); if (mChannel != null) { row.settingsIntent.putExtra(Notification.EXTRA_CHANNEL_ID, mChannel.getId()); } } } private PackageInfo findPackageInfo(String pkg, int uid) { if (pkg == null || uid < 0) { return null; Loading Loading
src/com/android/settings/notification/AppNotificationSettings.java +0 −45 Original line number Diff line number Diff line Loading @@ -61,11 +61,6 @@ public class AppNotificationSettings extends NotificationSettingsBase { private static final String TAG = "AppNotificationSettings"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final Intent APP_NOTIFICATION_PREFS_CATEGORY_INTENT = new Intent(Intent.ACTION_MAIN) .addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES); private static final String KEY_CHANNELS = "channels"; private static final String KEY_BLOCK = "block"; private DashboardFeatureProvider mDashboardFeatureProvider; Loading Loading @@ -270,46 +265,6 @@ public class AppNotificationSettings extends NotificationSettingsBase { setVisible(mBadge, !banned); } private List<ResolveInfo> queryNotificationConfigActivities() { if (DEBUG) Log.d(TAG, "APP_NOTIFICATION_PREFS_CATEGORY_INTENT is " + APP_NOTIFICATION_PREFS_CATEGORY_INTENT); final List<ResolveInfo> resolveInfos = mPm.queryIntentActivities( APP_NOTIFICATION_PREFS_CATEGORY_INTENT, 0 //PackageManager.MATCH_DEFAULT_ONLY ); return resolveInfos; } private void collectConfigActivities(ArrayMap<String, AppRow> rows) { final List<ResolveInfo> resolveInfos = queryNotificationConfigActivities(); applyConfigActivities(rows, resolveInfos); } private void applyConfigActivities(ArrayMap<String, AppRow> rows, List<ResolveInfo> resolveInfos) { if (DEBUG) Log.d(TAG, "Found " + resolveInfos.size() + " preference activities" + (resolveInfos.size() == 0 ? " ;_;" : "")); for (ResolveInfo ri : resolveInfos) { final ActivityInfo activityInfo = ri.activityInfo; final ApplicationInfo appInfo = activityInfo.applicationInfo; final AppRow row = rows.get(appInfo.packageName); if (row == null) { if (DEBUG) Log.v(TAG, "Ignoring notification preference activity (" + activityInfo.name + ") for unknown package " + activityInfo.packageName); continue; } if (row.settingsIntent != null) { if (DEBUG) Log.v(TAG, "Ignoring duplicate notification preference activity (" + activityInfo.name + ") for package " + activityInfo.packageName); continue; } row.settingsIntent = new Intent(APP_NOTIFICATION_PREFS_CATEGORY_INTENT) .setClassName(activityInfo.packageName, activityInfo.name); } } private Comparator<NotificationChannel> mChannelComparator = new Comparator<NotificationChannel>() { private final Collator sCollator = Collator.getInstance(); Loading
src/com/android/settings/notification/ChannelNotificationSettings.java +9 −1 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.provider.Settings; import android.service.notification.NotificationListenerService.Ranking; import android.support.v7.preference.Preference; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; Loading Loading @@ -98,6 +99,12 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { FeatureFactory.getFactory(activity).getDashboardFeatureProvider(activity); addPreferencesFromResource(R.xml.channel_notification_settings); // load settings intent ArrayMap<String, NotificationBackend.AppRow> rows = new ArrayMap<String, NotificationBackend.AppRow>(); rows.put(mAppRow.pkg, mAppRow); collectConfigActivities(rows); mBlock = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BLOCK); mBadge = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BADGE); mImportance = (RestrictedDropDownPreference) findPreference(KEY_IMPORTANCE); Loading Loading @@ -127,8 +134,9 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { .setSummary(mAppRow.label) .setPackageName(mAppRow.pkg) .setUid(mAppRow.uid) .setAppNotifPrefIntent(mAppRow.settingsIntent) .setButtonActions(AppHeaderController.ActionType.ACTION_APP_INFO, AppHeaderController.ActionType.ACTION_NONE) AppHeaderController.ActionType.ACTION_NOTIF_PREFERENCE) .done(getPrefContext()); getPreferenceScreen().addPreference(pref); } Loading
src/com/android/settings/notification/NotificationSettingsBase.java +54 −0 Original line number Diff line number Diff line Loading @@ -23,28 +23,39 @@ import com.android.settings.applications.AppInfoBase; import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedSwitchPreference; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.os.Bundle; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; import android.support.v7.preference.Preference; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; import android.widget.Toast; import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; import java.util.List; abstract public class NotificationSettingsBase extends SettingsPreferenceFragment { private static final String TAG = "NotifiSettingsBase"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final Intent APP_NOTIFICATION_PREFS_CATEGORY_INTENT = new Intent(Intent.ACTION_MAIN) .addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES); protected static final String KEY_BLOCK = "block"; protected static final String KEY_BADGE = "badge"; Loading Loading @@ -155,6 +166,49 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen getActivity().finish(); } private List<ResolveInfo> queryNotificationConfigActivities() { if (DEBUG) Log.d(TAG, "APP_NOTIFICATION_PREFS_CATEGORY_INTENT is " + APP_NOTIFICATION_PREFS_CATEGORY_INTENT); final List<ResolveInfo> resolveInfos = mPm.queryIntentActivities( APP_NOTIFICATION_PREFS_CATEGORY_INTENT, 0 //PackageManager.MATCH_DEFAULT_ONLY ); return resolveInfos; } protected void collectConfigActivities(ArrayMap<String, NotificationBackend.AppRow> rows) { final List<ResolveInfo> resolveInfos = queryNotificationConfigActivities(); applyConfigActivities(rows, resolveInfos); } private void applyConfigActivities(ArrayMap<String, NotificationBackend.AppRow> rows, List<ResolveInfo> resolveInfos) { if (DEBUG) Log.d(TAG, "Found " + resolveInfos.size() + " preference activities" + (resolveInfos.size() == 0 ? " ;_;" : "")); for (ResolveInfo ri : resolveInfos) { final ActivityInfo activityInfo = ri.activityInfo; final ApplicationInfo appInfo = activityInfo.applicationInfo; final NotificationBackend.AppRow row = rows.get(appInfo.packageName); if (row == null) { if (DEBUG) Log.v(TAG, "Ignoring notification preference activity (" + activityInfo.name + ") for unknown package " + activityInfo.packageName); continue; } if (row.settingsIntent != null) { if (DEBUG) Log.v(TAG, "Ignoring duplicate notification preference activity (" + activityInfo.name + ") for package " + activityInfo.packageName); continue; } row.settingsIntent = new Intent(APP_NOTIFICATION_PREFS_CATEGORY_INTENT) .setClassName(activityInfo.packageName, activityInfo.name); if (mChannel != null) { row.settingsIntent.putExtra(Notification.EXTRA_CHANNEL_ID, mChannel.getId()); } } } private PackageInfo findPackageInfo(String pkg, int uid) { if (pkg == null || uid < 0) { return null; Loading