use of com.android.settings.homepage.contextualcards.slices.ContextualNotificationChannelSlice.PREFS in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NotificationChannelWorker method removeUninstalledPackages.
private void removeUninstalledPackages() {
final SharedPreferences prefs = getContext().getSharedPreferences(PREFS, MODE_PRIVATE);
final Set<String> interactedPackages = prefs.getStringSet(PREF_KEY_INTERACTED_PACKAGES, new ArraySet());
if (interactedPackages.isEmpty()) {
return;
}
final List<PackageInfo> installedPackageInfos = getContext().getPackageManager().getInstalledPackages(0);
final List<String> installedPackages = installedPackageInfos.stream().map(packageInfo -> packageInfo.packageName).collect(Collectors.toList());
final Set<String> newInteractedPackages = new ArraySet<>();
for (String packageName : interactedPackages) {
if (installedPackages.contains(packageName)) {
newInteractedPackages.add(packageName);
}
}
prefs.edit().putStringSet(PREF_KEY_INTERACTED_PACKAGES, newInteractedPackages).apply();
}
Aggregations