Fix Calls/SMS default SIM selector
In cases where a SIM is initially disabled, even after you turn it on the ListPreference's for selecting the default SIM for Calls and SMS weren't working because the preference change listener wasn't getting registered. This CL fixes that for these controllers by always registering a change listener whenever we make the preference visible. Fixes: 134472294 Bug: 135142209 Test: make RunSettingsRoboTests Change-Id: Ia9362b7f26309bdbd6c5e8140fb606b28e2b34d8
This commit is contained in:
@@ -203,6 +203,28 @@ public class DefaultSubscriptionControllerTest {
|
||||
eq(SubscriptionManager.INVALID_SUBSCRIPTION_ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_prefBecomesAvailable_onPreferenceChangeCallbackNotNull() {
|
||||
final SubscriptionInfo sub1 = createMockSub(111, "sub1");
|
||||
final SubscriptionInfo sub2 = createMockSub(222, "sub2");
|
||||
|
||||
// Start with only one sub active, so the pref is not available
|
||||
SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1));
|
||||
doReturn(sub1.getSubscriptionId()).when(mController).getDefaultSubscriptionId();
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
|
||||
// Now make two subs be active - the pref should become available, and the
|
||||
// onPreferenceChange callback should be properly wired up.
|
||||
SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
||||
mController.onSubscriptionsChanged();
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
assertThat(mListPreference.getOnPreferenceChangeListener()).isEqualTo(mController);
|
||||
mListPreference.callChangeListener("222");
|
||||
verify(mController).setDefaultSubscription(eq(222));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onSubscriptionsChanged_twoSubscriptionsDefaultChanges_selectedEntryGetsUpdated() {
|
||||
final SubscriptionInfo sub1 = createMockSub(111, "sub1");
|
||||
|
Reference in New Issue
Block a user