зеркало из https://github.com/mozilla/gecko-dev.git
Bug 767620 - Part 2: RIL implementation. r=philikon
This commit is contained in:
Родитель
9f38208bc6
Коммит
39b0d0c173
|
@ -349,7 +349,7 @@ SmsDatabaseService.prototype = {
|
|||
saveReceivedMessage: function saveReceivedMessage(sender, body, date) {
|
||||
let message = {delivery: DELIVERY_RECEIVED,
|
||||
sender: sender,
|
||||
receiver: this.mRIL.radioState.msisdn,
|
||||
receiver: this.mRIL.rilContext.icc.msisdn,
|
||||
body: body,
|
||||
timestamp: date,
|
||||
read: FILTER_READ_UNREAD};
|
||||
|
@ -358,7 +358,7 @@ SmsDatabaseService.prototype = {
|
|||
|
||||
saveSentMessage: function saveSentMessage(receiver, body, date) {
|
||||
let message = {delivery: DELIVERY_SENT,
|
||||
sender: this.mRIL.radioState.msisdn,
|
||||
sender: this.mRIL.rilContext.icc.msisdn,
|
||||
receiver: receiver,
|
||||
body: body,
|
||||
timestamp: date,
|
||||
|
|
|
@ -30,7 +30,7 @@ const DOM_SMS_DELIVERY_RECEIVED = "received";
|
|||
const DOM_SMS_DELIVERY_SENT = "sent";
|
||||
|
||||
const RIL_IPC_MSG_NAMES = [
|
||||
"RIL:GetRadioState",
|
||||
"RIL:GetRilContext",
|
||||
"RIL:EnumerateCalls",
|
||||
"RIL:GetMicrophoneMuted",
|
||||
"RIL:SetMicrophoneMuted",
|
||||
|
@ -146,7 +146,7 @@ function RadioInterfaceLayer() {
|
|||
this.worker.onerror = this.onerror.bind(this);
|
||||
this.worker.onmessage = this.onmessage.bind(this);
|
||||
|
||||
this.radioState = {
|
||||
this.rilContext = {
|
||||
radioState: RIL.GECKO_RADIOSTATE_UNAVAILABLE,
|
||||
cardState: RIL.GECKO_CARDSTATE_UNAVAILABLE,
|
||||
icc: null,
|
||||
|
@ -161,7 +161,7 @@ function RadioInterfaceLayer() {
|
|||
type: null,
|
||||
signalStrength: null,
|
||||
relSignalStrength: null},
|
||||
data: {connected: false,
|
||||
data: {connected: false,
|
||||
emergencyCallsOnly: false,
|
||||
roaming: false,
|
||||
network: null,
|
||||
|
@ -204,9 +204,9 @@ RadioInterfaceLayer.prototype = {
|
|||
receiveMessage: function receiveMessage(msg) {
|
||||
debug("Received '" + msg.name + "' message from content process");
|
||||
switch (msg.name) {
|
||||
case "RIL:GetRadioState":
|
||||
case "RIL:GetRilContext":
|
||||
// This message is sync.
|
||||
return this.radioState;
|
||||
return this.rilContext;
|
||||
case "RIL:EnumerateCalls":
|
||||
this.enumerateCalls();
|
||||
break;
|
||||
|
@ -324,7 +324,7 @@ RadioInterfaceLayer.prototype = {
|
|||
this.handleRadioStateChange(message);
|
||||
break;
|
||||
case "cardstatechange":
|
||||
this.radioState.cardState = message.cardState;
|
||||
this.rilContext.cardState = message.cardState;
|
||||
ppmm.sendAsyncMessage("RIL:CardStateChanged", message);
|
||||
break;
|
||||
case "sms-received":
|
||||
|
@ -359,7 +359,7 @@ RadioInterfaceLayer.prototype = {
|
|||
" timestamp=" + message.localTimeStampInMS);
|
||||
break;
|
||||
case "iccinfochange":
|
||||
this.radioState.icc = message;
|
||||
this.rilContext.icc = message;
|
||||
break;
|
||||
case "iccgetcardlock":
|
||||
this.handleICCGetCardLock(message);
|
||||
|
@ -381,7 +381,7 @@ RadioInterfaceLayer.prototype = {
|
|||
}
|
||||
break;
|
||||
case "celllocationchanged":
|
||||
this.radioState.cell = message;
|
||||
this.rilContext.cell = message;
|
||||
break;
|
||||
case "ussdreceived":
|
||||
debug("ussdreceived " + JSON.stringify(message));
|
||||
|
@ -399,7 +399,7 @@ RadioInterfaceLayer.prototype = {
|
|||
},
|
||||
|
||||
updateVoiceConnection: function updateVoiceConnection(state) {
|
||||
let voiceInfo = this.radioState.voice;
|
||||
let voiceInfo = this.rilContext.voice;
|
||||
voiceInfo.type = "gsm"; //TODO see bug 726098.
|
||||
if (!state || state.regState == RIL.NETWORK_CREG_STATE_UNKNOWN) {
|
||||
voiceInfo.connected = false;
|
||||
|
@ -466,13 +466,13 @@ RadioInterfaceLayer.prototype = {
|
|||
|
||||
handleSignalStrengthChange: function handleSignalStrengthChange(message) {
|
||||
// TODO CDMA, EVDO, LTE, etc. (see bug 726098)
|
||||
this.radioState.voice.signalStrength = message.gsmDBM;
|
||||
this.radioState.voice.relSignalStrength = message.gsmRelative;
|
||||
ppmm.sendAsyncMessage("RIL:VoiceInfoChanged", this.radioState.voice);
|
||||
this.rilContext.voice.signalStrength = message.gsmDBM;
|
||||
this.rilContext.voice.relSignalStrength = message.gsmRelative;
|
||||
ppmm.sendAsyncMessage("RIL:VoiceInfoChanged", this.rilContext.voice);
|
||||
|
||||
this.radioState.data.signalStrength = message.gsmDBM;
|
||||
this.radioState.data.relSignalStrength = message.gsmRelative;
|
||||
ppmm.sendAsyncMessage("RIL:DataInfoChanged", this.radioState.data);
|
||||
this.rilContext.data.signalStrength = message.gsmDBM;
|
||||
this.rilContext.data.relSignalStrength = message.gsmRelative;
|
||||
ppmm.sendAsyncMessage("RIL:DataInfoChanged", this.rilContext.data);
|
||||
},
|
||||
|
||||
networkChanged: function networkChanged(srcNetwork, destNetwork) {
|
||||
|
@ -484,8 +484,8 @@ RadioInterfaceLayer.prototype = {
|
|||
},
|
||||
|
||||
handleOperatorChange: function handleOperatorChange(message) {
|
||||
let voice = this.radioState.voice;
|
||||
let data = this.radioState.data;
|
||||
let voice = this.rilContext.voice;
|
||||
let data = this.rilContext.data;
|
||||
|
||||
if (this.networkChanged(message, voice.network)) {
|
||||
voice.network = message;
|
||||
|
@ -500,34 +500,34 @@ RadioInterfaceLayer.prototype = {
|
|||
|
||||
handleRadioStateChange: function handleRadioStateChange(message) {
|
||||
let newState = message.radioState;
|
||||
if (this.radioState.radioState == newState) {
|
||||
if (this.rilContext.radioState == newState) {
|
||||
return;
|
||||
}
|
||||
this.radioState.radioState = newState;
|
||||
this.rilContext.radioState = newState;
|
||||
//TODO Should we notify this change as a card state change?
|
||||
|
||||
this._ensureRadioState();
|
||||
},
|
||||
|
||||
_ensureRadioState: function _ensureRadioState() {
|
||||
debug("Reported radio state is " + this.radioState.radioState +
|
||||
debug("Reported radio state is " + this.rilContext.radioState +
|
||||
", desired radio enabled state is " + this._radioEnabled);
|
||||
if (this._radioEnabled == null) {
|
||||
// We haven't read the initial value from the settings DB yet.
|
||||
// Wait for that.
|
||||
return;
|
||||
}
|
||||
if (this.radioState.radioState == RIL.GECKO_RADIOSTATE_UNKNOWN) {
|
||||
if (this.rilContext.radioState == RIL.GECKO_RADIOSTATE_UNKNOWN) {
|
||||
// We haven't received a radio state notification from the RIL
|
||||
// yet. Wait for that.
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.radioState.radioState == RIL.GECKO_RADIOSTATE_OFF &&
|
||||
if (this.rilContext.radioState == RIL.GECKO_RADIOSTATE_OFF &&
|
||||
this._radioEnabled) {
|
||||
this.setRadioEnabled(true);
|
||||
}
|
||||
if (this.radioState.radioState == RIL.GECKO_RADIOSTATE_READY &&
|
||||
if (this.rilContext.radioState == RIL.GECKO_RADIOSTATE_READY &&
|
||||
!this._radioEnabled) {
|
||||
this.setRadioEnabled(false);
|
||||
}
|
||||
|
@ -637,7 +637,7 @@ RadioInterfaceLayer.prototype = {
|
|||
bearer: WAP.WDP_BEARER_GSM_SMS_GSM_MSISDN,
|
||||
sourceAddress: message.sender,
|
||||
sourcePort: message.header.originatorPort,
|
||||
destinationAddress: this.radioState.icc.MSISDN,
|
||||
destinationAddress: this.rilContext.icc.msisdn,
|
||||
destinationPort: message.header.destinationPort,
|
||||
};
|
||||
WAP.WapPushManager.receiveWdpPDU(message.fullData, message.fullData.length,
|
||||
|
@ -890,7 +890,7 @@ RadioInterfaceLayer.prototype = {
|
|||
this.worker.postMessage({type: "setRadioPower", on: value});
|
||||
},
|
||||
|
||||
radioState: null,
|
||||
rilContext: null,
|
||||
|
||||
// Handle phone functions of nsIRILContentHelper
|
||||
|
||||
|
|
|
@ -1000,11 +1000,11 @@ let RIL = {
|
|||
debug("ICC_EF_MSISDN: invalid length of BCD number/SSC contents - " + len);
|
||||
return;
|
||||
}
|
||||
this.iccInfo.MSISDN = GsmPDUHelper.readDiallingNumber(len);
|
||||
this.iccInfo.msisdn = GsmPDUHelper.readDiallingNumber(len);
|
||||
Buf.readStringDelimiter(length);
|
||||
|
||||
if (DEBUG) debug("MSISDN: " + this.iccInfo.MSISDN);
|
||||
if (this.iccInfo.MSISDN) {
|
||||
if (DEBUG) debug("MSISDN: " + this.iccInfo.msisdn);
|
||||
if (this.iccInfo.msisdn) {
|
||||
this._handleICCInfoChange();
|
||||
}
|
||||
}
|
||||
|
@ -1024,30 +1024,30 @@ let RIL = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Read the AD from the ICC.
|
||||
* Read the AD (Administrative Data) from the ICC.
|
||||
*/
|
||||
getAD: function getAD() {
|
||||
function callback() {
|
||||
let length = Buf.readUint32();
|
||||
// Each octet is encoded into two chars.
|
||||
let len = length / 2;
|
||||
this.iccInfo.AD = GsmPDUHelper.readHexOctetArray(len);
|
||||
this.iccInfo.ad = GsmPDUHelper.readHexOctetArray(len);
|
||||
Buf.readStringDelimiter(length);
|
||||
|
||||
if (DEBUG) {
|
||||
let str = "";
|
||||
for (let i = 0; i < this.iccInfo.AD.length; i++) {
|
||||
str += this.iccInfo.AD[i] + ", ";
|
||||
for (let i = 0; i < this.iccInfo.ad.length; i++) {
|
||||
str += this.iccInfo.ad[i] + ", ";
|
||||
}
|
||||
debug("AD: " + str);
|
||||
}
|
||||
|
||||
if (this.iccInfo.IMSI) {
|
||||
if (this.iccInfo.imsi) {
|
||||
// MCC is the first 3 digits of IMSI
|
||||
this.iccInfo.MCC = this.iccInfo.IMSI.substr(0,3);
|
||||
this.iccInfo.mcc = parseInt(this.iccInfo.imsi.substr(0,3));
|
||||
// The 4th byte of the response is the length of MNC
|
||||
this.iccInfo.MNC = this.iccInfo.IMSI.substr(3, this.iccInfo.AD[3]);
|
||||
if (DEBUG) debug("MCC: " + this.iccInfo.MCC + " MNC: " + this.iccInfo.MNC);
|
||||
this.iccInfo.mnc = parseInt(this.iccInfo.imsi.substr(3, this.iccInfo.ad[3]));
|
||||
if (DEBUG) debug("MCC: " + this.iccInfo.mcc + " MNC: " + this.iccInfo.mnc);
|
||||
this._handleICCInfoChange();
|
||||
}
|
||||
}
|
||||
|
@ -1079,7 +1079,9 @@ let RIL = {
|
|||
service -= 1;
|
||||
let index = service / 8;
|
||||
let bitmask = 1 << (service % 8);
|
||||
return this.UST && (index < this.UST.length) && (this.UST[index] & bitmask);
|
||||
return this.iccInfo.ust &&
|
||||
(index < this.iccInfo.ust.length) &&
|
||||
(this.iccInfo.ust[index] & bitmask);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1090,13 +1092,13 @@ let RIL = {
|
|||
let length = Buf.readUint32();
|
||||
// Each octet is encoded into two chars.
|
||||
let len = length / 2;
|
||||
this.iccInfo.UST = GsmPDUHelper.readHexOctetArray(len);
|
||||
this.iccInfo.ust = GsmPDUHelper.readHexOctetArray(len);
|
||||
Buf.readStringDelimiter(length);
|
||||
|
||||
if (DEBUG) {
|
||||
let str = "";
|
||||
for (let i = 0; i < this.iccInfo.UST.length; i++) {
|
||||
str += this.iccInfo.UST[i] + ", ";
|
||||
for (let i = 0; i < this.iccInfo.ust.length; i++) {
|
||||
str += this.iccInfo.ust[i] + ", ";
|
||||
}
|
||||
debug("UST: " + str);
|
||||
}
|
||||
|
@ -1182,24 +1184,24 @@ let RIL = {
|
|||
getFDN: function getFDN(options) {
|
||||
function callback(options) {
|
||||
function add(contact) {
|
||||
this.iccInfo.FDN.push(contact);
|
||||
this.iccInfo.fdn.push(contact);
|
||||
};
|
||||
function finish() {
|
||||
if (DEBUG) {
|
||||
for (let i = 0; i < this.iccInfo.FDN.length; i++) {
|
||||
debug("FDN[" + i + "] alphaId = " + this.iccInfo.FDN[i].alphaId +
|
||||
" number = " + this.iccInfo.FDN[i].number);
|
||||
for (let i = 0; i < this.iccInfo.fdn.length; i++) {
|
||||
debug("FDN[" + i + "] alphaId = " + this.iccInfo.fdn[i].alphaId +
|
||||
" number = " + this.iccInfo.fdn[i].number);
|
||||
}
|
||||
}
|
||||
this.sendDOMMessage({type: "icccontacts",
|
||||
contactType: "FDN",
|
||||
contacts: this.iccInfo.FDN,
|
||||
contacts: this.iccInfo.fdn,
|
||||
requestId: options.requestId});
|
||||
};
|
||||
this.parseDiallingNumber(options, add, finish);
|
||||
}
|
||||
|
||||
this.iccInfo.FDN = [];
|
||||
this.iccInfo.fdn = [];
|
||||
this.iccIO({
|
||||
command: ICC_COMMAND_GET_RESPONSE,
|
||||
fileId: ICC_EF_FDN,
|
||||
|
@ -1227,24 +1229,24 @@ let RIL = {
|
|||
getADN: function getADN(options) {
|
||||
function callback(options) {
|
||||
function add(contact) {
|
||||
this.iccInfo.ADN.push(contact);
|
||||
this.iccInfo.adn.push(contact);
|
||||
};
|
||||
function finish() {
|
||||
if (DEBUG) {
|
||||
for (let i = 0; i < this.iccInfo.ADN.length; i++) {
|
||||
debug("ADN[" + i + "] alphaId = " + this.iccInfo.ADN[i].alphaId +
|
||||
" number = " + this.iccInfo.ADN[i].number);
|
||||
for (let i = 0; i < this.iccInfo.adn.length; i++) {
|
||||
debug("ADN[" + i + "] alphaId = " + this.iccInfo.adn[i].alphaId +
|
||||
" number = " + this.iccInfo.adn[i].number);
|
||||
}
|
||||
}
|
||||
this.sendDOMMessage({type: "icccontacts",
|
||||
contactType: "ADN",
|
||||
contacts: this.iccInfo.ADN,
|
||||
contacts: this.iccInfo.adn,
|
||||
requestId: options.requestId});
|
||||
};
|
||||
this.parseDiallingNumber(options, add, finish);
|
||||
}
|
||||
|
||||
this.iccInfo.ADN = [];
|
||||
this.iccInfo.adn = [];
|
||||
this.iccIO({
|
||||
command: ICC_COMMAND_GET_RESPONSE,
|
||||
fileId: options.fileId,
|
||||
|
@ -2006,13 +2008,15 @@ let RIL = {
|
|||
|
||||
// From TS 23.003, 0000 and 0xfffe are indicated that no valid LAI exists
|
||||
// in MS. So we still need to report the '0000' as well.
|
||||
if (cell.lac !== state[1]) {
|
||||
cell.lac = state[1];
|
||||
let lac = parseInt(state[1], 16);
|
||||
if (cell.lac !== lac) {
|
||||
cell.lac = lac;
|
||||
cellChanged = true;
|
||||
}
|
||||
|
||||
if (cell.cid !== state[2]) {
|
||||
cell.cid = state[2];
|
||||
let cid = parseInt(state[2], 16);
|
||||
if (cell.cid !== cid) {
|
||||
cell.cid = cid;
|
||||
cellChanged = true;
|
||||
}
|
||||
|
||||
|
@ -2703,7 +2707,7 @@ RIL[REQUEST_GET_IMSI] = function REQUEST_GET_IMSI(length, options) {
|
|||
return;
|
||||
}
|
||||
|
||||
this.iccInfo.IMSI = Buf.readString();
|
||||
this.iccInfo.imsi = Buf.readString();
|
||||
};
|
||||
RIL[REQUEST_HANGUP] = function REQUEST_HANGUP(length, options) {
|
||||
if (options.rilRequestError) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче