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

Commit 72c0ad94 authored by Jack Yu's avatar Jack Yu Committed by Android (Google) Code Review
Browse files

Merge "Fixed incorrect permission check" into main

parents 30df24c4 b3843f62
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line 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.
     * Returns whether the given subscription is associated with the calling user.
     *
     *
     * @param subscriptionId the subscription ID of the subscription
     * @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
     * @return {@code true} if the subscription is associated with the user that the calling process
     *         is running in; {@code false} otherwise.
     *         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.
     * @throws SecurityException if the caller doesn't have permissions required.
     */
     */
    @Override
    @Override
    public boolean isSubscriptionAssociatedWithCallingUser(int subscriptionId) {
    public boolean isSubscriptionAssociatedWithCallingUser(int subscriptionId,
        enforcePermissions("isSubscriptionAssociatedWithCallingUser",
            @NonNull String callingPackage, @Nullable String callingFeatureId) {
                Manifest.permission.READ_PHONE_STATE);
        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());
        UserHandle myUserHandle = UserHandle.of(UserHandle.getCallingUserId());
        return mFeatureFlags.subscriptionUserAssociationQuery()
        return mFeatureFlags.subscriptionUserAssociationQuery()