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

Commit b3843f62 authored by Jack Yu's avatar Jack Yu
Browse files

Fixed incorrect permission check

isSubscriptionAssociatedWithUser API should also allow callers
with READ_PRIVILEGED_PHONE_STATE permission to access

Bug: 394859326
Test: atest SubscriptionManagerTests
Test: Basic telephony functionality tests
Flag: EXEMPT bug fix
Change-Id: Ifc10e38a471514c30c3d94b7e98e737e31230133
parent 21133d63
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -4129,6 +4129,9 @@ public class SubscriptionManagerService extends ISub.Stub {
     * Returns whether the given subscription is associated with the calling user.
     *
     * @param subscriptionId the subscription ID of the subscription
     * @param callingPackage The package making the call
     * @param callingFeatureId The feature in the package
     *
     * @return {@code true} if the subscription is associated with the user that the calling process
     *         is running in; {@code false} otherwise.
     *
@@ -4136,9 +4139,13 @@ public class SubscriptionManagerService extends ISub.Stub {
     * @throws SecurityException if the caller doesn't have permissions required.
     */
    @Override
    public boolean isSubscriptionAssociatedWithCallingUser(int subscriptionId) {
        enforcePermissions("isSubscriptionAssociatedWithCallingUser",
                Manifest.permission.READ_PHONE_STATE);
    public boolean isSubscriptionAssociatedWithCallingUser(int subscriptionId,
            @NonNull String callingPackage, @Nullable String callingFeatureId) {
        if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, subscriptionId,
                callingPackage, callingFeatureId, "isSubscriptionAssociatedWithCallingUser")) {
            throw new SecurityException("Need READ_PHONE_STATE, READ_PRIVILEGED_PHONE_STATE, or "
                    + "carrier privilege");
        }

        UserHandle myUserHandle = UserHandle.of(UserHandle.getCallingUserId());
        return mFeatureFlags.subscriptionUserAssociationQuery()