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

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

Return only subscriptions associted with user for work profile. am: 79728a9b...

Return only subscriptions associted with user for work profile. am: 79728a9b am: 5169e9c8 am: 39cb1d79

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/23846471



Change-Id: I9fc43bcf3c7fe127713885ab8d9c919d88f4c5c3
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 594889e5 39cb1d79
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