文章目录
一、当Android设备中存在双卡时,移动网络默认为SIM卡1
完成这个需求有以下两个修改点:
下面依旧是Android13 MTK平台,在MtkMultiSimSettingController.java的updateDefaults()方法中将移动网络设置为SIM1。
除此之外,当存在双卡时,开机进入到Launcher界面时,首先就会出现一个对话框让我们去选择使用SIM卡1还是SIM卡2。所以当我们设置为默认SIM卡1之后,这个弹窗我们也需要去除掉。
- 可以加入自己的判断,直接将autoFallbackEnabled重新赋值
- 也可以在frameworks/base/core/res/res/values/config.xml,修改config_voice_data_sms_auto_fallback
二、下面是完整的代码路径和修改点
java
system/vendor/mediatek/proprietary/frameworks/opt/telephony/src/java/com/mediatek/internal/telephony/MtkMultiSimSettingController.java
java
@Override
protected void updateDefaults() {
//........省略多余代码.........
boolean dataSelected = updateDefaultValue(mPrimarySubList,
mSubController.getDefaultDataSubId(),
(newValue ->{
// The default mobile network is SIM 1
int defaultSubId = mSubController.getDefaultDataSubId();
if(defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID){
int subId1 = mSubController.getSubIdUsingPhoneId(0);
if(subId1 == newValue){
mSubController.setDefaultDataSubId(newValue);
}
}
}));
// The default mobile network is SIM 1
// Update default voice subscription.
if (DBG) log("[updateDefaultValues] Update default voice subscription");
boolean voiceSelected = updateDefaultValue(mPrimarySubList,
mSubController.getDefaultVoiceSubId(),
(newValue -> mSubController.setDefaultVoiceSubId(newValue)));
//........省略多余代码.........
boolean autoFallbackEnabled = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_voice_data_sms_auto_fallback);
// Based on config config_voice_data_sms_auto_fallback value choose voice/data/sms
// preference auto selection logic or display notification for end used to
// select voice/data/SMS preferences.
// Removes the mobile network selection popup begin
autoFallbackEnabled = true;
// Removes the mobile network selection popup end
if (!autoFallbackEnabled) {
sendSubChangeNotificationIfNeeded(change, dataSelected, voiceSelected, smsSelected);
} else {
updateUserPreferences(mPrimarySubList, dataSelected, voiceSelected, smsSelected);
}
}
越想贴近事实,不明白的事情就越多。