From 63f74b85677f12e929fbb5ac95384b2fa4132f4f Mon Sep 17 00:00:00 2001 From: Ling Ma Date: Mon, 22 Jan 2024 22:02:00 +0000 Subject: [PATCH] Wrap subManager creation with createForAllProfiles Since U, a sub can be associated with a particular profile, and thus in V we enforce filtering on the caller and only show the subs that are associated with the caller. However, in some cases the caller indeed needs to see all subs regardless of its association, e.g. sysUI. Therefore, a param isForAllProfile is added to indicate whether the caller intends to see all subs. Bug: 296076674 Test: voice call + data browsing Flag: ACONFIG com.android.internal.telephony.flags.enforce_subscription_user_filter DEVELOPMENT Change-Id: I7dfb324d7e08fc4c845c44cd93e6ddf7d0368c1f --- .../settings/security/SimLockPreferenceController.java | 5 +++-- .../settings/security/SimLockPreferenceControllerTest.java | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/security/SimLockPreferenceController.java b/src/com/android/settings/security/SimLockPreferenceController.java index 8429a9f352c..8cc72342e0e 100644 --- a/src/com/android/settings/security/SimLockPreferenceController.java +++ b/src/com/android/settings/security/SimLockPreferenceController.java @@ -44,8 +44,9 @@ public class SimLockPreferenceController extends BasePreferenceController { mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE); mCarrierConfigManager = (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE); - mSubscriptionManager = (SubscriptionManager) context - .getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE); + mSubscriptionManager = ((SubscriptionManager) context + .getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)) + .createForAllUserProfiles(); mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); } diff --git a/tests/robotests/src/com/android/settings/security/SimLockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/SimLockPreferenceControllerTest.java index f38cc4948d4..10e397c1b14 100644 --- a/tests/robotests/src/com/android/settings/security/SimLockPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/security/SimLockPreferenceControllerTest.java @@ -77,6 +77,7 @@ public class SimLockPreferenceControllerTest { ShadowApplication shadowApplication = ShadowApplication.getInstance(); shadowApplication.setSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE, mSubscriptionManager); + when(mSubscriptionManager.createForAllUserProfiles()).thenReturn(mSubscriptionManager); shadowApplication.setSystemService(Context.CARRIER_CONFIG_SERVICE, mCarrierManager); shadowApplication.setSystemService(Context.USER_SERVICE, mUserManager); shadowApplication.setSystemService(Context.TELEPHONY_SERVICE, mTelephonyManager);