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
This commit is contained in:
@@ -97,7 +97,7 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
|
|||||||
app == null ? null : ApplicationsState.getInstance(app), host);
|
app == null ? null : ApplicationsState.getInstance(app), host);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
|
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
|
||||||
RecentNotifyingAppsPreferenceController(Context context, NotificationBackend backend,
|
RecentNotifyingAppsPreferenceController(Context context, NotificationBackend backend,
|
||||||
IUsageStatsManager usageStatsManager, UserManager userManager,
|
IUsageStatsManager usageStatsManager, UserManager userManager,
|
||||||
ApplicationsState appState, Fragment host) {
|
ApplicationsState appState, Fragment host) {
|
||||||
@@ -118,7 +118,7 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
return true;
|
return mApplicationsState != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -307,9 +307,6 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
|
|||||||
if (appEntry == null) {
|
if (appEntry == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!shouldIncludePkgInRecents(app.getPackage(), app.getUserId())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
displayableApps.add(app);
|
displayableApps.add(app);
|
||||||
count++;
|
count++;
|
||||||
if (count >= SHOW_RECENT_APP_COUNT) {
|
if (count >= SHOW_RECENT_APP_COUNT) {
|
||||||
@@ -318,24 +315,4 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
|
|||||||
}
|
}
|
||||||
return displayableApps;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user