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

Commit f45953e9 authored by Aishwarya Mallampati's avatar Aishwarya Mallampati Committed by Android (Google) Code Review
Browse files

Merge "Do not throw InvalidArgumentException." into udc-qpr-dev

parents eac54a33 38155c89
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -3546,10 +3546,10 @@ public class SubscriptionManagerService extends ISub.Stub {
     *
     * @param subId the unique SubscriptionInfo index in database
     * @return userHandle associated with this subscription
     * or {@code null} if subscription is not associated with any user.
     * or {@code null} if subscription is not associated with any user
     * or {code null} if subscripiton is not available on the device.
     *
     * @throws SecurityException if doesn't have required permission.
     * @throws IllegalArgumentException if {@code subId} is invalid.
     */
    @Override
    @Nullable
@@ -3562,8 +3562,7 @@ public class SubscriptionManagerService extends ISub.Stub {
            SubscriptionInfoInternal subInfo = mSubscriptionDatabaseManager
                    .getSubscriptionInfoInternal(subId);
            if (subInfo == null) {
                throw new IllegalArgumentException("getSubscriptionUserHandle: Invalid subId: "
                        + subId);
                return null;
            }

            UserHandle userHandle = UserHandle.of(subInfo.getUserId());
+13 −0
Original line number Diff line number Diff line
@@ -1063,6 +1063,19 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
                .isEqualTo(FAKE_USER_HANDLE);
    }

    @Test
    public void testGetSubscriptionUserHandleUnknownSubscription() {
        mContextFixture.addCallingOrSelfPermission(
                Manifest.permission.MANAGE_SUBSCRIPTION_USER_ASSOCIATION);

        // getSubscriptionUserHandle() returns null when subscription is not available on the device
        assertThat(mSubscriptionManagerServiceUT.getSubscriptionUserHandle(10))
                .isEqualTo(null);

        mContextFixture.removeCallingOrSelfPermission(
                Manifest.permission.MANAGE_SUBSCRIPTION_USER_ASSOCIATION);
    }

    @Test
    public void testIsSubscriptionAssociatedWithUser() {
        insertSubscription(FAKE_SUBSCRIPTION_INFO1);