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

Commit c7a7913a authored by Nathan Harold's avatar Nathan Harold
Browse files

Allow canPackageManageGroup for new groups

-canPackageManageGroup currently blows up (IAE) when it is
 invoked on a group that doesn't yet exist. Since the carrier
 config API method of managing groups doesn't distinguish
 between creation and updating, and since there is no
 security reason to prevent management of a nonexistent
 group, update this function to allow packages to pass the
 canManage check for nonexistent groups.

-For addSubscriptionsToGroup() apply a separate check
 to disallow adding subscriptions to a nonexistent
 group via the API (preserving current behavior).

Bug: 133442394
Test: atest SubscriptionControllerTest
Change-Id: I08600b85c6410fbbce140937132456e22291bf37
parent 69715225
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -2920,8 +2920,10 @@ public class SubscriptionController extends ISub.Stub {
            Binder.restoreCallingIdentity(identity);
        }

        // If the group does not exist, then by default the UUID is up for grabs so no need to
        // restrict management of a group (that someone may be attempting to create).
        if (ArrayUtils.isEmpty(infoList)) {
            throw new IllegalArgumentException("No subscription in group " + groupUuid);
            return true;
        }

        // If the calling package is the group owner, skip carrier permission check and return
@@ -2963,6 +2965,12 @@ public class SubscriptionController extends ISub.Stub {
            throw new IllegalArgumentException("Invalid groupUuid");
        }

        // TODO: Revisit whether we need this restriction in R. There's no technical need for it,
        // but we don't want to change the API behavior at this time.
        if (getSubscriptionsInGroup(groupUuid, callingPackage).isEmpty()) {
            throw new IllegalArgumentException("Cannot add subscriptions to a non-existent group!");
        }

        // Makes sure calling package matches caller UID.
        mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
        // If it doesn't have modify phone state permission, or carrier privilege permission,