Skip to content

Commit

Permalink
Don't show NLSes with excessively long component names
Browse files Browse the repository at this point in the history
Test: install test app with long CN
Test: ServiceListingTest
Bug: 260570119
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:793257967f165970f8cb0f4cebddab9dcd5d8353)
Merged-In: I3ffd02f6cf6bf282e7fc264fd070ed3add4d8571
Change-Id: I3ffd02f6cf6bf282e7fc264fd070ed3add4d8571
  • Loading branch information
Julia Reynolds authored and thestinger committed Jun 7, 2023
1 parent a299e0e commit 61d1522
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class NotificationAccessSettings extends EmptyTextSettings {
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()
Expand Down Expand Up @@ -101,6 +102,12 @@ public void onCreate(Bundle icicle) {
.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);

Expand Down

0 comments on commit 61d1522

Please sign in to comment.