Bug 725137 - RIL: process registration state + GPRS registration state. r=qDot

This commit is contained in:
Philipp von Weitershausen 2012-02-10 11:27:23 -08:00
parent 78535c5387
commit 4c24c2a473
3 changed files with 139 additions and 36 deletions

View File

@ -180,6 +180,12 @@ RadioInterfaceLayer.prototype = {
// This one will handle its own notifications.
this.handleEnumerateCalls(message.calls);
break;
case "registrationstatechange":
this.currentState.registrationState = message.registrationState;
break;
case "gprsregistrationstatechange":
this.currentState.gprsRegistrationState = message.gprsRegistrationState;
break;
case "signalstrengthchange":
this.currentState.signalStrength = message.signalStrength;
break;

View File

@ -204,6 +204,28 @@ const CARD_APP_STATE_READY = 5;
const CARD_MAX_APPS = 8;
// Network registration states. See TS 27.007 7.2
const NETWORK_CREG_STATE_NOT_SEARCHING = 0;
const NETWORK_CREG_STATE_REGISTERED_HOME = 1;
const NETWORK_CREG_STATE_SEARCHING = 2;
const NETWORK_CREG_STATE_DENIED = 3;
const NETWORK_CREG_STATE_UNKNOWN = 4;
const NETWORK_CREG_STATE_REGISTERED_ROAMING = 5;
const NETWORK_CREG_TECH_UNKNOWN = 0;
const NETWORK_CREG_TECH_GPRS = 1;
const NETWORK_CREG_TECH_EDGE = 2;
const NETWORK_CREG_TECH_UMTS = 3;
const NETWORK_CREG_TECH_IS95A = 4;
const NETWORK_CREG_TECH_IS95B = 5;
const NETWORK_CREG_TECH_1XRTT = 6;
const NETWORK_CREG_TECH_EVDO0 = 7;
const NETWORK_CREG_TECH_EVDOA = 8;
const NETWORK_CREG_TECH_HSDPA = 9;
const NETWORK_CREG_TECH_HSUPA = 10;
const NETWORK_CREG_TECH_HSPA = 11;
const NETWORK_CREG_TECH_EVDOB = 12;
const CALL_STATE_ACTIVE = 0;
const CALL_STATE_HOLDING = 1;
const CALL_STATE_DIALING = 2;
@ -222,23 +244,6 @@ const CALL_PRESENTATION_PAYPHONE = 3;
const SMS_HANDLED = 0;
/**
* DOM constants
*/
const DOM_RADIOSTATE_UNAVAILABLE = "unavailable";
const DOM_RADIOSTATE_OFF = "off";
const DOM_RADIOSTATE_READY = "ready";
const DOM_CARDSTATE_UNAVAILABLE = "unavailable";
const DOM_CARDSTATE_ABSENT = "absent";
const DOM_CARDSTATE_PIN_REQUIRED = "pin_required";
const DOM_CARDSTATE_PUK_REQUIRED = "puk_required";
const DOM_CARDSTATE_NETWORK_LOCKED = "network_locked";
const DOM_CARDSTATE_NOT_READY = "not_ready";
const DOM_CARDSTATE_READY = "ready";
/**
* GSM PDU constants
*/
@ -433,6 +438,19 @@ const GECKO_DATACALL_STATE_CONNECTED = 2;
const GECKO_DATACALL_STATE_DISCONNECTING = 3;
const GECKO_DATACALL_STATE_DISCONNECTED = 4;
// Other Gecko-specific constants
const GECKO_RADIOSTATE_UNAVAILABLE = "unavailable";
const GECKO_RADIOSTATE_OFF = "off";
const GECKO_RADIOSTATE_READY = "ready";
const GECKO_CARDSTATE_UNAVAILABLE = "unavailable";
const GECKO_CARDSTATE_ABSENT = "absent";
const GECKO_CARDSTATE_PIN_REQUIRED = "pin_required";
const GECKO_CARDSTATE_PUK_REQUIRED = "puk_required";
const GECKO_CARDSTATE_NETWORK_LOCKED = "network_locked";
const GECKO_CARDSTATE_NOT_READY = "not_ready";
const GECKO_CARDSTATE_READY = "ready";
// Allow this file to be imported via Components.utils.import().
const EXPORTED_SYMBOLS = Object.keys(this);

View File

@ -539,6 +539,27 @@ let RIL = {
this.rilQuirksInitialized = true;
},
/**
* Parse an integer from a string, falling back to a default value
* if the the provided value is not a string or does not contain a valid
* number.
*
* @param string
* String to be parsed.
* @param defaultValue
* Default value to be used.
*/
parseInt: function RIL_parseInt(string, defaultValue) {
let number = parseInt(string, 10);
if (!isNaN(number)) {
return number;
}
if (defaultValue === undefined) {
defaultValue = null;
}
return defaultValue;
},
/**
* Retrieve the ICC's status.
*
@ -1261,6 +1282,9 @@ let Phone = {
IMSI: null,
SMSC: null,
registrationState: {},
gprsRegistrationState: {},
/**
* List of strings identifying the network operator.
*/
@ -1375,7 +1399,7 @@ let Phone = {
this.sendDOMMessage({
type: "radiostatechange",
radioState: (newState == RADIO_STATE_OFF) ?
DOM_RADIOSTATE_OFF : DOM_RADIOSTATE_READY
GECKO_RADIOSTATE_OFF : GECKO_RADIOSTATE_READY
});
//XXX TODO For now, just turn the radio on if it's off. for the real
@ -1392,7 +1416,7 @@ let Phone = {
//TODO do that
this.sendDOMMessage({type: "radiostatechange",
radioState: DOM_RADIOSTATE_UNAVAILABLE});
radioState: GECKO_RADIOSTATE_UNAVAILABLE});
}
if (newState == RADIO_STATE_SIM_READY ||
@ -1404,13 +1428,13 @@ let Phone = {
RIL.getSignalStrength();
RIL.getSMSCAddress();
this.sendDOMMessage({type: "cardstatechange",
cardState: DOM_CARDSTATE_READY});
cardState: GECKO_CARDSTATE_READY});
}
if (newState == RADIO_STATE_SIM_LOCKED_OR_ABSENT ||
newState == RADIO_STATE_RUIM_LOCKED_OR_ABSENT) {
RIL.getICCStatus();
this.sendDOMMessage({type: "cardstatechange",
cardState: DOM_CARDSTATE_UNAVAILABLE});
cardState: GECKO_CARDSTATE_UNAVAILABLE});
}
let wasOn = this.radioState != RADIO_STATE_OFF &&
@ -1496,10 +1520,10 @@ let Phone = {
if ((!iccStatus) || (iccStatus.cardState == CARD_STATE_ABSENT)) {
if (DEBUG) debug("ICC absent");
if (this.cardState == DOM_CARDSTATE_ABSENT) {
if (this.cardState == GECKO_CARDSTATE_ABSENT) {
return;
}
this.cardState = DOM_CARDSTATE_ABSENT;
this.cardState = GECKO_CARDSTATE_ABSENT;
this.sendDOMMessage({type: "cardstatechange",
cardState: this.cardState});
return;
@ -1512,10 +1536,10 @@ let Phone = {
(this.radioState == RADIO_STATE_NV_NOT_READY) ||
(this.radioState == RADIO_STATE_NV_READY)) {
if (DEBUG) debug("ICC not ready");
if (this.cardState == DOM_CARDSTATE_NOT_READY) {
if (this.cardState == GECKO_CARDSTATE_NOT_READY) {
return;
}
this.cardState = DOM_CARDSTATE_NOT_READY;
this.cardState = GECKO_CARDSTATE_NOT_READY;
this.sendDOMMessage({type: "cardstatechange",
cardState: this.cardState});
return;
@ -1530,10 +1554,10 @@ let Phone = {
if (DEBUG) {
debug("Subscription application is not present in iccStatus.");
}
if (this.cardState == DOM_CARDSTATE_ABSENT) {
if (this.cardState == GECKO_CARDSTATE_ABSENT) {
return;
}
this.cardState = DOM_CARDSTATE_ABSENT;
this.cardState = GECKO_CARDSTATE_ABSENT;
this.sendDOMMessage({type: "cardstatechange",
cardState: this.cardState});
return;
@ -1542,21 +1566,21 @@ let Phone = {
let newCardState;
switch (app.app_state) {
case CARD_APP_STATE_PIN:
newCardState = DOM_CARDSTATE_PIN_REQUIRED;
newCardState = GECKO_CARDSTATE_PIN_REQUIRED;
break;
case CARD_APP_STATE_PUK:
newCardState = DOM_CARDSTATE_PUK_REQUIRED;
newCardState = GECKO_CARDSTATE_PUK_REQUIRED;
break;
case CARD_APP_STATE_SUBSCRIPTION_PERSO:
newCardState = DOM_CARDSTATE_NETWORK_LOCKED;
newCardState = GECKO_CARDSTATE_NETWORK_LOCKED;
break;
case CARD_APP_STATE_READY:
newCardState = DOM_CARDSTATE_READY;
newCardState = GECKO_CARDSTATE_READY;
break;
case CARD_APP_STATE_UNKNOWN:
case CARD_APP_STATE_DETECTED:
default:
newCardState = DOM_CARDSTATE_NOT_READY;
newCardState = GECKO_CARDSTATE_NOT_READY;
}
if (this.cardState == newCardState) {
@ -1607,12 +1631,67 @@ let Phone = {
this.IMEISV = imeiSV;
},
onRegistrationState: function onRegistrationState(newState) {
this.registrationState = newState;
onRegistrationState: function onRegistrationState(state) {
let rs = this.registrationState;
let stateChanged = false;
let regState = RIL.parseInt(state[0], NETWORK_CREG_STATE_UNKNOWN);
if (rs.regState != regState) {
rs.regState = regState;
stateChanged = true;
}
let radioTech = RIL.parseInt(state[3], NETWORK_CREG_TECH_UNKNOWN);
if (rs.radioTech != radioTech) {
rs.radioTech = radioTech;
stateChanged = true;
}
// TODO: This zombie code branch that will be raised from the dead once
// we add explicit CDMA support everywhere (bug 726098).
let cdma = false;
if (cdma) {
let baseStationId = RIL.parseInt(state[4]);
let baseStationLatitude = RIL.parseInt(state[5]);
let baseStationLongitude = RIL.parseInt(state[6]);
if (!baseStationLatitude && !baseStationLongitude) {
baseStationLatitude = baseStationLongitude = null;
}
let cssIndicator = RIL.parseInt(state[7]);
let systemId = RIL.parseInt(state[8]);
let networkId = RIL.parseInt(state[9]);
let roamingIndicator = RIL.parseInt(state[10]);
let systemIsInPRL = RIL.parseInt(state[11]);
let defaultRoamingIndicator = RIL.parseInt(state[12]);
let reasonForDenial = RIL.parseInt(state[13]);
}
if (stateChanged) {
this.sendDOMMessage({type: "registrationstatechange",
registrationState: rs});
}
},
onGPRSRegistrationState: function onGPRSRegistrationState(newState) {
this.gprsRegistrationState = newState;
onGPRSRegistrationState: function onGPRSRegistrationState(state) {
let rs = this.gprsRegistrationState;
let stateChanged = false;
let regState = RIL.parseInt(state[0], NETWORK_CREG_STATE_UNKNOWN);
if (rs.regState != regState) {
rs.regState = regState;
stateChanged = true;
}
let radioTech = RIL.parseInt(state[3], NETWORK_CREG_TECH_UNKNOWN);
if (rs.radioTech != radioTech) {
rs.radioTech = radioTech;
stateChanged = true;
}
if (stateChanged) {
this.sendDOMMessage({type: "gprsregistrationstatechange",
gprsRegistrationState: rs});
}
},
onOperator: function onOperator(operator) {