aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAishwarya Mallampati <amallampati@google.com>2023-06-28 17:22:31 +0000
committerAishwarya Mallampati <amallampati@google.com>2023-06-28 21:34:21 +0000
commit79728a9bb1acf16043365fcf58ad6d1c117917b9 (patch)
treeeb715b2183e85164e53a60a4f8a1a20e5a5040c1
parent03001d6cc6aa64b79153210ac6908abf918b81ce (diff)
downloadtelephony-79728a9bb1acf16043365fcf58ad6d1c117917b9.tar.gz
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
-rw-r--r--src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java10
-rw-r--r--tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionManagerServiceTest.java12
2 files changed, 22 insertions, 0 deletions
diff --git a/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java b/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java
index f9720df6f1..8e773c072d 100644
--- a/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java
+++ b/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java
@@ -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 {
diff --git a/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionManagerServiceTest.java b/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionManagerServiceTest.java
index 38b495aaca..3abfac79e8 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionManagerServiceTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionManagerServiceTest.java
@@ -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