Qualcomm platform dual card slot network mode supports all domestic operators

Part1

The dual-card network mode of Qualcomm platform is usually that slot 1 supports 4, 3, 2G networks, and slot 2 is generally written as fixed by default. In the previous android L and below, the basic setting of msm8909 and msm8916 platforms is GSM only, because The requirement is for android M of msm8996, so I will probably go through the setup process under the specified platform analysis.
Start positioning from the network settings app (NetworkSetting) interface.
The menu for setting the network mode in MobileNetworkSettings.java under package/service/Telephony is ListPreference
private ListPreference mButtonPreferredNetworkMode;
clicking on the Preference corresponds to the array corresponding to the network mode, and Android native will All network modes are displayed, which is suitable for finding problems in the debugging stage, but this is not in line with the good interface interaction of the models on the market. The
user should be presented to the 4/3/2G network mode menu mentioned above and select
setScreenState () Under the method, obtain mccmnc through the operator to customize the corresponding network mode menu

先判断一下sim卡的状态
             int simState = TelephonyManager.getDefault().getSimState(mPhone.getPhoneId());
             getPreferenceScreen().setEnabled(simState != TelephonyManager.SIM_STATE_ABSENT);
             
             以下以国内电信网络模式为例,
             setEntries()设置网络模式字符串,setEntryValues设置网络模式对应的数值
if((mccmnc.equals("46003")||mccmnc.equals("46005")||mccmnc.equals("46011"))) {
    
    

            

 mButtonPreferredNetworkMode.setEntries(
                   R.array.preferred_network_mode_choices_FQ1_CT);
             mButtonPreferredNetworkMode.setEntryValues(
                   R.array.preferred_network_mode_values_FQ1_CT);
                  if(subController.getDefaultDataSubId()==subId) {
    
    //判断当前的subId是否为走数据的Sub,通常情况下,只让终端用户手动选择数据卡的网络模式
           if ((getPreferredNetworkModeForSubId()!= 22)) {
    
    
                 if (getPreferredNetworkModeForSubId()== 4) {
    
    
                     setPreferredNetworkMode(4);
                 }else
                     setPreferredNetworkMode(22);
           }
      } else if(subController.getDefaultDataSubId()!=subId){
    
    
             if((prefSet != null)) {
    
    //非数据卡,直接移除网络模式设置preference
                 prefSet.removePreference(mButtonPreferredNetworkMode);
             }
      }

In addition, Qualcomm andriod M directly fixed the network mode of card slot 2 on the PhoneFeature app. More accurately, before M, the card slot 2 was set to GSM by default in the following position.

vendor\qcom\proprietary\qrdplus\Extension\apps\PhoneFeatures\src\com\qualcomm\qti\phonefeature\PrefNetworkRequest.java
public PrefNetworkRequest(Context context, int slot, int networkMode, Message callback) {
    
    
        super(sSyncQueue);
        mContext = context;
        mCallback = callback;
        commands = new ArrayList<PrefNetworkSetCommand>();
//屏蔽下面的代码,移除固定卡槽2的网络模式设置
        /*if (networkMode != Phone.NT_MODE_GSM_ONLY) {
            for (int index = 0; index < Constants.PHONE_COUNT; index++) {
                if (index != slot)
                    commands.add(new PrefNetworkSetCommand(index, Phone.NT_MODE_GSM_ONLY));
            }
        }*/
        if (slot >= 0 && slot < Constants.PHONE_COUNT) {
    
    
            commands.add(new PrefNetworkSetCommand(slot, networkMode));
        }
    }

After android N, the default network mode has a small change

  frameworks\base\packages\SettingsProvider\src\com\android\providers\settings\DatabaseHelper.java

            for (int phoneId = 0; phoneId < phoneCount; phoneId++) {
    
    
                mode = TelephonyManager.getTelephonyProperty(phoneId,
                         "ro.telephony.default_network",                   
                         Integer.toString(RILConstants.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA)
                if (phoneId == 0) {
    
    
                    val = mode;
                } else {
    
    
                    val = val + "," + mode;
                }
            }
Part2

In summary, the content described in Part1 is mainly done two things:
1. For different operators, simplifying the complex, optimizing the network mode menu
2. Lifting the restriction that the card slot 2 cannot be set to any network mode.
Our ultimate goal is definitely The network mode can be set directly, and as a mobile phone device that supports hot swap, it is necessary to find the status of the sim after detecting the status of the sim, and then set the corresponding network mode to ensure that different sim cards can accurately match the network.
Then a small mention Let’s take a look at the NV10 on the modem side. This is a network mode NV. Read this NV through QXDM, you can get the current network mode of all subIds. The upper layer sets the network mode, which is actually a modification of NV10. In addition, the popularity of VoLte was not so high before. Under the premise that CDMA only supports a single channel in hardware, the card slot of the telecom card must be matched to the network in time, otherwise the following status will appear:
1. The telecom card is not registered on the 4G network, then the interface displays empty The signal grid, because there is no CDMA network mode, is assigned to the card slot of the telecom card.
2. The telecom card is registered on the 4G network. Once a call is made, the telecom call needs to fall back to CDMA, and there is no matching network mode, which directly leads to the failure to call out or Be called in

Locate the sim card detection related class
frameworks\opt\telephony\src\java\com\android\internal\telephony\SubscriptionInfoUpdater.java through the radio log of each insertion and removal of the card.
Do not use mccmnc to distinguish between different operators. , It’s best to judge the
handle handling of SIM card loading, and the network mode distribution of the two card slots, focusing on the method
private void handleSimLoaded(int slotId) { Here is the fixed judgment processing of the two card slots, with slotId Variable parameters, especially telecom cards

        int SubId = sirInfo.getSubscriptionId();
        int SlotId = mSubscriptionManager.getSlotId(SubId);
        int nwmode = RILConstants.PREFERRED_NETWORK_MODE;
        try {
    
    
            nwmode = android.provider.Settings.Global.getInt(
            mPhone[SlotId].getContext().getContentResolver(),
                           Settings.Global.PREFERRED_NETWORK_MODE + SubId);
            } catch (SettingNotFoundException snfe) {
    
    

}
            try {
    
    
            nwmode  = TelephonyManager.getIntAtIndex(
                             mContext.getContentResolver(),
                                  Settings.Global.PREFERRED_NETWORK_MODE, slotId);
            } catch (SettingNotFoundException retrySnfe) {
    
    

            Rlog.e(LOG_TAG, "Settings Exception Reading Value At Index for"+
                                     " Settings.Global.PREFERRED_NETWORK_MODE");
            }
        }

  }

The above reads the default network mode. The following uses the telecommunications card in slot 1 and the mobile card in slot 2 as examples. Setting the slotId network mode
isCTCard is to determine whether the current iccid is the iccid of the telecommunications card

 if(isCTCard(0)&&(!isCTCard(1))) {
    
    
                logd("nw ******sim1 is CT card******");
                if (slotId == 1) {
    
    
                   if (nwmode == 16) {
    
    
                         mPhone[1].setPreferredNetworkType(16, null);
                         Settings.Global.putInt(mPhone[1].getContext().getContentResolver(),
                         Settings.Global.PREFERRED_NETWORK_MODE + SubId,
                         16);
                   logd(" nw "+" 111 CMCC card 3G mode, only sim1 is CT card 3G mode nwmode = "+ nwmode);
                      } if (nwmode == 3) {
    
    
                         mPhone[1].setPreferredNetworkType(3, null);
                         Settings.Global.putInt(mPhone[1].getContext().getContentResolver(),
                         Settings.Global.PREFERRED_NETWORK_MODE + SubId,
                         3);
                         logd(" nw "+" 111 CU card 3G mode, only sim1 is CT card 3G mode nwmode = "+ nwmode);
                      } if (nwmode == 20) {
    
    
                          mPhone[1].setPreferredNetworkType(20, null);
                          Settings.Global.putInt(mPhone[1].getContext().getContentResolver(),
                          Settings.Global.PREFERRED_NETWORK_MODE + SubId,
                          20);
                          logd(" nw "+" 111 if equals 20 set 20");
                      } if (nwmode == 1) {
    
    
                          mPhone[1].setPreferredNetworkType(1, null);
                          Settings.Global.putInt(mPhone[1].getContext().getContentResolver(),
                          Settings.Global.PREFERRED_NETWORK_MODE + SubId,
                          1);
                          logd(" nw "+" 111 if equals 1 set 1");
                       }
                      else if ((nwmode != 20)&&(nwmode != 16)&&(nwmode != 3)&&(nwmode != 1)) {
    
    
                          mPhone[1].setPreferredNetworkType(20, null);
                          Settings.Global.putInt(mPhone[1].getContext().getContentResolver(),
                          Settings.Global.PREFERRED_NETWORK_MODE + SubId,
                          20);
                          logd(" dhflogsw "+" 111 normal mode  only sim1 is CT card nwmode = "+ nwmode);
                      }
                }
                if (slotId == 0) {
    
    
                   if (nwmode == 4) {
    
    
                       mPhone[0].setPreferredNetworkType(4, null);
                       Settings.Global.putInt(mPhone[0].getContext().getContentResolver(),
                       Settings.Global.PREFERRED_NETWORK_MODE + SubId,
                       4);
                       logd(" nw "+" 111 only sim1 is CT card 3G mode ");
                   } else {
    
    
                       mPhone[0].setPreferredNetworkType(22, null);
                       Settings.Global.putInt(mPhone[0].getContext().getContentResolver(),
                       Settings.Global.PREFERRED_NETWORK_MODE + SubId,
                       22);
                       logd(" nw "+" 111 only sim1 is CT card LTE mode ");
                    }
                }
About sim card detection

When the phone restarts or detects the status change of the sim card, RIL will initiate a query for the sim card information, write the read information into the database, and save it to the subscriptionManager.
Insert picture description here
This section refers to FamilyYuan's blog, link https://blog.csdn.net /myfriend0/article/details/79364548, thanks.
In addition, this part of the content is something that has been changed two or three years ago. Recently, I think it is necessary to write it out and sort it out. If there is any incorrect place, please correct me.

Guess you like

Origin blog.csdn.net/jeephao/article/details/103394733