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
diff --git a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
index 9b20e7a..9efe34e 100644
--- a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
+++ b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
@@ -97,7 +97,7 @@
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 @@
@Override
public boolean isAvailable() {
- return true;
+ return mApplicationsState != null;
}
@Override
@@ -307,9 +307,6 @@
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 @@
}
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;
- }
}