Merge "Don't show NLSes with excessively long component names" into tm-qpr-dev am: 7626600bbf

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/22066389

Change-Id: I90173ce86cc356ba97e4ff51dffd6b6588bb0c49
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/settings/notification/NotificationAccessSettings.java b/src/com/android/settings/notification/NotificationAccessSettings.java
index 4ec9ccd..56d3f0e 100644
--- a/src/com/android/settings/notification/NotificationAccessSettings.java
+++ b/src/com/android/settings/notification/NotificationAccessSettings.java
@@ -65,6 +65,7 @@
     private static final String TAG = "NotifAccessSettings";
     private static final String ALLOWED_KEY = "allowed";
     private static final String NOT_ALLOWED_KEY = "not_allowed";
+    private static final int MAX_CN_LENGTH = 500;
 
     private static final ManagedServiceSettings.Config CONFIG =
             new ManagedServiceSettings.Config.Builder()
@@ -101,6 +102,12 @@
                 .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);