Android源码开发笔记 WWAN Carrier config的修改

每个运营商的SIM卡都会有一套对应的MCC/MNC,比如:

中国移动: 460-02

AT&T: 310-410, 311-070

Verizon: 311-480, 310-012

Sprint: 310-120, 311-940

Telstra: 505-01

TMobile: 310-260

插入对应运营商的SIM卡,Android系统会自动load对应MCC/MNC的config给WWAN的app。

比如Google GMS image中的Messages app,短信的设定就会使用对应运营商的配置来决定诸如图片分辨率,短信长度之类。

要修改Carrier config,有下面三个位置:

1. 默认配置,在frameworks/base/telephony/java/android/telephony/CarrierConfigManager.java

sDefaults.putInt(KEY_MMS_MAX_IMAGE_HEIGHT_INT, 720);
sDefaults.putInt(KEY_MMS_MAX_IMAGE_WIDTH_INT, 1280);
sDefaults.putInt(KEY_MMS_MAX_MESSAGE_SIZE_INT, 1000 * 1024);
sDefaults.putInt(KEY_MMS_MESSAGE_TEXT_MAX_SIZE_INT, 153 * 7); //7 segments, each 153 characters
sDefaults.putInt(KEY_MMS_RECIPIENT_LIMIT_INT, 10);
sDefaults.putInt(KEY_MMS_SMS_TO_MMS_TEXT_LENGTH_THRESHOLD_INT, -1);
sDefaults.putInt(KEY_MMS_SMS_TO_MMS_TEXT_THRESHOLD_INT, -1);

对于各个KEY的详细说明,可以参考frameworks/base/telephony/java/android/telephony/SmsManager.java

去加载这些默认配置的位置,也在SmsManager.java中:

public static Bundle getMmsConfig(BaseBundle config) {
    Bundle filtered = new Bundle();
    ...
    filtered.putInt(MMS_CONFIG_MAX_MESSAGE_SIZE, config.getInt(MMS_CONFIG_MAX_MESSAGE_SIZE));
    filtered.putInt(MMS_CONFIG_MAX_IMAGE_WIDTH, config.getInt(MMS_CONFIG_MAX_IMAGE_WIDTH));
    filtered.putInt(MMS_CONFIG_MAX_IMAGE_HEIGHT, config.getInt(MMS_CONFIG_MAX_IMAGE_HEIGHT));
    filtered.putInt(MMS_CONFIG_RECIPIENT_LIMIT, config.getInt(MMS_CONFIG_RECIPIENT_LIMIT));
    filtered.putInt(MMS_CONFIG_ALIAS_MIN_CHARS, config.getInt(MMS_CONFIG_ALIAS_MIN_CHARS));
    filtered.putInt(MMS_CONFIG_ALIAS_MAX_CHARS, config.getInt(MMS_CONFIG_ALIAS_MAX_CHARS));
    filtered.putInt(MMS_CONFIG_SMS_TO_MMS_TEXT_THRESHOLD,
            config.getInt(MMS_CONFIG_SMS_TO_MMS_TEXT_THRESHOLD));
    filtered.putInt(MMS_CONFIG_SMS_TO_MMS_TEXT_LENGTH_THRESHOLD,
            config.getInt(MMS_CONFIG_SMS_TO_MMS_TEXT_LENGTH_THRESHOLD));
    filtered.putInt(MMS_CONFIG_MESSAGE_TEXT_MAX_SIZE,
            config.getInt(MMS_CONFIG_MESSAGE_TEXT_MAX_SIZE));
    filtered.putInt(MMS_CONFIG_SUBJECT_MAX_LENGTH,
            config.getInt(MMS_CONFIG_SUBJECT_MAX_LENGTH));
    ...
    return filtered;
}

 

2. 各个运营商MCC/MNC定义的config,在packages/apps/CarrierConfig/assets/

可以看到后缀都是各个MCC/MNC的组合,要修改对应运营商的,可以在其对应的xml中修改。

 

3. 手机厂商Vendor定义的config,在packages/apps/CarrierConfig/res/xml/vendor.xml(一般overlay到device/下面)

分为两部分,一是全体设置,二是针对运营商设置。

<carrier_config>
        <boolean name="apn_expand_bool" value="true" />
        <boolean name="world_phone_bool" value="false" />
        <boolean name="allow_adding_apns_bool" value="true" />
......
</carrier_config>

<carrier_config mcc="204" mnc="04">
        <boolean name="carrier_volte_available_bool" value="true" />
        <boolean name="carrier_vt_available_bool" value="true" />
        <boolean name="carrier_wfc_ims_available_bool" value="true" />
</carrier_config>

 

三者修改都可以生效,但是会有优先级:vendor.xml > 运营商MCC/MNC.xml > CarrierConfigManager.java

posted @ 2018-02-09 16:51  Kunkka_An  阅读(3337)  评论(0编辑  收藏  举报