From f356ced8d7aee75ee2c18debcaf3d87b73e45af6 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Mon, 11 Nov 2019 11:33:18 -0500 Subject: [PATCH] Remove filtering from "recent sent" notifs preference The 'has a launch intent' filter was inherited from 'recent apps' preference but an app doesn't need a launch intent in order to send notifications. Also, the next screen didn't apply the filter so the data wouldn't always match up. Also make the preferencecontroller more robust to failure. Test: manual, trigger a notification from a non-launchable app and makes sure it appears in the list Fixes: 141380329 Fixes: 142956641 Change-Id: Icf3abead82c572bbffe6e06ecf51a8e02c11c982 --- ...centNotifyingAppsPreferenceController.java | 27 ++----------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java index 9b20e7a4fd1..9efe34e4e1c 100644 --- a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java +++ b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java @@ -97,7 +97,7 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC app == null ? null : ApplicationsState.getInstance(app), host); } - @VisibleForTesting(otherwise = VisibleForTesting.NONE) + @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) RecentNotifyingAppsPreferenceController(Context context, NotificationBackend backend, IUsageStatsManager usageStatsManager, UserManager userManager, ApplicationsState appState, Fragment host) { @@ -118,7 +118,7 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC @Override public boolean isAvailable() { - return true; + return mApplicationsState != null; } @Override @@ -307,9 +307,6 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC if (appEntry == null) { continue; } - if (!shouldIncludePkgInRecents(app.getPackage(), app.getUserId())) { - continue; - } displayableApps.add(app); count++; if (count >= SHOW_RECENT_APP_COUNT) { @@ -318,24 +315,4 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC } return displayableApps; } - - - /** - * Whether or not the app should be included in recent list. - */ - private boolean shouldIncludePkgInRecents(String pkgName, int userId) { - final Intent launchIntent = new Intent().addCategory(Intent.CATEGORY_LAUNCHER) - .setPackage(pkgName); - - if (mPm.resolveActivity(launchIntent, 0) == null) { - // Not visible on launcher -> likely not a user visible app, skip if non-instant. - final ApplicationsState.AppEntry appEntry = - mApplicationsState.getEntry(pkgName, userId); - if (appEntry == null || appEntry.info == null || !AppUtils.isInstant(appEntry.info)) { - Log.d(TAG, "Not a user visible or instant app, skipping " + pkgName); - return false; - } - } - return true; - } }