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

Commit be1db32a authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/23846471'] into udc-release.

Change-Id: I4808a913da9787b5be5aeda19b3b270b5dcf3e7d
parents f286f048 c34ea1b7
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import android.os.Process;
import android.os.RemoteException;
import android.os.TelephonyServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.provider.Telephony.SimInfo;
import android.service.carrier.CarrierIdentifier;
@@ -3665,6 +3666,15 @@ public class SubscriptionManagerService extends ISub.Stub {
                }
            }

            UserManager userManager = mContext.getSystemService(UserManager.class);
            if ((userManager != null)
                    && (userManager.isManagedProfile(userHandle.getIdentifier()))) {
                // For work profile, return subscriptions associated only with work profile
                return subscriptionsAssociatedWithUser;
            }

            // For all other profiles, if subscriptionsAssociatedWithUser is empty return all the
            // subscriptionsWithNoAssociation.
            return subscriptionsAssociatedWithUser.isEmpty() ?
                    subscriptionsWithNoAssociation : subscriptionsAssociatedWithUser;
        } finally {
+12 −0
Original line number Diff line number Diff line
@@ -146,6 +146,8 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {

    private static final UserHandle FAKE_USER_HANDLE = new UserHandle(12);

    private static final UserHandle FAKE_MANAGED_PROFILE_USER_HANDLE = new UserHandle(13);

    // mocked
    private SubscriptionManagerServiceCallback mMockedSubscriptionManagerServiceCallback;
    private EuiccController mEuiccController;
@@ -212,6 +214,9 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
        setIdentifierAccess(false);
        setPhoneNumberAccess(PackageManager.PERMISSION_DENIED);

        doReturn(true).when(mUserManager)
                .isManagedProfile(eq(FAKE_MANAGED_PROFILE_USER_HANDLE.getIdentifier()));

        logd("SubscriptionManagerServiceTest -Setup!");
    }

@@ -1081,6 +1086,13 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {

        assertThat(mSubscriptionManagerServiceUT.isSubscriptionAssociatedWithUser(1,
                FAKE_USER_HANDLE)).isEqualTo(true);

        // Work profile is not associated with any subscription
        associatedSubInfoList = mSubscriptionManagerServiceUT
                .getSubscriptionInfoListAssociatedWithUser(FAKE_MANAGED_PROFILE_USER_HANDLE);
        assertThat(associatedSubInfoList.size()).isEqualTo(0);
        assertThat(mSubscriptionManagerServiceUT.isSubscriptionAssociatedWithUser(1,
                FAKE_MANAGED_PROFILE_USER_HANDLE)).isEqualTo(false);
    }

    @Test