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

Commit c807256a authored by Aishwarya Mallampati's avatar Aishwarya Mallampati Committed by Automerger Merge Worker
Browse files

Merge "Do not throw InvalidArgumentException." into udc-qpr-dev am: f45953e9 am: 38d5c2fd

parents 47f87a66 38d5c2fd
Loading
Loading
Loading
Loading
+3 −4
Original line number Original line Diff line number Diff line
@@ -3546,10 +3546,10 @@ public class SubscriptionManagerService extends ISub.Stub {
     *
     *
     * @param subId the unique SubscriptionInfo index in database
     * @param subId the unique SubscriptionInfo index in database
     * @return userHandle associated with this subscription
     * @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 SecurityException if doesn't have required permission.
     * @throws IllegalArgumentException if {@code subId} is invalid.
     */
     */
    @Override
    @Override
    @Nullable
    @Nullable
@@ -3562,8 +3562,7 @@ public class SubscriptionManagerService extends ISub.Stub {
            SubscriptionInfoInternal subInfo = mSubscriptionDatabaseManager
            SubscriptionInfoInternal subInfo = mSubscriptionDatabaseManager
                    .getSubscriptionInfoInternal(subId);
                    .getSubscriptionInfoInternal(subId);
            if (subInfo == null) {
            if (subInfo == null) {
                throw new IllegalArgumentException("getSubscriptionUserHandle: Invalid subId: "
                return null;
                        + subId);
            }
            }


            UserHandle userHandle = UserHandle.of(subInfo.getUserId());
            UserHandle userHandle = UserHandle.of(subInfo.getUserId());
+13 −0
Original line number Original line Diff line number Diff line
@@ -1063,6 +1063,19 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
                .isEqualTo(FAKE_USER_HANDLE);
                .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
    @Test
    public void testIsSubscriptionAssociatedWithUser() {
    public void testIsSubscriptionAssociatedWithUser() {
        insertSubscription(FAKE_SUBSCRIPTION_INFO1);
        insertSubscription(FAKE_SUBSCRIPTION_INFO1);