Bug 780558 - B2G RIL: expose cell LAC/CID - Part 2: RIL implementation, r=philikon

This commit is contained in:
Vicamo Yang 2012-08-15 12:35:46 +08:00
Родитель 8d001adc76
Коммит 6bbee37bbc
5 изменённых файлов: 87 добавлений и 58 удалений

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

@ -24,6 +24,7 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsINetworkManager.h"
#include "nsIRadioInterfaceLayer.h"
#include "nsIDOMMobileConnection.h"
#include "nsThreadUtils.h"
#ifdef AGPS_TYPE_INVALID
@ -371,11 +372,15 @@ GonkGPSGeolocationProvider::SetReferenceLocation()
icc->GetMcc(&location.u.cellID.mcc);
icc->GetMnc(&location.u.cellID.mnc);
}
nsCOMPtr<nsICellLocation> cell;
rilCtx->GetCell(getter_AddRefs(cell));
if (cell) {
cell->GetLac(&location.u.cellID.lac);
cell->GetCid(&location.u.cellID.cid);
nsCOMPtr<nsIDOMMozMobileConnectionInfo> voice;
rilCtx->GetVoice(getter_AddRefs(voice));
if (voice) {
nsCOMPtr<nsIDOMMozMobileCellInfo> cell;
voice->GetCell(getter_AddRefs(cell));
if (cell) {
cell->GetGsmLocationAreaCode(&location.u.cellID.lac);
cell->GetGsmCellId(&location.u.cellID.cid);
}
}
if (mAGpsRilInterface) {
mAGpsRilInterface->set_ref_location(&location, sizeof(location));

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

@ -33,6 +33,8 @@ const MOBILECONNECTIONINFO_CID =
Components.ID("{a35cfd39-2d93-4489-ac7d-396475dacb27}");
const MOBILENETWORKINFO_CID =
Components.ID("{a6c8416c-09b4-46d1-bf29-6520d677d085}");
const MOBILECELLINFO_CID =
Components.ID("{5e809018-68c0-4c54-af0b-2a9b8f748c45}");
const VOICEMAILSTATUS_CID=
Components.ID("{5467f2eb-e214-43ea-9b89-67711241ec8e}");
@ -89,6 +91,7 @@ MobileConnectionInfo.prototype = {
emergencyCallsOnly: false,
roaming: false,
network: null,
cell: null,
type: null,
signalStrength: null,
relSignalStrength: null
@ -114,6 +117,23 @@ MobileNetworkInfo.prototype = {
state: null
};
function MobileCellInfo() {}
MobileCellInfo.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozMobileCellInfo]),
classID: MOBILECELLINFO_CID,
classInfo: XPCOMUtils.generateCI({
classID: MOBILECELLINFO_CID,
classDescription: "MobileCellInfo",
flags: Ci.nsIClassInfo.DOM_OBJECT,
interfaces: [Ci.nsIDOMMozMobileCellInfo]
}),
// nsIDOMMozMobileCellInfo
gsmLocationAreaCode: null,
gsmCellId: null
};
function VoicemailStatus() {}
VoicemailStatus.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozVoicemailStatus]),
@ -168,11 +188,24 @@ RILContentHelper.prototype = {
updateConnectionInfo: function updateConnectionInfo(srcInfo, destInfo) {
for (let key in srcInfo) {
if (key != "network") {
if ((key != "network") && (key != "cell")) {
destInfo[key] = srcInfo[key];
}
}
let srcCell = srcInfo.cell;
if (!srcCell) {
destInfo.cell = null;
} else {
let cell = destInfo.cell;
if (!cell) {
cell = destInfo.cell = new MobileCellInfo();
}
cell.gsmLocationAreaCode = srcCell.gsmLocationAreaCode;
cell.gsmCellId = srcCell.gsmCellId;
}
let srcNetwork = srcInfo.network;
if (!srcNetwork) {
destInfo.network= null;

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

@ -151,14 +151,16 @@ function RadioInterfaceLayer() {
radioState: RIL.GECKO_RADIOSTATE_UNAVAILABLE,
cardState: RIL.GECKO_CARDSTATE_UNAVAILABLE,
icc: null,
cell: null,
// These objects implement the nsIDOMMozMobileConnectionInfo interface,
// although the actual implementation lives in the content process.
// although the actual implementation lives in the content process. So are
// the child attributes `network` and `cell`, which implement
// nsIDOMMozMobileNetworkInfo and nsIDOMMozMobileCellInfo respectively.
voice: {connected: false,
emergencyCallsOnly: false,
roaming: false,
network: null,
cell: null,
type: null,
signalStrength: null,
relSignalStrength: null},
@ -166,6 +168,7 @@ function RadioInterfaceLayer() {
emergencyCallsOnly: false,
roaming: false,
network: null,
cell: null,
type: null,
signalStrength: null,
relSignalStrength: null},
@ -420,9 +423,6 @@ RadioInterfaceLayer.prototype = {
case "iccmbdn":
ppmm.sendAsyncMessage("RIL:VoicemailNumberChanged", message);
break;
case "celllocationchanged":
this.rilContext.cell = message;
break;
case "ussdreceived":
debug("ussdreceived " + JSON.stringify(message));
this.handleUSSDReceived(message);
@ -506,6 +506,13 @@ RadioInterfaceLayer.prototype = {
voiceInfo.relSignalStrength = null;
}
let newCell = newInfo.cell;
if ((newCell.gsmLocationAreaCode < 0) || (newCell.gsmCellId < 0)) {
voiceInfo.cell = null;
} else {
voiceInfo.cell = newCell;
}
if (!newInfo.batch) {
ppmm.sendAsyncMessage("RIL:VoiceInfoChanged", voiceInfo);
}
@ -529,6 +536,13 @@ RadioInterfaceLayer.prototype = {
dataInfo.relSignalStrength = null;
}
let newCell = newInfo.cell;
if ((newCell.gsmLocationAreaCode < 0) || (newCell.gsmCellId < 0)) {
dataInfo.cell = null;
} else {
dataInfo.cell = newCell;
}
if (!newInfo.batch) {
ppmm.sendAsyncMessage("RIL:DataInfoChanged", dataInfo);
}

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

@ -217,21 +217,7 @@ interface nsIICCRecords : nsISupports
readonly attribute jsval fdn;
};
[scriptable, uuid(1b47459d-d0bc-4e91-8509-cc106054b9ee)]
interface nsICellLocation : nsISupports
{
/**
* Location Area Code
*/
readonly attribute unsigned short lac;
/**
* Cell Identity
*/
readonly attribute unsigned long cid;
};
[scriptable, uuid(a6f6977e-f4ee-42b4-ae79-798c8c47c360)]
[scriptable, uuid(e6dc89f2-0d4e-46fc-902c-cfeeaee15e40)]
interface nsIRilContext : nsISupports
{
readonly attribute DOMString radioState;
@ -240,8 +226,6 @@ interface nsIRilContext : nsISupports
readonly attribute nsIICCRecords icc;
readonly attribute nsICellLocation cell;
readonly attribute nsIDOMMozMobileConnectionInfo voice;
readonly attribute nsIDOMMozMobileConnectionInfo data;

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

@ -623,11 +623,6 @@ let RIL = {
voiceRegistrationState: {},
dataRegistrationState: {},
/**
* The cell location on a phone, such as LAC, CID.
*/
cellLocation: {},
/**
* List of strings identifying the network operator.
*/
@ -698,11 +693,13 @@ let RIL = {
*
* @param string
* String to be parsed.
* @param defaultValue
* @param defaultValue [optional]
* Default value to be used.
* @param radix [optional]
* A number that represents the numeral system to be used. Default 10.
*/
parseInt: function RIL_parseInt(string, defaultValue) {
let number = parseInt(string, 10);
parseInt: function RIL_parseInt(string, defaultValue, radix) {
let number = parseInt(string, radix || 10);
if (!isNaN(number)) {
return number;
}
@ -2186,6 +2183,24 @@ let RIL = {
}
}
if (!curState.cell) {
curState.cell = {};
}
// 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.
let lac = RIL.parseInt(newState[1], -1, 16);
if (curState.cell.gsmLocationAreaCode !== lac) {
curState.cell.gsmLocationAreaCode = lac;
changed = true;
}
let cid = RIL.parseInt(newState[2], -1, 16);
if (curState.cell.gsmCellId !== cid) {
curState.cell.gsmCellId = cid;
changed = true;
}
let radioTech = RIL.parseInt(newState[3], NETWORK_CREG_TECH_UNKNOWN);
if (curState.radioTech != radioTech) {
changed = true;
@ -2202,28 +2217,6 @@ let RIL = {
RIL.getSMSCAddress();
}
let cell = this.cellLocation;
let cellChanged = false;
// 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.
let lac = parseInt(state[1], 16);
if (cell.lac !== lac) {
cell.lac = lac;
cellChanged = true;
}
let cid = parseInt(state[2], 16);
if (cell.cid !== cid) {
cell.cid = cid;
cellChanged = true;
}
if (cellChanged) {
cell.rilMessageType = "celllocationchanged";
this.sendDOMMessage(cell);
}
// TODO: This zombie code branch that will be raised from the dead once
// we add explicit CDMA support everywhere (bug 726098).
let cdma = false;