Hide roaming option when carriers force all networks as HOME networks
This change will hide roaming option in carrier's network setting if the carrier overrrides the carrier config force_home_network_bool to true. Some carriers, like google Fi, has no concept of roaming. The carrier config force_home_network_bool is overridden to true to treat all cellular networks as home networks. There is no actually impact when user turn on/off the roaming option in network setting. Leaving an unused option just confuse many end users. Bug: 79424760 Test: make && make RunSettingsRoboTests Test: activate Fi service and make sure no roaming option Test: activate VZW service and make sure roaming option is present Test: override the cc config with adb command to make sure the roaming option is always correctly shown/hidden on the cc key values Change-Id: If6d0f7e3a5edea368b3a725afd9a2b4d1ad686ed
This commit is contained in:
@@ -65,6 +65,16 @@ public class RoamingPreferenceController extends TelephonyTogglePreferenceContro
|
|||||||
mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
|
mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
|
||||||
|
if (carrierConfig != null && carrierConfig.getBoolean(
|
||||||
|
CarrierConfigManager.KEY_FORCE_HOME_NETWORK_BOOL)) {
|
||||||
|
return CONDITIONALLY_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
return AVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
if (mListener == null) {
|
if (mListener == null) {
|
||||||
|
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settings.network.telephony;
|
package com.android.settings.network.telephony;
|
||||||
|
|
||||||
|
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||||
|
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
@@ -92,7 +95,7 @@ public class RoamingPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_validSubId_returnAvailable() {
|
public void getAvailabilityStatus_validSubId_returnAvailable() {
|
||||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||||
BasePreferenceController.AVAILABLE);
|
AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -168,4 +171,29 @@ public class RoamingPreferenceControllerTest {
|
|||||||
|
|
||||||
verify(mPreference, never()).setEnabled(anyBoolean());
|
verify(mPreference, never()).setEnabled(anyBoolean());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_carrierConfigIsNull_shouldReturnAvailable() {
|
||||||
|
doReturn(null).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_forceHomeNetworkIsFalse_shouldReturnAvailable() {
|
||||||
|
final PersistableBundle bundle = new PersistableBundle();
|
||||||
|
bundle.putBoolean(CarrierConfigManager.KEY_FORCE_HOME_NETWORK_BOOL, false);
|
||||||
|
doReturn(bundle).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_forceHomeNetworkIsTrue_shouldReturnConditionallyAvailable() {
|
||||||
|
final PersistableBundle bundle = new PersistableBundle();
|
||||||
|
bundle.putBoolean(CarrierConfigManager.KEY_FORCE_HOME_NETWORK_BOOL, false);
|
||||||
|
doReturn(bundle).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user