Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9532b691 authored by Raphael Kim's avatar Raphael Kim Committed by Android Build Coastguard Worker
Browse files

[CDM] Validate component name length before requesting notification access.

Bug: 295335110
Test: Test app with long component name
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:618767b6bf71b872399b57eb89c6724041258f45)
Merged-In: I7ea5d5c1f78858db9865f3310d1e0aff9c8b5579
Change-Id: I7ea5d5c1f78858db9865f3310d1e0aff9c8b5579
parent 6a9250ec
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ public class CompanionDeviceManagerService extends SystemService {
            "debug.cdm.cdmservice.removal_time_window";

    private static final long ASSOCIATION_REMOVAL_TIME_WINDOW_DEFAULT = DAYS.toMillis(90);
    private static final int MAX_CN_LENGTH = 500;

    private PersistentDataStore mPersistentStore;
    private final PersistUserStateHandler mUserPersistenceHandler;
@@ -541,6 +542,9 @@ public class CompanionDeviceManagerService extends SystemService {
            String callingPackage = component.getPackageName();
            checkCanCallNotificationApi(callingPackage);
            // TODO: check userId.
            if (component.flattenToString().length() > MAX_CN_LENGTH) {
                throw new IllegalArgumentException("Component name is too long.");
            }
            final long identity = Binder.clearCallingIdentity();
            try {
                return PendingIntent.getActivityAsUser(getContext(),