From 79cb59e618138c89d9b006adf9228886117cb4cf Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Tue, 7 Mar 2023 15:44:29 -0500 Subject: [PATCH] Don't show NLSes with excessively long component names Test: install test app with long CN Test: ServiceListingTest Bug: 260570119 Change-Id: I3ffd02f6cf6bf282e7fc264fd070ed3add4d8571 Merged-In: I3ffd02f6cf6bf282e7fc264fd070ed3add4d8571 --- .../notification/NotificationAccessSettings.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/com/android/settings/notification/NotificationAccessSettings.java b/src/com/android/settings/notification/NotificationAccessSettings.java index 9df548c53bb..71e58e40b55 100644 --- a/src/com/android/settings/notification/NotificationAccessSettings.java +++ b/src/com/android/settings/notification/NotificationAccessSettings.java @@ -57,6 +57,9 @@ import java.util.List; @SearchIndexable public class NotificationAccessSettings extends EmptyTextSettings { private static final String TAG = "NotifAccessSettings"; + + private static final int MAX_CN_LENGTH = 500; + private static final ManagedServiceSettings.Config CONFIG = new ManagedServiceSettings.Config.Builder() .setTag(TAG) @@ -91,6 +94,12 @@ 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));