The decision if a SIM is connected to a roaming network (a network of another country, for example) is done by the framework with the information obtained on this network.
First, we need to know that there are two types:
- Domestic Roaming -> A network of the same country (same MCC) as the SIM but that it is of other operator (different MNC).
- International Roaming -> A network of another country (different MCC)
A lot of OEMs (BQ, Samsung, Xiaomi...) treat Domestic Roaming as not roaming because, for example, all the MVNO use Domestic Roaming.
By default, AOSP has a way to add networks so they will always be considered roaming (as well as adding networks that will never be considered roaming)
For AOSP, it works like this:
In ServiceStateTracker.java of framework/opt/telephony:
/**
* Do not set roaming state in case of oprators considered non-roaming.
*
* Can use mcc or mcc+mnc as item of
* {
@link CarrierConfigManager#KEY_NON_ROAMING_OPERATOR_STRING_ARRAY
}
.
* For example, 302 or 21407. If mcc or mcc+mnc match with operator,
* don't set roaming state.
*
* @param s ServiceState hold current ons
* @return false for roaming state set
*/
private boolean isOperatorConsideredNonRoaming(ServiceState s) {
String operatorNumeric = s.getOperatorNumeric();
PersistableBundle config = getCarrierConfig();
String[] numericArray = config.getStringArray(
CarrierConfigManager.KEY_NON_ROAMING_OPERATOR_STRING_ARRAY);
if (ArrayUtils.isEmpty(numericArray) || operatorNumeric == null) {
return false;
}
for (String numeric : numericArray) {
if (!TextUtils.isEmpty(numeric) && operatorNumeric.startsWith(numeric)) {
return true;
}
}
return false;
}
and at the same way:
private boolean isOperatorConsideredRoaming(ServiceState s) {
String operatorNumeric = s.getOperatorNumeric();
PersistableBundle config = getCarrierConfig();
String[] numericArray = config.getStringArray(
CarrierConfigManager.KEY_ROAMING_OPERATOR_STRING_ARRAY);
if (ArrayUtils.isEmpty(numericArray) || operatorNumeric == null) {
return false;
}
for (String numeric : numericArray) {
if (!TextUtils.isEmpty(numeric) && operatorNumeric.startsWith(numeric)) {
return true;
}
}
return false;
}
If we search information about KEY_ROAMING_OPERATOR_STRING_ARRAY and KEY_NON_ROAMING_OPERATOR_STRING_ARRAY in Android Developers we found that
So you could add in carrier_config_21407 (Movistar Spain) a list of roaming and not roaming list:
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<carrier_config_list>
<carrier_config>
<string-array name="gsm_nonroaming_networks_string_array" num="1">
<item value="26804" /> //for example, LycaMobile Portugal
</string-array>
</carrier_config>
</carrier_config_list>
The carrier config files are found in platform/packages/apps/CarrierConfig. There are two possible formats: