From 173cc267e0fb854cc7247e9f1e3acff0a325c4af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Hern=C3=A1ndez?= Date: Mon, 5 Jun 2023 19:10:00 +0200 Subject: [PATCH] DO NOT MERGE Don't hide approved NLSes in Settings Note that an NLS that shouldn't be approvable (because its name is too long) but was already approved (either before the max length check was introduced, or through other means) will disappear from the list if the user revokes its access. This might be somewhat confusing, but since this is a very-edge case already it's fine. Bug: 282932362 Test: manual Change-Id: Iccfe7b53d643d6c9f9516f91d3cee3309b11551e --- .../notification/NotificationAccessSettings.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/com/android/settings/notification/NotificationAccessSettings.java b/src/com/android/settings/notification/NotificationAccessSettings.java index 71e58e40b55..79e75bd822c 100644 --- a/src/com/android/settings/notification/NotificationAccessSettings.java +++ b/src/com/android/settings/notification/NotificationAccessSettings.java @@ -94,12 +94,6 @@ public class NotificationAccessSettings extends EmptyTextSettings { .setNoun(CONFIG.noun) .setSetting(CONFIG.setting) .setTag(CONFIG.tag) - .setValidator(info -> { - if (info.getComponentName().flattenToString().length() > MAX_CN_LENGTH) { - return false; - } - return true; - }) .build(); mServiceListing.addCallback(this::updateList); setPreferenceScreen(getPreferenceManager().createPreferenceScreen(mContext)); @@ -140,6 +134,11 @@ public class NotificationAccessSettings extends EmptyTextSettings { services.sort(new PackageItemInfo.DisplayNameComparator(mPm)); for (ServiceInfo service : services) { final ComponentName cn = new ComponentName(service.packageName, service.name); + boolean isAllowed = mNm.isNotificationListenerAccessGranted(cn); + if (!isAllowed && cn.flattenToString().length() > MAX_CN_LENGTH) { + continue; + } + CharSequence title = null; try { title = mPm.getApplicationInfoAsUser( @@ -154,7 +153,7 @@ public class NotificationAccessSettings extends EmptyTextSettings { pref.setIcon(mIconDrawableFactory.getBadgedIcon(service, service.applicationInfo, UserHandle.getUserId(service.applicationInfo.uid))); pref.setKey(cn.flattenToString()); - pref.setSummary(mNm.isNotificationListenerAccessGranted(cn) + pref.setSummary(isAllowed ? R.string.app_permission_summary_allowed : R.string.app_permission_summary_not_allowed); if (managedProfileId != UserHandle.USER_NULL