那么Plmn的来源是什么呢?
@GsmServiceStateTracker.java
private void pollState() {
mPollingContext = new int[1];
mPollingContext[0] = 0;
switch (mCi.getRadioState()) {
case RADIO_UNAVAILABLE:
break;
case RADIO_OFF:
break;
default:
mPollingContext[0]++;
//读取当前网络运营商信息
mCi.getOperator(
obtainMessage(
EVENT_POLL_STATE_OPERATOR, mPollingContext));
break;
}
}
这里的
mCi就是RILJ对象:
@RIL.java
public void getOperator(Message result) {
//向RIL发送RIL_REQUEST_OPERATOR的请求
RILRequest rr = RILRequest.obtain(RIL_REQUEST_OPERATOR, result);
send(rr);
}
当接收到RIL的返回数据后,就会接收到EVENT_POLL_STATE_OPERATOR的消息:
public void handleMessage (Message msg) {
AsyncResult ar;
int[] ints;
String[] strings;
Message message;
switch (msg.what) {
case EVENT_POLL_STATE_REGISTRATION:
case EVENT_POLL_STATE_GPRS:
case EVENT_POLL_STATE_OPERATOR:
case EVENT_POLL_STATE_NETWORK_SELECTION_MODE:
ar = (AsyncResult) msg.obj;
handlePollStateResult(msg.what, ar);
break;
default:
super.handleMessage(msg);
break;
}
}
然后在handlePollStateResult()中处理该消息:
protected void handlePollStateResult (int what, AsyncResult ar) {
int ints[];
String states[];
switch (what) {
case EVENT_POLL_STATE_OPERATOR: {
//获取返回值
String opNames[] = (String[])ar.result;
if (opNames != null && opNames.length >= 3) {
//Plmn可以由应用特意指定(通过setOperatorBrandOverride方法),而无需理会Modem读取的值,但实际上该方法并未被使用
String brandOverride = mUiccController.getUiccCard() != null ? mUiccController.getUiccCard().getOperatorBrandOverride() : null;
if (brandOverride != null) {
//如果是被特意指定的,就直接使用,与Modem返回值无关
mNewSS.setOperatorName(brandOverride, brandOverride, opNames[2]);
} else {
//默认情况下根据RIL返回值设置当前的Plmn
mNewSS.setOperatorName(opNames[0], opNames[1], opNames[2]);
}
}
break;
}
}
}
这里看到,mNewSS(也就是ServiceState)可以从两个途径获取Plmn:
@ServiceState.java
public void setOperatorName(String longName, String shortName, String numeric) {
mOperatorAlphaLong = longName;
mOperatorAlphaShort = shortName;
mOperatorNumeric = numeric;
}
由此,便将当前的Plmn Name保存在ServiceState对象中,其他对象就可以
通过ServiceState的getOperatorAlphaLong()方法得到当前的Plmn值:
public String getOperatorAlphaLong() {
return mOperatorAlphaLong;
}
这就是Plmn Name的读取流程。
下面一节介绍SPN的读取过程。