Android 当存在双卡时,移动网络默认为SIM卡1

文章目录

一、当Android设备中存在双卡时,移动网络默认为SIM卡1

完成这个需求有以下两个修改点:

   下面依旧是Android13 MTK平台,在MtkMultiSimSettingController.java的updateDefaults()方法中将移动网络设置为SIM1。

   除此之外,当存在双卡时,开机进入到Launcher界面时,首先就会出现一个对话框让我们去选择使用SIM卡1还是SIM卡2。所以当我们设置为默认SIM卡1之后,这个弹窗我们也需要去除掉。

  1. 可以加入自己的判断,直接将autoFallbackEnabled重新赋值
  2. 也可以在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);
        }
    }

越想贴近事实,不明白的事情就越多。

相关推荐
阿pin36 分钟前
Android随笔-Serializable与Parcelable
android·serializable·parcelable
天空之城--1 小时前
Android 事件分发机制深度解析——原理、源码与实战综合总结
android
阿pin2 小时前
Android随笔-AIDL
android·开发语言·aidl
2501_916007473 小时前
Bundle ID 注册与管理 App ID 创建指南 命名规则 权限开关与删除注意事项
android·ios·小程序·https·uni-app·iphone·webview
雨白3 小时前
面向对象六大基本原则实战:从零重构支持引擎切换的网络框架
android·架构
张赐荣3 小时前
Android TalkBack 无障碍优化: 为控件自定义转子导航动作
android·microsoft
天空之城--5 小时前
Android Flutter行业动态与学习参考(2026年8月)
android·flutter
quantdash_cc6 小时前
基于 QuantDash 5 分钟 K 线的网格交易策略参数网格搜索寻优实战
android·开发语言·pandas·量化·quantdash
杉氧7 小时前
原生交互:如何在 Flutter 中嵌入 Android/iOS 原生组件并解决手势冲突
android·flutter·dart
Android打工仔7 小时前
Continuation 的链式关系 —— 一个 suspend 函数如何把结果交还给调用者?
android·kotlin