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

Commit 2562902d authored by Sergey Nikolaienkov's avatar Sergey Nikolaienkov
Browse files

Fix usages of getCallingUserId()/Uid() in CdmService

Bug: 208945927
Test: atest CtsCompanionDevicesTestCases
Change-Id: I1f2fcde1b25f80537bffd729afdf47cd84122515
parent 66dfc76f
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -406,9 +406,8 @@ public class CompanionDeviceManagerService extends SystemService {

        @Override
        public List<AssociationInfo> getAssociations(String packageName, int userId) {
            final int callingUid = getCallingUserId();
            if (!checkCallerCanManageAssociationsForPackage(getContext(), userId, packageName)) {
                throw new SecurityException("Caller (uid=" + callingUid + ") does not have "
                throw new SecurityException("Caller (uid=" + getCallingUid() + ") does not have "
                        + "permissions to get associations for u" + userId + "/" + packageName);
            }

+2 −2
Original line number Diff line number Diff line
@@ -154,14 +154,14 @@ final class PermissionsUtils {
    }

    static boolean checkCallerCanManageCompanionDevice(@NonNull Context context) {
        if (getCallingUserId() == SYSTEM_UID) return true;
        if (getCallingUid() == SYSTEM_UID) return true;

        return context.checkCallingPermission(MANAGE_COMPANION_DEVICES) == PERMISSION_GRANTED;
    }

    static void enforceCallerCanManagerCompanionDevice(@NonNull Context context,
            @Nullable String message) {
        if (getCallingUserId() == SYSTEM_UID) return;
        if (getCallingUid() == SYSTEM_UID) return;

        context.enforceCallingPermission(MANAGE_COMPANION_DEVICES, message);
    }