Android 7.1 双卡双待机器,首选网络类型设置 详细分析

news/2024/11/27 8:22:02/
首次由preferred_network_mode转换成preferred_network_mode1和preferred_network_mode2是在SubscriptionInfoUpdater类中的handleSimLoaded方法


我们机器设备默认的是:
[ro.telephony.default_network]: [22,20]

但是双sim卡,会对网络进行设置,会有一个设置的过程:
类->方法流程
click选择某张运营商卡为主卡:
IExtTelephony extTelephony =
IExtTelephony.Stub.asInterface(ServiceManager.getService("extphone"));
extTelephony.setPrimaryCardOnSlot(targetSub);

调用ExtTelephony的setPrimaryCardOnSlot方法
-》ExtTelephonyServiceImpl
-》setPrimaryCardOnSlot()
-》QtiPrimaryCardController.getInstance().setPrimaryCardOnSlot(slotId);
-》QtiPrimaryCardController
-》setPrimaryCardOnSlot()
-》synchronized private void setPrimaryCardOnSlot(int primarySlotId, Message msg)
-》在setPrimaryCardOnSlot方法中:

mPrefNwModes = mPriorityHandler.getNwModesFromConfig(primarySlotId);
//通过getNwModesFromConfig获取两种网络模式

for (int i = 0; i < QtiPrimaryCardUtils.PHONE_COUNT; i++) {
saveNwModesToDB(mPrefNwModes[i], i); //保存到数据库重要的一步
}

-》QtiPrimaryCardPriorityHandler
-》getNwModesFromConfig()
-》

for (int i = 0; i < QtiPrimaryCardUtils.PHONE_COUNT; i++) {
if (mCurrPriorityConfigs[i] != null) {
prefNwModes[i] = (i == primarySlotId) ? mCurrPriorityConfigs[i].network1 :
mCurrPriorityConfigs[i].network2;
//获取该类中的mCurrPriorityConfigs的network1和network2
} else {
prefNwModes[i] = defaultNwMode;
}
}

-》而mCurrPriorityConfigs的计算和获取是通过:
-》loadCurrentPriorityConfigs()
-》

public void loadCurrentPriorityConfigs(boolean override) {
if(!mLoadingConfigCompleted) {
logd("getPrefPrimarySlot: All Config Loading not done. EXIT!!!");
return;
}

if(override || !mLoadingCurrentConfigsDone) {
//get Current Priority config applicable for each slot
for (int i = 0; i < QtiPrimaryCardUtils.PHONE_COUNT; i++) {
mCurrPriorityConfigs[i] = getPriorityConfig(i);
}
mLoadingCurrentConfigsDone = true;
}
}

-》getPriorityConfig()
-》PriorityConfig pConfig = mAllPriorityConfigs.get(i);
-》 private HashMap<Integer, PriorityConfig> mAllPriorityConfigs =
new HashMap<Integer, PriorityConfig>();
从mAllPriorityConfigs 这个HashMap中来
-》在初始化的时候:
QtiPrimaryCardPriorityHandler(Context context){
mContext = context;

mCurrPriorityConfigs = new PriorityConfig[QtiPrimaryCardUtils.PHONE_COUNT];
tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);

readPriorityConfigFromXml();
}
-》readPriorityConfigFromXml()
-》
private void readPriorityConfigFromXml() {
XmlResourceParser parser = null;
try {
Resources res = mContext.getPackageManager().getResourcesForApplication(packageName);
if (res == null) loge("res is null");
int resId = res.getIdentifier(QtiPrimaryCardUtils.getConfigXml(), "xml", packageName);
parser = res.getXml(resId);
//Clear all old configs from hash map.
mAllPriorityConfigs.clear();
mPriorityCount = 0;

XmlUtils.beginDocument(parser, "priority_config");
//2TODO: here we can read the operator config and feed it to pcutils
XmlUtils.nextElement(parser);
while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
savePriorityConfig(parser);
XmlUtils.nextElement(parser);
}
mLoadingConfigCompleted = true;
} catch (Exception e) {
Rlog.e(LOG_TAG, "Exception while reading priority configs: " + e.getMessage(), e);
mLoadingConfigCompleted = false;
} finally {
logi("mAllPriorityConfigs: " + mAllPriorityConfigs);
if (parser != null) {
parser.close();
}
}
}
-》是从QtiPrimaryCardUtils.getConfigXml()中读取xml文件

-》xml的文件名分别是:
public static String getConfigXml() {
if (isBitSetInConfig(ConfigBits.PRIORITY_CONFIG_3)) {
return "priority_config_3";
} else if (isBitSetInConfig(ConfigBits.PRIORITY_CONFIG_2)) {
return "priority_config_2";
} else if (isBitSetInConfig(ConfigBits.PRIORITY_CONFIG_1)) {
return "priority_config_1";
}
return "priority_config_2";
}

-》打开xml文件:

config_3:
<priority_config>
<!--[ODM][pref_network] enable config primary sub setable,modify the default config START-->
<!--
<priority priority="0" iin_pattern="^8986(?=03|11)" card_type="CARDTYPE_2G" network1="7" network2="7" />
<priority priority="1" iin_pattern="^8986(?=03|11)" card_type="CARDTYPE_3G" network1="7" network2="7"/>
<priority priority="2" iin_pattern="^8986(?=01|09)" card_type="CARDTYPE_2G" network1="1" network2="1" />
<priority priority="3" iin_pattern="^8986(?=01|09)" card_type="CARDTYPE_3G" network1="1" network2="1"/>
<priority priority="4" iin_pattern="^(?!8986)" card_type="CARDTYPE_2G" network1="18" network2="1" />
<priority priority="5" iin_pattern="^(?!8986)" card_type="CARDTYPE_3G" network1="20" network2="1"/>
<priority priority="6" iin_pattern="^8986(?!01|03|09|11)" card_type="CARDTYPE_2G" network1="18" network2="1"/>
<priority priority="7" iin_pattern="^8986(?!01|03|09|11)" card_type="CARDTYPE_3G" network1="20" network2="1"/>
-->
<priority priority="4" iin_pattern="^(?!8986)" card_type="CARDTYPE_4G" network1="22" network2="22"/>
<priority priority="5" iin_pattern="^898600" card_type="CARDTYPE_4G" network1="20" network2="17"/>
<priority priority="6" iin_pattern="^898602" card_type="CARDTYPE_4G" network1="20" network2="17"/>
<priority priority="7" iin_pattern="^898607" card_type="CARDTYPE_4G" network1="20" network2="17"/>
<!--CU-->
<priority priority="8" iin_pattern="^898601" card_type="CARDTYPE_4G" network1="20" network2="9"/>
<priority priority="9" iin_pattern="^898609" card_type="CARDTYPE_4G" network1="20" network2="9"/>
<!--CT-->
<priority priority="0" iin_pattern="^898603" card_type="CARDTYPE_4G" network1="22" network2="8"/>
<priority priority="1" iin_pattern="^898606" card_type="CARDTYPE_4G" network1="22" network2="8"/>
<priority priority="2" iin_pattern="^898611" card_type="CARDTYPE_4G" network1="22" network2="8"/>
<priority priority="3" iin_pattern="^898530" card_type="CARDTYPE_4G" network1="22" network2="8"/>
<!--end-->
<!--[ODM][pref_network] enable config primary sub setable,modify the default config END-->
</priority_config>


config_2:
<priority_config>
<priority priority="0" iin_pattern="^[0-9]{6,}" card_type="CARDTYPE_2G" network1="3" network2="1" />
<priority priority="1" iin_pattern="^[0-9]{6,}" card_type="CARDTYPE_3G" network1="9" network2="1"/>
<priority priority="2" iin_pattern="^[0-9]{6,}" card_type="CARDTYPE_4G" network1="9" network2="1"/>
</priority_config>


config_1:
<priority_config>
<priority priority="0" iin_pattern="^(?!8986)" card_type="CARDTYPE_2G" network1="18" network2="1" />
<priority priority="1" iin_pattern="^(?!8986)" card_type="CARDTYPE_3G" network1="20" network2="1"/>
<priority priority="2" iin_pattern="^8986(?!01|03|09|11)" card_type="CARDTYPE_2G" network1="18" network2="1"/>
<priority priority="3" iin_pattern="^8986(?!01|03|09|11)" card_type="CARDTYPE_3G" network1="20" network2="1"/>
</priority_config>

http://www.ppmy.cn/news/210383.html

相关文章

android 双卡双待 发送短信

最近公司拿了一批手机是FRG83G的双卡机子&#xff0c;在程序中按照普通的发短信调用方法&#xff0c;短信发不出去&#xff0c;经过研究&#xff0c;目前android的双卡手机有两个插槽&#xff0c;一个是GSM&#xff0c;另外一个是CDMA&#xff0c;对应的卡也必须插正确&#xf…

Dockerfile常用指令及其含义

编写dockerfile文件中常用指令&#xff1a; 指令说明FROM指明当前的镜像基于哪个镜像构建:LABEL标记镜像信息&#xff0c;添加元数据ARG定义构建镜像过程中使用的变量ENV指定环境变量VOLUME创建一个数据卷挂载点USER指定运行容器时的用户名或 UIDWORKDIR配置工作目录EXPOSE容器…

汽车相关知识及术语

1 汽车构造与制造流程 1.1 汽车构造 汽车可以分为四大部分 车身&#xff1a; 骨架、车身钣金件以及座椅、仪表、天窗、车外后视镜等车身附件 动力系统&#xff1a; 发动机和变速器 底盘&#xff1a; 传动系统、悬架系统、转向系统、制动系统和车轮轮胎 电气电子系统&#…

小米手机开发版刷机

爬坑后整理的有用资源&#xff1a; 开发版ROM资源&#xff1a; https://xiaomirom.com 刷机教程: https://web.vip.miui.com/page/info/mio/mio/detail?postId32681233&app_versiondev.20051 希望大家不要被线刷宝误导&#xff0c;请用官网刷机软件&#xff0c;祝大家早日…

手机小技巧:小米手机怎么截屏?

小米手机怎么截屏&#xff1f;小米手机是国产手机中性价比偏全民化的“发烧机”&#xff0c;功能方面算是比较多的&#xff0c;今天我们来看看它是怎么截屏的。 一、通知栏截屏 不管是小米手机还是其他国产手机&#xff0c;通知栏都会有一个截屏功能&#xff0c;我们只需要轻轻…

小米手机怎么截屏?小米手机区域截屏

小米手机怎么截屏&#xff1f;手机的截屏其实都是差不多的&#xff0c;基本上都是三指向下滑动而达到截屏效果的&#xff0c;但基本都是全屏截图。小米手机区域截屏怎么做&#xff1f;如果想要做到任意位置的那种区域块截屏的话&#xff0c;该怎么做&#xff1f;下面就来看看吧…

Elliptic Labs与小米联手,向印度市场推出红米 11SE智能手机

全球Al软件公司、AI Virtual Smart Sensors™ 的领导者Elliptic Labs (OSE: ELABS)与小米再度携手&#xff0c;在面向印度市场推出的最新款智能手机红米 11SE上搭载其产品AI Virtual Proximity Sensor™ INNER BEAUTY。小米作为全球第三大智能手机制造商&#xff0c;自2016年以…

历代小米黑鲨手机主要参数对比,更新于2021年3月

历代小米黑鲨手机主要参数对比 按年份排序 序型号年份处理器运存存储屏幕摄像头电池特性1黑鲨12018.03骁龙8456G/8G64G起不可扩展5.99寸403PPI前2000W后2000W4000mAh18W有线游戏手机后置双摄2黑鲨22019.03骁龙8556G/8G/12G128G起不可扩展6.39寸403PPI前2000W后4800W4000mAh27…