android 8.0的Volte开关流程
Volte按钮:
vendor/qcom/proprietary/telephont-app/NetworkSetting/src/com/qualcomm/qti/networksetting/MoblieNetWorkSettings.java中key为_"enhanced_4g_lte"的SwitchPreference就是设置中的Votle开关。
boolean enhanced4gMode = !enhanced4gModePref.isChecked();
mImsMgr.setEnhanced4gLteModeSettingForSlot(enhanced4gModePref.isChecked());
上两行代码就是按钮相关的设置。
调用ImsManager中的setEnhanced4gLteModeSettingForSlot方法来进行设置。ImsManage路径:android\frameworks\opt\net\ims\src\java\com\android\ims\ImsManager。
~
~
ImsManage.java
public void setEnhanced4gLteModeSettingForSlot(boolean enabled) {
// If false, we must always keep advanced 4G mode set to true (1).
int value = getBooleanCarrierConfigForSlot(
CarrierConfigManager.KEY_EDITABLE_ENHANCED_4G_LTE_BOOL) ? (enabled ? 1: 0) : 1;
int subId = getSubId(mPhoneId);
log("setEnhanced4gLteModeSettingForSlot :: subId=" + subId + " enabled=" + enabled);
try {
int prevSetting = android.provider.Settings.Global.getInt(mContext.getContentResolver(),
android.provider.Settings.Global.ENHANCED_4G_MODE_ENABLED + subId);
if (prevSetting == value) {
// Don't trigger setAdvanced4GMode if the setting hasn't changed.
return;
}
} catch (Settings.SettingNotFoundException e) {
// Setting doesn't exist yet, so set it below.
}
android.provider.Settings.Global.putInt(mContext.getContentResolver(),
android.provider.Settings.Global.ENHANCED_4G_MODE_ENABLED + subId, value);
if (isNonTtyOrTtyOnVolteEnabledForSlot()) { //不支持TTY或者VoLTE支持TTY
try {
setAdvanced4GMode(enabled);//设置Votle
} catch (ImsException ie) {
// do nothing
}
}
}
以上代码是setEnhanced4gLteModeSettingForSlot的具体实现。代码不是很复杂,和android8.0之前版本的区别就在于它多了一个运载配置和getInt中subId的闯入。android8.0之前的版本好像是没有这两个东西的。
~
~
~
private void setAdvanced4GMode(boolean turnOn) throws ImsException {
checkAndThrowExceptionIfServiceUnavailable();
log("setAdvanced4GMode :: turnOn=" + turnOn);
// if turnOn: first set feature values then call turnOnIms()
// if turnOff: only set feature values if IMS turn off is not allowed. If turn off is
// allowed, first call turnOffIms() then set feature values
if (turnOn) {
setLteFeatureValues(turnOn);
log("setAdvanced4GMode: turnOnIms");
turnOnIms();
} else {
if (isImsTurnOffAllowed()) {
log("setAdvanced4GMode: turnOffIms");
turnOffIms();
}