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

Commit 79728a9b authored by Aishwarya Mallampati's avatar Aishwarya Mallampati
Browse files

Return only subscriptions associted with user for work profile.

Bug: 289197367
Test: Flashed build on raven-userdebug: calls and sms are working fine.
atest SubscriptionManagerServiceTest,
atest com.android.providers.telephony.SmsProviderTest,
atest com.android.providers.telephony.MmsProviderTest,
atest com.android.providers.telephony.ProviderUtilTest,
atest CtsTelephonyProviderTestCases,
atest CtsTelephonyTestCases

Change-Id: Ia143f9c8de146be0de09973cb15c5a949b988937
parent 03001d6c
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