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

Commit 85c368a6 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: I9aa3953912d71fd2f2914361669c2ffb9bb417fd
parent b1d4e2ef
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -4821,10 +4821,14 @@ public class SubscriptionManager {
                    + "Invalid subscriptionId: " + subscriptionId);
        }

        String contextPkg = mContext != null ? mContext.getOpPackageName() : "<unknown>";
        String contextAttributionTag = mContext != null ? mContext.getAttributionTag() : null;

        try {
            ISub iSub = TelephonyManager.getSubscriptionService();
            if (iSub != null) {
                return iSub.isSubscriptionAssociatedWithCallingUser(subscriptionId);
                return iSub.isSubscriptionAssociatedWithCallingUser(subscriptionId, contextPkg,
                        contextAttributionTag);
            } else {
                throw new IllegalStateException("subscription service unavailable.");
            }
+5 −1
Original line number Diff line number Diff line
@@ -347,13 +347,17 @@ interface ISub {
     * Returns whether the given subscription is associated with the calling user.
     *
     * @param subscriptionId the subscription ID of the subscription
     * @param callingPackage The package maing the call
     * @param callingFeatureId The feature in the package

     * @return {@code true} if the subscription is associated with the user that the current process
     *         is running in; {@code false} otherwise.
     *
     * @throws IllegalArgumentException if subscription doesn't exist.
     * @throws SecurityException if the caller doesn't have permissions required.
     */
    boolean isSubscriptionAssociatedWithCallingUser(int subscriptionId);
    boolean isSubscriptionAssociatedWithCallingUser(int subscriptionId, String callingPackage,
            String callingFeatureId);

    /**
     * Check if subscription and user are associated with each other.