Andoird adds system default configuration APN

1. Project Scenario and Problem Description

Platform: RK3288
System: Android5.1

The client machine is a cabinet in Hong Kong (code; HK), using a Hong Kong SIM card, burning or restoring factory settings for the first time, setting-mobile network-access point name-APN can identify the information on the Hong Kong side , but none of them are selected and need to be manually selected. If you change another SIM card (with a different operator number) and restart, you must manually select again;

The local test uses a China Mobile (4G) SIM card, which will automatically select the China Mobile cmnet access point name when it is turned on.


Second, the location of the APN default configuration file in the system:

The default configuration of the system APN comes from system/etc/apns-conf.xmlthis file. It is generated in the source code vendor/rockchip/common/phone/etc/apns-full-conf.xmlfile. Generally, the location may be different depending on the project. If you can’t find it, you can find it directly. You can see many existing ones in apns-conf.xml apn information, add the new APN you need to configure.

For example, the apn option of Hong Kong provided by the customer:

<apn carrier="3 HK" mcc="454" mnc="03" apn="ipc.lte.three.com.hk" type="default,supl" />

3. The configured APN is selected by default when starting up:

After adding and configuring the apn, re-burn the boot, insert the SIM card in Hong Kong, and find that there is a newly added APN in the Settings-Mobile Network-Access Point Name-APN, but it is not selected by default; but it will be selected by default when using China Mobile or China Unicom. Function. This problem can be solved by modifying the source code:

In packages/apps/Settings/src/com/android/settings/ApnSettings.java, locate the fillList() method:

private void fillList() {
    
    
...
boolean selectable = ((type == null) || !type.equals("mms"));
pref.setSelectable(selectable);

//add by fy start
//如果name和apn和numeric满足自己配置的条件,就直接setChceked
if("3 HK".equals(name) && "ipc.lte.three.com.hk".equals(apn) && where.contains("45403")){
    
    
      pref.setChecked();
      apnList.addPreference(pref);
      Log.d("fy","3 HK");
} else{
    
    
//add by fy end
        if (selectable) {
    
    
                if ((mSelectedKey != null) && mSelectedKey.equals(key)) {
    
    
                        pref.setChecked();
                }
                apnList.addPreference(pref);
        } else {
    
    
                mmsApnList.add(pref);
        }
}
...
}

Guess you like

Origin blog.csdn.net/weixin_45639314/article/details/131682712