diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 38c2829e27f6dad724e5188b846835e6c2f74718..b7667a8669f40b2ffe01609ad21e82c55aca6142 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -34,6 +34,7 @@ import static android.hardware.biometrics.BiometricSourceType.FACE; import static android.hardware.biometrics.BiometricSourceType.FINGERPRINT; import static android.os.BatteryManager.BATTERY_STATUS_UNKNOWN; import static android.os.BatteryManager.CHARGING_POLICY_DEFAULT; +import static android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING; import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_ADAPTIVE_AUTH_REQUEST; import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT; @@ -437,7 +438,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } }; - private final OnSubscriptionsChangedListener mSubscriptionListener = + @VisibleForTesting + final OnSubscriptionsChangedListener mSubscriptionListener = new OnSubscriptionsChangedListener() { @Override public void onSubscriptionsChanged() { @@ -586,16 +588,14 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab private void handleSimSubscriptionInfoChanged() { Assert.isMainThread(); mLogger.v("onSubscriptionInfoChanged()"); - List<SubscriptionInfo> sil = mSubscriptionManager - .getCompleteActiveSubscriptionInfoList(); - if (sil != null) { - for (SubscriptionInfo subInfo : sil) { + List<SubscriptionInfo> subscriptionInfos = getSubscriptionInfo(true /* forceReload */); + if (!subscriptionInfos.isEmpty()) { + for (SubscriptionInfo subInfo : subscriptionInfos) { mLogger.logSubInfo(subInfo); } } else { mLogger.v("onSubscriptionInfoChanged: list is null"); } - List<SubscriptionInfo> subscriptionInfos = getSubscriptionInfo(true /* forceReload */); // Hack level over 9000: Because the subscription id is not yet valid when we see the // first update in handleSimStateChange, we need to force refresh all SIM states @@ -658,18 +658,18 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab /** * @return List of SubscriptionInfo records, maybe empty but never null. + * + * Note that this method will filter out any subscription which is PROFILE_CLASS_PROVISIONING */ public List<SubscriptionInfo> getSubscriptionInfo(boolean forceReload) { List<SubscriptionInfo> sil = mSubscriptionInfo; if (sil == null || forceReload) { - sil = mSubscriptionManager.getCompleteActiveSubscriptionInfoList(); - } - if (sil == null) { - // getCompleteActiveSubscriptionInfoList was null callers expect an empty list. - mSubscriptionInfo = new ArrayList<>(); - } else { - mSubscriptionInfo = sil; + mSubscriptionInfo = mSubscriptionManager.getCompleteActiveSubscriptionInfoList() + .stream() + .filter(subInfo -> subInfo.getProfileClass() != PROFILE_CLASS_PROVISIONING) + .toList(); } + return new ArrayList<>(mSubscriptionInfo); } diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java index 538daee523771b2453ac75f04d5569825f6af735..336a97ef09f41ec5c495197599b8a4f256303189 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java @@ -26,6 +26,8 @@ import static android.hardware.biometrics.SensorProperties.STRENGTH_STRONG; import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFPS_OPTICAL; import static android.telephony.SubscriptionManager.DATA_ROAMING_DISABLE; import static android.telephony.SubscriptionManager.NAME_SOURCE_CARRIER_ID; +import static android.telephony.SubscriptionManager.PROFILE_CLASS_DEFAULT; +import static android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING; import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST; import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN; @@ -187,6 +189,11 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { TEST_CARRIER, TEST_CARRIER_2, NAME_SOURCE_CARRIER_ID, 0xFFFFFF, "", DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", true, TEST_GROUP_UUID, TEST_CARRIER_ID, 0); + private static final SubscriptionInfo TEST_SUBSCRIPTION_PROVISIONING = new SubscriptionInfo( + 1, "", 0, + TEST_CARRIER, TEST_CARRIER, NAME_SOURCE_CARRIER_ID, 0xFFFFFF, "", + DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", false, TEST_GROUP_UUID, + TEST_CARRIER_ID, PROFILE_CLASS_PROVISIONING); private static final int FINGERPRINT_SENSOR_ID = 1; @Mock @@ -1204,7 +1211,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { assertThat(mKeyguardUpdateMonitor.mSimDatas.get(TEST_SUBSCRIPTION.getSubscriptionId())) .isNotNull(); - when(mSubscriptionManager.getCompleteActiveSubscriptionInfoList()).thenReturn(null); + when(mSubscriptionManager.getCompleteActiveSubscriptionInfoList()) + .thenReturn(new ArrayList<>()); mKeyguardUpdateMonitor.mPhoneStateListener.onActiveDataSubscriptionIdChanged( SubscriptionManager.INVALID_SUBSCRIPTION_ID); mTestableLooper.processAllMessages(); @@ -1215,6 +1223,37 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { SubscriptionManager.INVALID_SUBSCRIPTION_ID)).isNull(); } + @Test + public void testActiveSubscriptionList_filtersProvisioningNetworks() { + List<SubscriptionInfo> list = new ArrayList<>(); + list.add(TEST_SUBSCRIPTION_PROVISIONING); + when(mSubscriptionManager.getCompleteActiveSubscriptionInfoList()).thenReturn(list); + mKeyguardUpdateMonitor.mSubscriptionListener.onSubscriptionsChanged(); + + assertThat(mKeyguardUpdateMonitor.getSubscriptionInfo(true)).isEmpty(); + + SubscriptionInfo.Builder b = new SubscriptionInfo.Builder(TEST_SUBSCRIPTION_PROVISIONING); + b.setProfileClass(PROFILE_CLASS_DEFAULT); + SubscriptionInfo validInfo = b.build(); + + list.clear(); + list.add(validInfo); + mKeyguardUpdateMonitor.mSubscriptionListener.onSubscriptionsChanged(); + + assertThat(mKeyguardUpdateMonitor.getSubscriptionInfo(true)).hasSize(1); + } + + @Test + public void testActiveSubscriptionList_filtersProvisioningNetworks_untilValid() { + List<SubscriptionInfo> list = new ArrayList<>(); + list.add(TEST_SUBSCRIPTION_PROVISIONING); + when(mSubscriptionManager.getCompleteActiveSubscriptionInfoList()).thenReturn(list); + mKeyguardUpdateMonitor.mSubscriptionListener.onSubscriptionsChanged(); + + assertThat(mKeyguardUpdateMonitor.getSubscriptionInfo(true)).isEmpty(); + + } + @Test public void testIsUserUnlocked() { // mUserManager will report the user as unlocked on @Before