Merge "Refine the logic to show/hide cdma preference"

This commit is contained in:
TreeHugger Robot
2018-10-29 22:55:57 +00:00
committed by Android (Google) Code Review
5 changed files with 95 additions and 26 deletions

View File

@@ -30,7 +30,6 @@ import android.provider.Settings;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.CarrierConfigManager;
import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -213,11 +212,6 @@ public class MobileNetworkUtils {
|| (!esimIgnoredDevice && enabledEsimUiByDefault && inEsimSupportedCountries));
}
public static PersistableBundle getCarrierConfigBySubId(int mSubId) {
//TODO(b/114749736): get carrier config from subId
return new PersistableBundle();
}
/**
* Set whether to enable data for {@code subId}, also whether to disable data for other
* subscription
@@ -253,9 +247,17 @@ public class MobileNetworkUtils {
}
final TelephonyManager telephonyManager = TelephonyManager.from(context)
.createForSubscriptionId(subId);
final PersistableBundle carrierConfig = context.getSystemService(
CarrierConfigManager.class).getConfigForSubId(subId);
if (telephonyManager.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
return true;
} else if (carrierConfig != null
&& !carrierConfig.getBoolean(
CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL)
&& carrierConfig.getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL)) {
return true;
}
if (isWorldMode(context, subId)) {
@@ -312,7 +314,10 @@ public class MobileNetworkUtils {
if (telephonyManager.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM) {
return true;
} else if (carrierConfig.getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL)) {
} else if (carrierConfig != null
&& !carrierConfig.getBoolean(
CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL)
&& carrierConfig.getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL)) {
return true;
}

View File

@@ -23,6 +23,8 @@ import android.telephony.TelephonyManager;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.internal.telephony.Phone;
/**
* Preference controller for "System Select"
*/
@@ -47,6 +49,12 @@ public class CdmaSystemSelectPreferenceController extends CdmaBasePreferenceCont
resetCdmaRoamingModeToDefault();
}
}
final int settingsNetworkMode = Settings.Global.getInt(
mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + mSubId,
Phone.PREFERRED_NT_MODE);
listPreference.setEnabled(
settingsNetworkMode != TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
}
@Override