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:
Rambo Wang
2022-09-09 17:13:07 +00:00
committed by rambowang
parent e68cf6df7d
commit 145c954a33
2 changed files with 39 additions and 1 deletions

View File

@@ -65,6 +65,16 @@ public class RoamingPreferenceController extends TelephonyTogglePreferenceContro
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
public void onStart() {
if (mListener == null) {

View File

@@ -16,6 +16,9 @@
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 org.mockito.ArgumentMatchers.anyBoolean;
@@ -92,7 +95,7 @@ public class RoamingPreferenceControllerTest {
@Test
public void getAvailabilityStatus_validSubId_returnAvailable() {
assertThat(mController.getAvailabilityStatus()).isEqualTo(
BasePreferenceController.AVAILABLE);
AVAILABLE);
}
@Test
@@ -168,4 +171,29 @@ public class RoamingPreferenceControllerTest {
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);
}
}