Bug 833277 - Tell if we are on CDMA network r=vicamo

This commit is contained in:
Patrick Wang 2013-01-22 19:01:04 +08:00
Родитель 22d41f0b1f
Коммит f12e810a62
2 изменённых файлов: 103 добавлений и 10 удалений

Просмотреть файл

@ -129,10 +129,10 @@ this.REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE = 104;
this.REQUEST_ISIM_AUTHENTICATION = 105;
this.REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU = 106;
this.REQUEST_STK_SEND_ENVELOPE_WITH_STATUS = 107;
this.REQUEST_VOICE_RADIO_TECH = 108;
this.REQUEST_DIAL_EMERGENCY_CALL = 10016;
// Akami/Maguro specific parcel types.
this.REQUEST_VOICE_RADIO_TECH = 105;
this.REQUEST_IMS_REGISTRATION_STATE = 106;
this.REQUEST_IMS_SEND_SMS = 107;
this.REQUEST_GET_DATA_CALL_PROFILE = 108;
@ -248,7 +248,7 @@ this.SMS_RETRY_MAX = 3;
this.RADIO_STATE_OFF = 0;
this.RADIO_STATE_UNAVAILABLE = 1;
this.RADIO_STATE_ON = 2;
this.RADIO_STATE_ON = 10; // RIL v7
// RIL v5 legacy constants:
this.RADIO_STATE_SIM_NOT_READY = 2;
@ -383,6 +383,7 @@ this.NETWORK_CREG_TECH_EVDOB = 12;
this.NETWORK_CREG_TECH_EHRPD = 13;
this.NETWORK_CREG_TECH_LTE = 14;
this.NETWORK_CREG_TECH_HSPAP = 15;
this.NETWORK_CREG_TECH_GSM = 16;
this.CALL_STATE_ACTIVE = 0;
this.CALL_STATE_HOLDING = 1;
@ -2325,6 +2326,7 @@ this.GECKO_RADIO_TECH = [
"ehrpd",
"lte",
"hspa+",
"gsm"
];
this.GECKO_VOICEMAIL_MESSAGE_COUNT_UNKNOWN = -1;

Просмотреть файл

@ -756,6 +756,17 @@ let RIL = {
this.radioState = GECKO_RADIOSTATE_UNAVAILABLE;
this._isInitialRadioState = true;
/**
* True if we are on CDMA network.
*/
this._isCdma = false;
/**
* Set when radio is ready but radio tech is unknown. That is, we are
* waiting for REQUEST_VOICE_RADIO_TECH
*/
this._waitingRadioTech = false;
/**
* ICC status. Keeps a reference of the data response to the
* getICCStatus request.
@ -1456,6 +1467,10 @@ let RIL = {
Buf.simpleRequest(REQUEST_VOICE_REGISTRATION_STATE);
},
getVoiceRadioTechnology: function getVoiceRadioTechnology() {
Buf.simpleRequest(REQUEST_VOICE_RADIO_TECH);
},
getDataRegistrationState: function getDataRegistrationState() {
Buf.simpleRequest(REQUEST_DATA_REGISTRATION_STATE);
},
@ -3296,6 +3311,47 @@ let RIL = {
network.mnc = mnc;
},
/**
* Process radio technology change.
*/
_processRadioTech: function _processRadioTech(radioTech) {
let isCdma = true;
this.radioTech = radioTech;
switch(radioTech) {
case NETWORK_CREG_TECH_GPRS:
case NETWORK_CREG_TECH_EDGE:
case NETWORK_CREG_TECH_UMTS:
case NETWORK_CREG_TECH_HSDPA:
case NETWORK_CREG_TECH_HSUPA:
case NETWORK_CREG_TECH_HSPA:
case NETWORK_CREG_TECH_LTE:
case NETWORK_CREG_TECH_HSPAP:
case NETWORK_CREG_TECH_GSM:
isCdma = false;
};
if (DEBUG) {
debug("Radio tech is set to: " + GECKO_RADIO_TECH[radioTech] +
", it is a " + (isCdma?"cdma":"gsm") + " technology");
}
// We should request SIM information when
// 1. Radio state has been changed, so we are waiting for radioTech or
// 2. isCdma is different from this._isCdma.
if (this._waitingRadioTech || isCdma != this._isCdma) {
this._isCdma = isCdma;
this._waitingRadioTech = false;
if (this._isCdma) {
this.getDeviceIdentity();
} else {
this.getIMEI();
this.getIMEISV();
}
this.getICCStatus();
}
},
/**
* Helper for returning the TOA for the given dial string.
*/
@ -4955,6 +5011,16 @@ RIL[REQUEST_STK_SEND_ENVELOPE_WITH_STATUS] = function REQUEST_STK_SEND_ENVELOPE_
this.acknowledgeIncomingGsmSmsWithPDU(success, responsePduLen, options);
};
RIL[REQUEST_VOICE_RADIO_TECH] = function REQUEST_VOICE_RADIO_TECH(length, options) {
if (options.rilRequestError) {
if (DEBUG) {
debug("Error when getting voice radio tech: " + options.rilRequestError);
}
return;
}
let radioTech = Buf.readUint32List();
this._processRadioTech(radioTech[0]);
};
RIL[UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED] = function UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED() {
let radioState = Buf.readUint32();
@ -4984,18 +5050,41 @@ RIL[UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED] = function UNSOLICITED_RESPONSE_RA
return;
}
// TODO hardcoded for now (see bug 726098)
let cdma = false;
switch (radioState) {
case RADIO_STATE_SIM_READY:
case RADIO_STATE_SIM_NOT_READY:
case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
this._isCdma = false;
this._waitingRadioTech = false;
break;
case RADIO_STATE_RUIM_READY:
case RADIO_STATE_RUIM_NOT_READY:
case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
case RADIO_STATE_NV_READY:
case RADIO_STATE_NV_NOT_READY:
this._isCdma = true;
this._waitingRadioTech = false;
break;
case RADIO_STATE_ON: // RIL v7
// This value is defined in RIL v7, we will retrieve radio tech by another
// request. We leave _isCdma untouched, and it will be set once we get the
// radio technology.
this._waitingRadioTech = true;
this.getVoiceRadioTechnology();
break;
}
if ((this.radioState == GECKO_RADIOSTATE_UNAVAILABLE ||
this.radioState == GECKO_RADIOSTATE_OFF) &&
newState == GECKO_RADIOSTATE_READY) {
// The radio became available, let's get its info.
if (cdma) {
this.getDeviceIdentity();
} else {
this.getIMEI();
this.getIMEISV();
if (!this._waitingRadioTech) {
if (this._isCdma) {
this.getDeviceIdentity();
} else {
this.getIMEI();
this.getIMEISV();
}
}
this.getBasebandVersion();
this.updateCellBroadcastConfig();
@ -5009,8 +5098,10 @@ RIL[UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED] = function UNSOLICITED_RESPONSE_RA
// If the radio is up and on, so let's query the card state.
// On older RILs only if the card is actually ready, though.
// If _waitingRadioTech is set, we don't need to get icc status now.
if (radioState == RADIO_STATE_UNAVAILABLE ||
radioState == RADIO_STATE_OFF) {
radioState == RADIO_STATE_OFF ||
this._waitingRadioTech) {
return;
}
this.getICCStatus();