From 008a8c5a4f8bfd552cb8e2addfaf6ba02ceaa364 Mon Sep 17 00:00:00 2001 From: Jessica Jong Date: Tue, 18 Aug 2015 09:54:36 +0800 Subject: [PATCH] Bug 1185406 - B2G RIL: Read 'pcscf' and expose it in nsIRilNetworkInfo. r=hsinyi --- dom/system/gonk/DataCallInterfaceService.js | 3 ++- dom/system/gonk/DataCallManager.js | 23 +++++++++++++++++-- dom/system/gonk/RadioInterfaceLayer.js | 3 ++- .../gonk/nsIDataCallInterfaceService.idl | 8 ++++++- dom/system/gonk/nsIDataCallManager.idl | 13 ++++++++++- dom/system/gonk/ril_worker.js | 17 ++++++++++---- 6 files changed, 56 insertions(+), 11 deletions(-) diff --git a/dom/system/gonk/DataCallInterfaceService.js b/dom/system/gonk/DataCallInterfaceService.js index abb98fe6741..abb5a06054c 100644 --- a/dom/system/gonk/DataCallInterfaceService.js +++ b/dom/system/gonk/DataCallInterfaceService.js @@ -71,7 +71,8 @@ DataCall.prototype = { ifname: null, addreses: null, dnses: null, - gateways: null + gateways: null, + pcscf: null }; function DataCallInterfaceService() { diff --git a/dom/system/gonk/DataCallManager.js b/dom/system/gonk/DataCallManager.js index b29ecfa1a85..704c9b6a3e6 100644 --- a/dom/system/gonk/DataCallManager.js +++ b/dom/system/gonk/DataCallManager.js @@ -960,7 +960,8 @@ function DataCall(aClientId, aApnSetting, aDataCallHandler) { ifname: null, addresses: [], dnses: [], - gateways: [] + gateways: [], + pcscf: [] }; this.state = NETWORK_STATE_UNKNOWN; this.requestedNetworkIfaces = []; @@ -1091,6 +1092,7 @@ DataCall.prototype = { this.linkInfo.addresses = aDataCall.addresses ? aDataCall.addresses.split(" ") : []; this.linkInfo.gateways = aDataCall.gateways ? aDataCall.gateways.split(" ") : []; this.linkInfo.dnses = aDataCall.dnses ? aDataCall.dnses.split(" ") : []; + this.linkInfo.pcscf = aDataCall.pcscf ? aDataCall.pcscf.split(" ") : []; this.state = this._getGeckoDataCallState(aDataCall); // Notify DataCallHandler about data call connected. @@ -1143,7 +1145,8 @@ DataCall.prototype = { ifname: aUpdatedDataCall.ifname, addresses: aUpdatedDataCall.addresses ? aUpdatedDataCall.addresses.split(" ") : [], dnses: aUpdatedDataCall.dnses ? aUpdatedDataCall.dnses.split(" ") : [], - gateways: aUpdatedDataCall.gateways ? aUpdatedDataCall.gateways.split(" ") : [] + gateways: aUpdatedDataCall.gateways ? aUpdatedDataCall.gateways.split(" ") : [], + pcscf: aUpdatedDataCall.pcscf ? aUpdatedDataCall.pcscf.split(" ") : [] }; switch (dataCallState) { @@ -1169,6 +1172,7 @@ DataCall.prototype = { this.linkInfo.addresses = newLinkInfo.addresses.slice(); this.linkInfo.gateways = newLinkInfo.gateways.slice(); this.linkInfo.dnses = newLinkInfo.dnses.slice(); + this.linkInfo.pcscf = newLinkInfo.pcscf.slice(); } break; case NETWORK_STATE_DISCONNECTED: @@ -1267,6 +1271,7 @@ DataCall.prototype = { this.linkInfo.addresses = []; this.linkInfo.dnses = []; this.linkInfo.gateways = []; + this.linkInfo.pcscf = []; }, reset: function() { @@ -1604,6 +1609,20 @@ RILNetworkInfo.prototype = { // See http://www.iana.org/assignments/port-numbers return this.getApnSetting().mmsport || -1; }, + + getPcscf: function(aCount) { + if (this.type != NETWORK_TYPE_MOBILE_IMS) { + if (DEBUG) this.debug("Error! Only IMS network can get pcscf."); + throw Cr.NS_ERROR_UNEXPECTED; + } + + let linkInfo = this.getDataCall().linkInfo; + + if (aCount) { + aCount.value = linkInfo.pcscf.length; + } + return linkInfo.pcscf.slice(); + }, }; function RILNetworkInterface(aDataCallHandler, aType, aApnSetting, aDataCall) { diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index d53a9a78b41..077f95623e9 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -392,7 +392,8 @@ DataCall.prototype = { ifname: null, addreses: null, dnses: null, - gateways: null + gateways: null, + pcscf: null }; function RadioInterfaceLayer() { diff --git a/dom/system/gonk/nsIDataCallInterfaceService.idl b/dom/system/gonk/nsIDataCallInterfaceService.idl index fedf55c0498..c4f733b8cb8 100644 --- a/dom/system/gonk/nsIDataCallInterfaceService.idl +++ b/dom/system/gonk/nsIDataCallInterfaceService.idl @@ -4,7 +4,7 @@ #include "nsISupports.idl" -[scriptable, uuid(d27ce247-9c7c-4582-826b-125e8275e9c2)] +[scriptable, uuid(88f18811-8f19-4902-a9b8-2a6430c71c94)] interface nsIDataCall : nsISupports { /** @@ -55,6 +55,12 @@ interface nsIDataCall : nsISupports * A space-delimited list of default gateway addresses. */ readonly attribute DOMString gateways; + + /** + * A space-delimited list of Proxy Call State Control Function addresses for + * IMS client. + */ + readonly attribute DOMString pcscf; }; [scriptable, uuid(e119c54b-9354-4ad6-a1ee-18608bde9320)] diff --git a/dom/system/gonk/nsIDataCallManager.idl b/dom/system/gonk/nsIDataCallManager.idl index 780887600de..de8477801bb 100644 --- a/dom/system/gonk/nsIDataCallManager.idl +++ b/dom/system/gonk/nsIDataCallManager.idl @@ -5,7 +5,7 @@ #include "nsISupports.idl" #include "nsINetworkInterface.idl" -[scriptable, uuid(501b7041-0754-4ddb-9174-946e2c2ebd83)] +[scriptable, uuid(b8bcd6aa-5b06-4362-a68c-317878429e51)] interface nsIRilNetworkInfo : nsINetworkInfo { readonly attribute unsigned long serviceId; @@ -15,6 +15,17 @@ interface nsIRilNetworkInfo : nsINetworkInfo readonly attribute DOMString mmsc; // Empty string if not set. readonly attribute DOMString mmsProxy; // Empty string if not set. readonly attribute long mmsPort; // -1 if not set. + + /** + * Get the list of pcscf addresses, could be IPv4 or IPv6. + * + * @param count + * The length of the list of pcscf addresses. + * + * @returns the list of pcscf addresses. + */ + void getPcscf([optional] out unsigned long count, + [array, size_is(count), retval] out wstring pcscf); }; [scriptable, function, uuid(cb2f0f5b-67f4-4c14-93e8-01e66b630464)] diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index 46f3aa73104..3c6ac273ae1 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -4236,12 +4236,11 @@ RilObject.prototype[REQUEST_SETUP_DATA_CALL] = function REQUEST_SETUP_DATA_CALL( } let Buf = this.context.Buf; - // Skip version of data call. - Buf.readInt32(); + let version = Buf.readInt32(); // Skip number of data calls. Buf.readInt32(); - this.readDataCall_v6(options); + this.readDataCall(options, version); this.sendChromeMessage(options); }; RilObject.prototype[REQUEST_SIM_IO] = function REQUEST_SIM_IO(length, options) { @@ -4512,9 +4511,13 @@ RilObject.prototype[REQUEST_LAST_DATA_CALL_FAIL_CAUSE] = null; * length. * # dnses - A space-delimited list of DNS server addresses. * # gateways - A space-delimited list of default gateway addresses. + * + * V10: + * # pcscf - A space-delimited list of Proxy Call State Control Function + * addresses. */ -RilObject.prototype.readDataCall_v6 = function(options) { +RilObject.prototype.readDataCall = function(options, version) { if (!options) { options = {}; } @@ -4529,6 +4532,10 @@ RilObject.prototype.readDataCall_v6 = function(options) { options.dnses = Buf.readString(); options.gateways = Buf.readString(); + if (version >= 10) { + options.pcscf = Buf.readString(); + } + return options; }; @@ -4557,7 +4564,7 @@ RilObject.prototype[REQUEST_DATA_CALL_LIST] = function REQUEST_DATA_CALL_LIST(le let datacalls = []; for (let i = 0; i < num; i++) { let datacall; - datacall = this.readDataCall_v6(); + datacall = this.readDataCall({}, version); datacalls.push(datacall); }