2012-07-20 13:10:44 +04:00
|
|
|
/* Copyright 2012 Mozilla Foundation and Mozilla contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2012-04-20 01:33:25 +04:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
|
|
|
|
2012-04-12 08:01:49 +04:00
|
|
|
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
2013-03-06 06:51:40 +04:00
|
|
|
Cu.import("resource://gre/modules/ObjectWrapper.jsm");
|
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
2012-04-20 01:33:25 +04:00
|
|
|
|
|
|
|
var RIL = {};
|
|
|
|
Cu.import("resource://gre/modules/ril_consts.js", RIL);
|
|
|
|
|
2012-06-20 02:52:06 +04:00
|
|
|
// set to true to in ril_consts.js to see debug messages
|
2012-11-14 14:25:35 +04:00
|
|
|
var DEBUG = RIL.DEBUG_CONTENT_HELPER;
|
|
|
|
|
|
|
|
// Read debug setting from pref
|
|
|
|
try {
|
|
|
|
let debugPref = Services.prefs.getBoolPref("ril.debugging.enabled");
|
|
|
|
DEBUG = RIL.DEBUG_CONTENT_HELPER || debugPref;
|
2013-06-10 06:41:14 +04:00
|
|
|
} catch (e) {}
|
|
|
|
|
|
|
|
let debug;
|
|
|
|
if (DEBUG) {
|
|
|
|
debug = function (s) {
|
|
|
|
dump("-*- RILContentHelper: " + s + "\n");
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
debug = function (s) {};
|
|
|
|
}
|
2012-04-20 01:33:25 +04:00
|
|
|
|
|
|
|
const RILCONTENTHELPER_CID =
|
|
|
|
Components.ID("{472816e1-1fd6-4405-996c-806f9ea68174}");
|
2013-05-30 15:14:39 +04:00
|
|
|
const ICCINFO_CID =
|
|
|
|
Components.ID("{fab2c0f0-d73a-11e2-8b8b-0800200c9a66}");
|
2012-04-20 01:33:25 +04:00
|
|
|
const MOBILECONNECTIONINFO_CID =
|
|
|
|
Components.ID("{a35cfd39-2d93-4489-ac7d-396475dacb27}");
|
2012-06-13 01:05:50 +04:00
|
|
|
const MOBILENETWORKINFO_CID =
|
2012-06-02 01:10:39 +04:00
|
|
|
Components.ID("{a6c8416c-09b4-46d1-bf29-6520d677d085}");
|
2012-08-16 05:36:56 +04:00
|
|
|
const MOBILECELLINFO_CID =
|
|
|
|
Components.ID("{5e809018-68c0-4c54-af0b-2a9b8f748c45}");
|
2012-07-19 07:27:08 +04:00
|
|
|
const VOICEMAILSTATUS_CID=
|
|
|
|
Components.ID("{5467f2eb-e214-43ea-9b89-67711241ec8e}");
|
2012-10-31 17:58:39 +04:00
|
|
|
const MOBILECFINFO_CID=
|
|
|
|
Components.ID("{a4756f16-e728-4d9f-8baa-8464f894888a}");
|
2012-12-04 06:40:47 +04:00
|
|
|
const CELLBROADCASTMESSAGE_CID =
|
|
|
|
Components.ID("{29474c96-3099-486f-bb4a-3c9a1da834e4}");
|
|
|
|
const CELLBROADCASTETWSINFO_CID =
|
|
|
|
Components.ID("{59f176ee-9dcd-4005-9d47-f6be0cd08e17}");
|
2013-06-30 16:21:32 +04:00
|
|
|
const DOMMMIERROR_CID =
|
|
|
|
Components.ID("{6b204c42-7928-4e71-89ad-f90cd82aff96}");
|
2012-04-20 01:33:25 +04:00
|
|
|
|
|
|
|
const RIL_IPC_MSG_NAMES = [
|
|
|
|
"RIL:CardStateChanged",
|
2012-09-04 01:43:59 +04:00
|
|
|
"RIL:IccInfoChanged",
|
2012-04-20 01:33:25 +04:00
|
|
|
"RIL:VoiceInfoChanged",
|
|
|
|
"RIL:DataInfoChanged",
|
2012-04-24 19:44:42 +04:00
|
|
|
"RIL:EnumerateCalls",
|
2012-06-02 01:10:39 +04:00
|
|
|
"RIL:GetAvailableNetworks",
|
2012-06-20 02:52:06 +04:00
|
|
|
"RIL:NetworkSelectionModeChanged",
|
|
|
|
"RIL:SelectNetwork",
|
|
|
|
"RIL:SelectNetworkAuto",
|
2012-04-24 19:44:42 +04:00
|
|
|
"RIL:CallStateChanged",
|
2012-07-19 07:27:08 +04:00
|
|
|
"RIL:VoicemailNotification",
|
2012-11-23 08:09:01 +04:00
|
|
|
"RIL:VoicemailInfoChanged",
|
2012-05-15 08:13:06 +04:00
|
|
|
"RIL:CallError",
|
2012-08-15 20:49:12 +04:00
|
|
|
"RIL:CardLockResult",
|
Bug 875710: Added getCardLockRetryCount to nsIIccProvider, r=vyang, sr=mounir
This patch adds getCardLockRetryCount to nsIIccProvider and its
implementations. This method allows callers to query the number
of remaining tries for unlocking a SIM-card lock. Supported locks
are 'pin', 'puk', 'pin2', 'puk2', 'nck', 'cck', and 'spck'. The
call returns a DOM request that returns the retry count in its
success handler, or signals an appropriate error.
Reading the retry count is an optional feature and may not be
supported for all lock types. In this case the DOM request receives
and error with the name GECKO_ERROR_NOT_SUPPORTED. For an invalid
lock type, the error name is GECKO_ERROR_GENERIC_FAILURE.
getCardLockRetryCount replaces retryCount in nsIDOMMobileConnection,
which is now deprecated.
--HG--
extra : rebase_source : d1d11612f836652dca85f7c701f09e7af962e3b7
2013-07-09 18:06:05 +04:00
|
|
|
"RIL:CardLockRetryCount",
|
2012-10-05 18:08:55 +04:00
|
|
|
"RIL:USSDReceived",
|
|
|
|
"RIL:SendMMI:Return:OK",
|
|
|
|
"RIL:SendMMI:Return:KO",
|
|
|
|
"RIL:CancelMMI:Return:OK",
|
|
|
|
"RIL:CancelMMI:Return:KO",
|
2012-04-10 16:04:27 +04:00
|
|
|
"RIL:StkCommand",
|
2012-09-25 23:22:38 +04:00
|
|
|
"RIL:StkSessionEnd",
|
2012-10-31 17:58:39 +04:00
|
|
|
"RIL:DataError",
|
|
|
|
"RIL:SetCallForwardingOption",
|
2012-12-04 06:40:47 +04:00
|
|
|
"RIL:GetCallForwardingOption",
|
2013-05-21 09:13:37 +04:00
|
|
|
"RIL:SetCallBarringOption",
|
|
|
|
"RIL:GetCallBarringOption",
|
2013-04-18 16:18:50 +04:00
|
|
|
"RIL:SetCallWaitingOption",
|
|
|
|
"RIL:GetCallWaitingOption",
|
2013-07-18 01:18:29 +04:00
|
|
|
"RIL:SetCallingLineIdRestriction",
|
|
|
|
"RIL:GetCallingLineIdRestriction",
|
2013-01-25 22:45:23 +04:00
|
|
|
"RIL:CellBroadcastReceived",
|
2013-02-25 13:27:26 +04:00
|
|
|
"RIL:CfStateChanged",
|
|
|
|
"RIL:IccOpenChannel",
|
|
|
|
"RIL:IccCloseChannel",
|
2013-03-06 06:12:23 +04:00
|
|
|
"RIL:IccExchangeAPDU",
|
2013-03-06 06:51:40 +04:00
|
|
|
"RIL:ReadIccContacts",
|
2013-03-25 07:09:01 +04:00
|
|
|
"RIL:UpdateIccContact"
|
2012-04-20 01:33:25 +04:00
|
|
|
];
|
|
|
|
|
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
|
|
|
"@mozilla.org/childprocessmessagemanager;1",
|
2012-08-27 18:13:02 +04:00
|
|
|
"nsISyncMessageSender");
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2012-08-17 07:46:34 +04:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gUUIDGenerator",
|
|
|
|
"@mozilla.org/uuid-generator;1",
|
|
|
|
"nsIUUIDGenerator");
|
|
|
|
|
2013-04-11 11:12:09 +04:00
|
|
|
function MobileIccCardLockResult(options) {
|
2012-09-10 07:54:49 +04:00
|
|
|
this.lockType = options.lockType;
|
|
|
|
this.enabled = options.enabled;
|
|
|
|
this.retryCount = options.retryCount;
|
|
|
|
this.success = options.success;
|
2013-06-10 06:41:14 +04:00
|
|
|
}
|
2013-04-11 11:12:09 +04:00
|
|
|
MobileIccCardLockResult.prototype = {
|
2012-09-10 07:54:49 +04:00
|
|
|
__exposedProps__ : {lockType: 'r',
|
|
|
|
enabled: 'r',
|
|
|
|
retryCount: 'r',
|
|
|
|
success: 'r'}
|
|
|
|
};
|
|
|
|
|
Bug 875710: Added getCardLockRetryCount to nsIIccProvider, r=vyang, sr=mounir
This patch adds getCardLockRetryCount to nsIIccProvider and its
implementations. This method allows callers to query the number
of remaining tries for unlocking a SIM-card lock. Supported locks
are 'pin', 'puk', 'pin2', 'puk2', 'nck', 'cck', and 'spck'. The
call returns a DOM request that returns the retry count in its
success handler, or signals an appropriate error.
Reading the retry count is an optional feature and may not be
supported for all lock types. In this case the DOM request receives
and error with the name GECKO_ERROR_NOT_SUPPORTED. For an invalid
lock type, the error name is GECKO_ERROR_GENERIC_FAILURE.
getCardLockRetryCount replaces retryCount in nsIDOMMobileConnection,
which is now deprecated.
--HG--
extra : rebase_source : d1d11612f836652dca85f7c701f09e7af962e3b7
2013-07-09 18:06:05 +04:00
|
|
|
function MobileIccCardLockRetryCount(options) {
|
|
|
|
this.lockType = options.lockType;
|
|
|
|
this.retryCount = options.retryCount;
|
|
|
|
this.success = options.success;
|
|
|
|
}
|
|
|
|
MobileIccCardLockRetryCount.prototype = {
|
|
|
|
__exposedProps__ : {lockType: 'r',
|
|
|
|
retryCount: 'r',
|
|
|
|
success: 'r'}
|
|
|
|
};
|
|
|
|
|
2013-05-30 15:14:39 +04:00
|
|
|
function IccInfo() {}
|
|
|
|
IccInfo.prototype = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozIccInfo]),
|
|
|
|
classID: ICCINFO_CID,
|
2012-09-04 01:43:59 +04:00
|
|
|
classInfo: XPCOMUtils.generateCI({
|
2013-05-30 15:14:39 +04:00
|
|
|
classID: ICCINFO_CID,
|
|
|
|
classDescription: "IccInfo",
|
2012-09-04 01:43:59 +04:00
|
|
|
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
2013-05-30 15:14:39 +04:00
|
|
|
interfaces: [Ci.nsIDOMMozIccInfo]
|
2012-09-04 01:43:59 +04:00
|
|
|
}),
|
|
|
|
|
2013-05-30 15:14:39 +04:00
|
|
|
// nsIDOMMozIccInfo
|
2012-09-04 01:43:59 +04:00
|
|
|
|
2012-09-14 14:30:44 +04:00
|
|
|
iccid: null,
|
2013-02-25 07:47:27 +04:00
|
|
|
mcc: null,
|
|
|
|
mnc: null,
|
2012-10-23 10:54:51 +04:00
|
|
|
spn: null,
|
2012-11-23 08:09:01 +04:00
|
|
|
msisdn: null
|
|
|
|
};
|
|
|
|
|
2012-12-26 14:49:08 +04:00
|
|
|
function VoicemailInfo() {}
|
|
|
|
VoicemailInfo.prototype = {
|
2012-11-23 08:09:01 +04:00
|
|
|
number: null,
|
|
|
|
displayName: null
|
2012-09-04 01:43:59 +04:00
|
|
|
};
|
|
|
|
|
2012-04-20 01:33:25 +04:00
|
|
|
function MobileConnectionInfo() {}
|
|
|
|
MobileConnectionInfo.prototype = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozMobileConnectionInfo]),
|
|
|
|
classID: MOBILECONNECTIONINFO_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({
|
|
|
|
classID: MOBILECONNECTIONINFO_CID,
|
|
|
|
classDescription: "MobileConnectionInfo",
|
|
|
|
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
|
|
|
interfaces: [Ci.nsIDOMMozMobileConnectionInfo]
|
|
|
|
}),
|
|
|
|
|
|
|
|
// nsIDOMMozMobileConnectionInfo
|
|
|
|
|
|
|
|
connected: false,
|
2012-08-07 23:11:48 +04:00
|
|
|
state: null,
|
2012-04-20 01:33:25 +04:00
|
|
|
emergencyCallsOnly: false,
|
|
|
|
roaming: false,
|
2012-06-13 01:05:50 +04:00
|
|
|
network: null,
|
2012-08-16 05:36:56 +04:00
|
|
|
cell: null,
|
2012-04-20 01:33:25 +04:00
|
|
|
type: null,
|
|
|
|
signalStrength: null,
|
|
|
|
relSignalStrength: null
|
|
|
|
};
|
|
|
|
|
2012-06-13 01:05:50 +04:00
|
|
|
function MobileNetworkInfo() {}
|
|
|
|
MobileNetworkInfo.prototype = {
|
2012-09-10 07:54:49 +04:00
|
|
|
__exposedProps__ : {shortName: 'r',
|
|
|
|
longName: 'r',
|
|
|
|
mcc: 'r',
|
|
|
|
mnc: 'r',
|
|
|
|
state: 'r'},
|
|
|
|
|
2012-06-13 01:05:50 +04:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozMobileNetworkInfo]),
|
|
|
|
classID: MOBILENETWORKINFO_CID,
|
2012-06-02 01:10:39 +04:00
|
|
|
classInfo: XPCOMUtils.generateCI({
|
2012-06-13 01:05:50 +04:00
|
|
|
classID: MOBILENETWORKINFO_CID,
|
|
|
|
classDescription: "MobileNetworkInfo",
|
2012-06-02 01:10:39 +04:00
|
|
|
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
2012-06-13 01:05:50 +04:00
|
|
|
interfaces: [Ci.nsIDOMMozMobileNetworkInfo]
|
2012-06-02 01:10:39 +04:00
|
|
|
}),
|
|
|
|
|
2012-06-13 01:05:50 +04:00
|
|
|
// nsIDOMMozMobileNetworkInfo
|
2012-06-02 01:10:39 +04:00
|
|
|
|
|
|
|
shortName: null,
|
|
|
|
longName: null,
|
2013-02-25 07:47:27 +04:00
|
|
|
mcc: null,
|
|
|
|
mnc: null,
|
2012-06-02 01:10:39 +04:00
|
|
|
state: null
|
|
|
|
};
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2012-08-16 05:36:56 +04:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2012-07-19 07:27:08 +04:00
|
|
|
function VoicemailStatus() {}
|
|
|
|
VoicemailStatus.prototype = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozVoicemailStatus]),
|
|
|
|
classID: VOICEMAILSTATUS_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({
|
|
|
|
classID: VOICEMAILSTATUS_CID,
|
|
|
|
classDescription: "VoicemailStatus",
|
|
|
|
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
|
|
|
interfaces: [Ci.nsIDOMMozVoicemailStatus]
|
|
|
|
}),
|
|
|
|
|
|
|
|
// nsIDOMMozVoicemailStatus
|
|
|
|
|
|
|
|
hasMessages: false,
|
|
|
|
messageCount: Ci.nsIDOMMozVoicemailStatus.MESSAGE_COUNT_UNKNOWN,
|
|
|
|
returnNumber: null,
|
|
|
|
returnMessage: null
|
|
|
|
};
|
|
|
|
|
2012-10-31 17:58:39 +04:00
|
|
|
function MobileCFInfo() {}
|
|
|
|
MobileCFInfo.prototype = {
|
|
|
|
__exposedProps__ : {active: 'r',
|
|
|
|
action: 'r',
|
|
|
|
reason: 'r',
|
|
|
|
number: 'r',
|
2012-12-03 13:30:59 +04:00
|
|
|
timeSeconds: 'r',
|
|
|
|
serviceClass: 'r'},
|
2012-10-31 17:58:39 +04:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozMobileCFInfo]),
|
|
|
|
classID: MOBILECFINFO_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({
|
|
|
|
classID: MOBILECFINFO_CID,
|
|
|
|
classDescription: "MobileCFInfo",
|
|
|
|
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
|
|
|
interfaces: [Ci.nsIDOMMozMobileCFInfo]
|
|
|
|
}),
|
|
|
|
|
|
|
|
// nsIDOMMozMobileCFInfo
|
|
|
|
|
|
|
|
active: false,
|
|
|
|
action: -1,
|
|
|
|
reason: -1,
|
|
|
|
number: null,
|
2012-12-03 13:30:59 +04:00
|
|
|
timeSeconds: 0,
|
|
|
|
serviceClass: -1
|
2012-10-31 17:58:39 +04:00
|
|
|
};
|
|
|
|
|
2012-12-04 06:40:47 +04:00
|
|
|
function CellBroadcastMessage(pdu) {
|
|
|
|
this.geographicalScope = RIL.CB_GSM_GEOGRAPHICAL_SCOPE_NAMES[pdu.geographicalScope];
|
|
|
|
this.messageCode = pdu.messageCode;
|
|
|
|
this.messageId = pdu.messageId;
|
|
|
|
this.language = pdu.language;
|
|
|
|
this.body = pdu.fullBody;
|
|
|
|
this.messageClass = pdu.messageClass;
|
|
|
|
this.timestamp = new Date(pdu.timestamp);
|
|
|
|
|
|
|
|
if (pdu.etws != null) {
|
|
|
|
this.etws = new CellBroadcastEtwsInfo(pdu.etws);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CellBroadcastMessage.prototype = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozCellBroadcastMessage]),
|
|
|
|
classID: CELLBROADCASTMESSAGE_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({
|
|
|
|
classID: CELLBROADCASTMESSAGE_CID,
|
|
|
|
classDescription: "CellBroadcastMessage",
|
|
|
|
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
|
|
|
interfaces: [Ci.nsIDOMMozCellBroadcastMessage]
|
|
|
|
}),
|
|
|
|
|
|
|
|
// nsIDOMMozCellBroadcastMessage
|
|
|
|
|
|
|
|
geographicalScope: null,
|
|
|
|
messageCode: null,
|
|
|
|
messageId: null,
|
|
|
|
language: null,
|
|
|
|
body: null,
|
|
|
|
messageClass: null,
|
|
|
|
timestamp: null,
|
|
|
|
|
|
|
|
etws: null
|
|
|
|
};
|
|
|
|
|
|
|
|
function CellBroadcastEtwsInfo(etwsInfo) {
|
|
|
|
if (etwsInfo.warningType != null) {
|
|
|
|
this.warningType = RIL.CB_ETWS_WARNING_TYPE_NAMES[etwsInfo.warningType];
|
|
|
|
}
|
|
|
|
this.emergencyUserAlert = etwsInfo.emergencyUserAlert;
|
|
|
|
this.popup = etwsInfo.popup;
|
|
|
|
}
|
|
|
|
CellBroadcastEtwsInfo.prototype = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozCellBroadcastEtwsInfo]),
|
|
|
|
classID: CELLBROADCASTETWSINFO_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({
|
|
|
|
classID: CELLBROADCASTETWSINFO_CID,
|
|
|
|
classDescription: "CellBroadcastEtwsInfo",
|
|
|
|
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
|
|
|
interfaces: [Ci.nsIDOMMozCellBroadcastEtwsInfo]
|
|
|
|
}),
|
|
|
|
|
|
|
|
// nsIDOMMozCellBroadcastEtwsInfo
|
|
|
|
|
|
|
|
warningType: null,
|
|
|
|
emergencyUserAlert: null,
|
|
|
|
popup: null
|
|
|
|
};
|
|
|
|
|
2013-05-21 09:13:37 +04:00
|
|
|
function CallBarringOption(option) {
|
|
|
|
this.program = option.program;
|
|
|
|
this.enabled = option.enabled;
|
|
|
|
this.password = option.password;
|
|
|
|
this.serviceClass = option.serviceClass;
|
|
|
|
}
|
|
|
|
CallBarringOption.prototype = {
|
|
|
|
__exposedProps__ : {program: 'r',
|
|
|
|
enabled: 'r',
|
|
|
|
password: 'r',
|
|
|
|
serviceClass: 'r'}
|
|
|
|
};
|
|
|
|
|
2013-06-30 16:21:32 +04:00
|
|
|
function DOMMMIResult(result) {
|
|
|
|
this.serviceCode = result.serviceCode;
|
|
|
|
this.statusMessage = result.statusMessage;
|
|
|
|
this.additionalInformation = result.additionalInformation;
|
|
|
|
};
|
|
|
|
DOMMMIResult.prototype = {
|
|
|
|
__exposedProps__: {serviceCode: 'r',
|
|
|
|
statusMessage: 'r',
|
|
|
|
additionalInformation: 'r'}
|
|
|
|
};
|
|
|
|
|
2013-07-18 01:18:29 +04:00
|
|
|
function DOMCLIRStatus(option) {
|
|
|
|
this.n = option.n;
|
|
|
|
this.m = option.m;
|
|
|
|
};
|
|
|
|
DOMCLIRStatus.prototype = {
|
|
|
|
__exposedProps__ : {n: 'r',
|
|
|
|
m: 'r'}
|
|
|
|
};
|
|
|
|
|
2013-06-30 16:21:32 +04:00
|
|
|
function DOMMMIError() {
|
|
|
|
};
|
|
|
|
DOMMMIError.prototype = {
|
|
|
|
classDescription: "DOMMMIError",
|
|
|
|
classID: DOMMMIERROR_CID,
|
|
|
|
contractID: "@mozilla.org/dom/mmi-error;1",
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]),
|
|
|
|
__init: function(serviceCode,
|
|
|
|
name,
|
|
|
|
message,
|
|
|
|
additionalInformation) {
|
|
|
|
this.__DOM_IMPL__.init(name, message);
|
|
|
|
this.serviceCode = serviceCode;
|
|
|
|
this.additionalInformation = additionalInformation;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-04-20 01:33:25 +04:00
|
|
|
function RILContentHelper() {
|
2013-01-08 11:57:34 +04:00
|
|
|
this.rilContext = {
|
2013-02-01 17:17:48 +04:00
|
|
|
cardState: RIL.GECKO_CARDSTATE_UNKNOWN,
|
2013-03-29 06:56:07 +04:00
|
|
|
networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN,
|
2013-05-30 15:14:39 +04:00
|
|
|
iccInfo: new IccInfo(),
|
2013-01-08 11:57:34 +04:00
|
|
|
voiceConnectionInfo: new MobileConnectionInfo(),
|
|
|
|
dataConnectionInfo: new MobileConnectionInfo()
|
|
|
|
};
|
2012-12-26 14:49:08 +04:00
|
|
|
this.voicemailInfo = new VoicemailInfo();
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2013-07-09 01:55:42 +04:00
|
|
|
this.initDOMRequestHelper(/* aWindow */ null, RIL_IPC_MSG_NAMES);
|
2013-06-10 06:41:14 +04:00
|
|
|
this._windowsMap = [];
|
2012-04-20 01:33:25 +04:00
|
|
|
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
|
|
|
}
|
2012-06-13 01:05:50 +04:00
|
|
|
|
2012-04-20 01:33:25 +04:00
|
|
|
RILContentHelper.prototype = {
|
2012-04-12 08:01:49 +04:00
|
|
|
__proto__: DOMRequestIpcHelper.prototype,
|
|
|
|
|
2012-04-20 01:33:25 +04:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionProvider,
|
2013-03-06 13:53:31 +04:00
|
|
|
Ci.nsICellBroadcastProvider,
|
|
|
|
Ci.nsIVoicemailProvider,
|
|
|
|
Ci.nsITelephonyProvider,
|
|
|
|
Ci.nsIIccProvider,
|
2013-07-09 01:55:42 +04:00
|
|
|
Ci.nsIObserver,
|
|
|
|
Ci.nsISupportsWeakReference]),
|
2012-04-20 01:33:25 +04:00
|
|
|
classID: RILCONTENTHELPER_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({classID: RILCONTENTHELPER_CID,
|
|
|
|
classDescription: "RILContentHelper",
|
|
|
|
interfaces: [Ci.nsIMobileConnectionProvider,
|
2013-03-06 13:53:31 +04:00
|
|
|
Ci.nsICellBroadcastProvider,
|
|
|
|
Ci.nsIVoicemailProvider,
|
|
|
|
Ci.nsITelephonyProvider,
|
|
|
|
Ci.nsIIccProvider]}),
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2013-01-28 07:41:34 +04:00
|
|
|
// An utility function to copy objects.
|
|
|
|
updateInfo: function updateInfo(srcInfo, destInfo) {
|
2012-11-23 08:09:01 +04:00
|
|
|
for (let key in srcInfo) {
|
|
|
|
destInfo[key] = srcInfo[key];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-06-13 01:05:50 +04:00
|
|
|
updateConnectionInfo: function updateConnectionInfo(srcInfo, destInfo) {
|
|
|
|
for (let key in srcInfo) {
|
2012-08-16 05:36:56 +04:00
|
|
|
if ((key != "network") && (key != "cell")) {
|
2012-06-13 01:05:50 +04:00
|
|
|
destInfo[key] = srcInfo[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-16 05:36:56 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-06-13 01:05:50 +04:00
|
|
|
let srcNetwork = srcInfo.network;
|
|
|
|
if (!srcNetwork) {
|
|
|
|
destInfo.network= null;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let network = destInfo.network;
|
|
|
|
if (!network) {
|
|
|
|
network = destInfo.network = new MobileNetworkInfo();
|
|
|
|
}
|
|
|
|
|
2013-01-28 07:41:34 +04:00
|
|
|
this.updateInfo(srcNetwork, network);
|
|
|
|
},
|
2012-06-13 01:05:50 +04:00
|
|
|
|
2013-03-06 06:51:40 +04:00
|
|
|
_windowsMap: null,
|
|
|
|
|
2013-01-08 11:57:34 +04:00
|
|
|
rilContext: null,
|
|
|
|
|
|
|
|
getRilContext: function getRilContext() {
|
|
|
|
// Update ril context by sending IPC message to chrome only when the first
|
|
|
|
// time we require it. The information will be updated by following info
|
|
|
|
// changed messages.
|
|
|
|
this.getRilContext = function getRilContext() {
|
|
|
|
return this.rilContext;
|
|
|
|
};
|
|
|
|
|
2013-07-02 13:36:40 +04:00
|
|
|
let rilContext =
|
|
|
|
cpmm.sendSyncMessage("RIL:GetRilContext", {clientId: 0})[0];
|
2013-01-08 11:57:34 +04:00
|
|
|
if (!rilContext) {
|
|
|
|
debug("Received null rilContext from chrome process.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.rilContext.cardState = rilContext.cardState;
|
2013-03-29 06:56:07 +04:00
|
|
|
this.rilContext.networkSelectionMode = rilContext.networkSelectionMode;
|
2013-01-24 07:11:16 +04:00
|
|
|
this.updateInfo(rilContext.iccInfo, this.rilContext.iccInfo);
|
2013-01-08 11:57:34 +04:00
|
|
|
this.updateConnectionInfo(rilContext.voice, this.rilContext.voiceConnectionInfo);
|
|
|
|
this.updateConnectionInfo(rilContext.data, this.rilContext.dataConnectionInfo);
|
|
|
|
|
|
|
|
return this.rilContext;
|
|
|
|
},
|
|
|
|
|
2013-07-02 13:36:40 +04:00
|
|
|
/**
|
|
|
|
* nsIMobileConnectionProvider
|
|
|
|
*/
|
|
|
|
|
2013-01-08 11:57:34 +04:00
|
|
|
get iccInfo() {
|
2013-05-13 06:18:19 +04:00
|
|
|
let context = this.getRilContext();
|
|
|
|
return context && context.iccInfo;
|
2013-01-08 11:57:34 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
get voiceConnectionInfo() {
|
2013-05-13 06:18:19 +04:00
|
|
|
let context = this.getRilContext();
|
|
|
|
return context && context.voiceConnectionInfo;
|
2013-01-08 11:57:34 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
get dataConnectionInfo() {
|
2013-05-13 06:18:19 +04:00
|
|
|
let context = this.getRilContext();
|
|
|
|
return context && context.dataConnectionInfo;
|
2013-01-08 11:57:34 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
get cardState() {
|
2013-05-13 06:18:19 +04:00
|
|
|
let context = this.getRilContext();
|
|
|
|
return context && context.cardState;
|
2013-01-08 11:57:34 +04:00
|
|
|
},
|
|
|
|
|
2013-03-29 06:56:07 +04:00
|
|
|
get networkSelectionMode() {
|
2013-05-13 06:18:19 +04:00
|
|
|
let context = this.getRilContext();
|
|
|
|
return context && context.networkSelectionMode;
|
2013-03-29 06:56:07 +04:00
|
|
|
},
|
|
|
|
|
2012-06-20 02:52:06 +04:00
|
|
|
/**
|
|
|
|
* The network that is currently trying to be selected (or "automatic").
|
|
|
|
* This helps ensure that only one network is selected at a time.
|
|
|
|
*/
|
|
|
|
_selectingNetwork: null,
|
2012-04-20 01:33:25 +04:00
|
|
|
|
|
|
|
getNetworks: function getNetworks(window) {
|
2012-06-02 01:10:39 +04:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:GetAvailableNetworks", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
2012-06-02 01:10:39 +04:00
|
|
|
return request;
|
2012-04-20 01:33:25 +04:00
|
|
|
},
|
|
|
|
|
2012-06-20 02:52:06 +04:00
|
|
|
selectNetwork: function selectNetwork(window, network) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._selectingNetwork) {
|
|
|
|
throw new Error("Already selecting a network: " + this._selectingNetwork);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!network) {
|
|
|
|
throw new Error("Invalid network provided: " + network);
|
|
|
|
}
|
|
|
|
|
2013-02-25 07:47:27 +04:00
|
|
|
if (isNaN(parseInt(network.mnc, 10))) {
|
|
|
|
throw new Error("Invalid network MNC: " + network.mnc);
|
2012-06-20 02:52:06 +04:00
|
|
|
}
|
|
|
|
|
2013-02-25 07:47:27 +04:00
|
|
|
if (isNaN(parseInt(network.mcc, 10))) {
|
|
|
|
throw new Error("Invalid network MCC: " + network.mcc);
|
2012-06-20 02:52:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
2013-04-01 10:26:45 +04:00
|
|
|
if (this.rilContext.networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_MANUAL &&
|
|
|
|
this.rilContext.voiceConnectionInfo.network === network) {
|
2012-06-20 02:52:06 +04:00
|
|
|
|
|
|
|
// Already manually selected this network, so schedule
|
|
|
|
// onsuccess to be fired on the next tick
|
|
|
|
this.dispatchFireRequestSuccess(requestId, null);
|
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._selectingNetwork = network;
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:SelectNetwork", {
|
2013-07-02 13:36:40 +04:00
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
mnc: network.mnc,
|
|
|
|
mcc: network.mcc
|
|
|
|
}
|
2012-06-20 02:52:06 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
|
|
|
selectNetworkAutomatically: function selectNetworkAutomatically(window) {
|
|
|
|
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._selectingNetwork) {
|
|
|
|
throw new Error("Already selecting a network: " + this._selectingNetwork);
|
|
|
|
}
|
|
|
|
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
2013-04-01 10:26:45 +04:00
|
|
|
if (this.rilContext.networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_AUTOMATIC) {
|
2012-06-20 02:52:06 +04:00
|
|
|
// Already using automatic selection mode, so schedule
|
|
|
|
// onsuccess to be be fired on the next tick
|
|
|
|
this.dispatchFireRequestSuccess(requestId, null);
|
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._selectingNetwork = "automatic";
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:SelectNetworkAuto", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
2012-06-20 02:52:06 +04:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-04-11 11:12:09 +04:00
|
|
|
getCardLockState: function getCardLockState(window, lockType) {
|
2012-04-12 08:01:49 +04:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:GetCardLockState", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
lockType: lockType,
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
2012-04-12 08:01:49 +04:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
|
|
|
unlockCardLock: function unlockCardLock(window, info) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
info.requestId = this.getRequestId(request);
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:UnlockCardLock", {
|
|
|
|
clientId: 0,
|
|
|
|
data: info
|
|
|
|
});
|
2012-04-12 08:01:49 +04:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
|
|
|
setCardLock: function setCardLock(window, info) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
info.requestId = this.getRequestId(request);
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:SetCardLock", {
|
|
|
|
clientId: 0,
|
|
|
|
data: info
|
|
|
|
});
|
2012-04-12 08:01:49 +04:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
Bug 875710: Added getCardLockRetryCount to nsIIccProvider, r=vyang, sr=mounir
This patch adds getCardLockRetryCount to nsIIccProvider and its
implementations. This method allows callers to query the number
of remaining tries for unlocking a SIM-card lock. Supported locks
are 'pin', 'puk', 'pin2', 'puk2', 'nck', 'cck', and 'spck'. The
call returns a DOM request that returns the retry count in its
success handler, or signals an appropriate error.
Reading the retry count is an optional feature and may not be
supported for all lock types. In this case the DOM request receives
and error with the name GECKO_ERROR_NOT_SUPPORTED. For an invalid
lock type, the error name is GECKO_ERROR_GENERIC_FAILURE.
getCardLockRetryCount replaces retryCount in nsIDOMMobileConnection,
which is now deprecated.
--HG--
extra : rebase_source : d1d11612f836652dca85f7c701f09e7af962e3b7
2013-07-09 18:06:05 +04:00
|
|
|
getCardLockRetryCount: function getCardLockRetryCount(window, lockType) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
cpmm.sendAsyncMessage("RIL:GetCardLockRetryCount", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
lockType: lockType,
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2012-10-05 18:08:55 +04:00
|
|
|
sendMMI: function sendMMI(window, mmi) {
|
2013-06-30 16:21:32 +04:00
|
|
|
// We need to save the global window to get the proper MMIError
|
|
|
|
// constructor once we get the reply from the parent process.
|
|
|
|
this._window = window;
|
|
|
|
|
2012-10-05 18:08:55 +04:00
|
|
|
debug("Sending MMI " + mmi);
|
2012-06-10 01:07:18 +04:00
|
|
|
if (!window) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
2013-06-30 16:21:32 +04:00
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
2012-06-10 01:07:18 +04:00
|
|
|
}
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:SendMMI", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
mmi: mmi,
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
2012-06-10 01:07:18 +04:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2012-10-05 18:08:55 +04:00
|
|
|
cancelMMI: function cancelMMI(window) {
|
|
|
|
debug("Cancel MMI");
|
2012-06-10 01:07:18 +04:00
|
|
|
if (!window) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:CancelMMI", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
2012-06-10 01:07:18 +04:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2012-08-30 02:09:12 +04:00
|
|
|
sendStkResponse: function sendStkResponse(window, command, response) {
|
2012-04-10 16:04:27 +04:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2012-08-30 02:09:12 +04:00
|
|
|
response.command = command;
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:SendStkResponse", {
|
|
|
|
clientId: 0,
|
|
|
|
data: response
|
|
|
|
});
|
2012-04-10 16:04:27 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
sendStkMenuSelection: function sendStkMenuSelection(window,
|
|
|
|
itemIdentifier,
|
|
|
|
helpRequested) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:SendStkMenuSelection", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
itemIdentifier: itemIdentifier,
|
|
|
|
helpRequested: helpRequested
|
|
|
|
}
|
|
|
|
});
|
2012-04-10 16:04:27 +04:00
|
|
|
},
|
|
|
|
|
2012-11-28 12:16:20 +04:00
|
|
|
sendStkTimerExpiration: function sendStkTimerExpiration(window,
|
|
|
|
timer) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:SendStkTimerExpiration", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
timer: timer
|
|
|
|
}
|
|
|
|
});
|
2012-11-28 12:16:20 +04:00
|
|
|
},
|
|
|
|
|
2012-09-11 06:34:36 +04:00
|
|
|
sendStkEventDownload: function sendStkEventDownload(window,
|
|
|
|
event) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:SendStkEventDownload", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
event: event
|
|
|
|
}
|
|
|
|
});
|
2012-09-11 06:34:36 +04:00
|
|
|
},
|
|
|
|
|
2013-02-25 13:27:26 +04:00
|
|
|
iccOpenChannel: function iccOpenChannel(window,
|
|
|
|
aid) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:IccOpenChannel", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
aid: aid
|
|
|
|
}
|
|
|
|
});
|
2013-02-25 13:27:26 +04:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
|
|
|
iccExchangeAPDU: function iccExchangeAPDU(window,
|
|
|
|
channel,
|
|
|
|
apdu) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
|
|
|
//Potentially you need serialization here and can't pass the jsval through
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:IccExchangeAPDU", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
channel: channel,
|
|
|
|
apdu: apdu
|
|
|
|
}
|
|
|
|
});
|
2013-02-25 13:27:26 +04:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
|
|
|
iccCloseChannel: function iccCloseChannel(window,
|
|
|
|
channel) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:IccCloseChannel", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
channel: channel
|
|
|
|
}
|
|
|
|
});
|
2013-02-25 13:27:26 +04:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-03-06 06:51:40 +04:00
|
|
|
readContacts: function readContacts(window, contactType) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
this._windowsMap[requestId] = window;
|
|
|
|
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:ReadIccContacts", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
contactType: contactType
|
|
|
|
}
|
|
|
|
});
|
2013-03-06 06:51:40 +04:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-03-06 06:12:23 +04:00
|
|
|
updateContact: function updateContact(window, contactType, contact, pin2) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
|
|
|
// Parsing nsDOMContact to Icc Contact format
|
|
|
|
let iccContact = {};
|
|
|
|
|
|
|
|
if (contact.name) {
|
|
|
|
iccContact.alphaId = contact.name[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (contact.tel) {
|
|
|
|
iccContact.number = contact.tel[0].value;
|
|
|
|
}
|
|
|
|
|
2013-04-30 10:53:47 +04:00
|
|
|
if (contact.email) {
|
|
|
|
iccContact.email = contact.email[0].value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (contact.tel.length > 1) {
|
|
|
|
iccContact.anr = contact.tel.slice(1);
|
|
|
|
}
|
|
|
|
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:UpdateIccContact", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
contactType: contactType,
|
|
|
|
contact: iccContact,
|
|
|
|
pin2: pin2
|
|
|
|
}
|
|
|
|
});
|
2013-03-06 06:12:23 +04:00
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2012-10-31 17:58:39 +04:00
|
|
|
getCallForwardingOption: function getCallForwardingOption(window, reason) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
|
|
|
if (!this._isValidCFReason(reason)){
|
|
|
|
this.dispatchFireRequestError(requestId, "Invalid call forwarding reason.");
|
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:GetCallForwardingOption", {
|
2013-07-02 13:36:40 +04:00
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
reason: reason
|
|
|
|
}
|
2012-10-31 17:58:39 +04:00
|
|
|
});
|
|
|
|
|
2013-07-02 13:36:40 +04:00
|
|
|
return request;
|
2012-10-31 17:58:39 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
setCallForwardingOption: function setCallForwardingOption(window, cfInfo) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
|
|
|
if (!cfInfo ||
|
|
|
|
!this._isValidCFReason(cfInfo.reason) ||
|
|
|
|
!this._isValidCFAction(cfInfo.action)){
|
|
|
|
this.dispatchFireRequestError(requestId, "Invalid call forwarding rule definition.");
|
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:SetCallForwardingOption", {
|
2013-07-02 13:36:40 +04:00
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
active: cfInfo.active,
|
|
|
|
action: cfInfo.action,
|
|
|
|
reason: cfInfo.reason,
|
|
|
|
number: cfInfo.number,
|
|
|
|
timeSeconds: cfInfo.timeSeconds
|
|
|
|
}
|
2012-10-31 17:58:39 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-05-21 09:13:37 +04:00
|
|
|
getCallBarringOption: function getCallBarringOption(window, option) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
|
|
|
if (DEBUG) debug("getCallBarringOption: " + JSON.stringify(option));
|
|
|
|
if (!this._isValidCallBarringOption(option)) {
|
|
|
|
this.dispatchFireRequestError(requestId, "InvalidCallBarringOption");
|
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:GetCallBarringOption", {
|
2013-07-02 13:36:40 +04:00
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
program: option.program,
|
|
|
|
password: option.password,
|
|
|
|
serviceClass: option.serviceClass
|
|
|
|
}
|
2013-05-21 09:13:37 +04:00
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
|
|
|
setCallBarringOption: function setCallBarringOption(window, option) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
|
|
|
if (DEBUG) debug("setCallBarringOption: " + JSON.stringify(option));
|
|
|
|
if (!this._isValidCallBarringOption(option)) {
|
|
|
|
this.dispatchFireRequestError(requestId, "InvalidCallBarringOption");
|
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:SetCallBarringOption", {
|
2013-07-02 13:36:40 +04:00
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
program: option.program,
|
|
|
|
enabled: option.enabled,
|
|
|
|
password: option.password,
|
|
|
|
serviceClass: option.serviceClass
|
|
|
|
}
|
2013-05-21 09:13:37 +04:00
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-04-18 16:18:50 +04:00
|
|
|
getCallWaitingOption: function getCallWaitingOption(window) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:GetCallWaitingOption", {
|
2013-07-02 13:36:40 +04:00
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId
|
|
|
|
}
|
2013-04-18 16:18:50 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
|
|
|
setCallWaitingOption: function setCallWaitingOption(window, enabled) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:SetCallWaitingOption", {
|
2013-07-02 13:36:40 +04:00
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
enabled: enabled
|
|
|
|
}
|
2013-04-18 16:18:50 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-07-18 01:18:29 +04:00
|
|
|
getCallingLineIdRestriction: function getCallingLineIdRestriction(window) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:GetCallingLineIdRestriction", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
|
|
|
setCallingLineIdRestriction:
|
|
|
|
function setCallingLineIdRestriction(window, clirMode) {
|
|
|
|
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:SetCallingLineIdRestriction", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
clirMode: clirMode
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
_mobileConnectionListeners: null,
|
|
|
|
_telephonyListeners: null,
|
|
|
|
_cellBroadcastListeners: null,
|
|
|
|
_voicemailListeners: null,
|
|
|
|
_iccListeners: null,
|
2012-07-19 07:27:08 +04:00
|
|
|
_enumerateTelephonyCallbacks: null,
|
2012-04-24 19:44:42 +04:00
|
|
|
|
2012-07-19 07:27:08 +04:00
|
|
|
voicemailStatus: null,
|
2012-12-26 14:49:08 +04:00
|
|
|
|
|
|
|
getVoicemailInfo: function getVoicemailInfo() {
|
|
|
|
// Get voicemail infomation by IPC only on first time.
|
|
|
|
this.getVoicemailInfo = function getVoicemailInfo() {
|
|
|
|
return this.voicemailInfo;
|
|
|
|
};
|
|
|
|
|
2013-07-02 13:36:40 +04:00
|
|
|
let voicemailInfo =
|
|
|
|
cpmm.sendSyncMessage("RIL:GetVoicemailInfo", {clientId: 0})[0];
|
2012-12-26 14:49:08 +04:00
|
|
|
if (voicemailInfo) {
|
2013-01-28 07:41:34 +04:00
|
|
|
this.updateInfo(voicemailInfo, this.voicemailInfo);
|
2012-12-26 14:49:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return this.voicemailInfo;
|
|
|
|
},
|
2012-11-23 08:09:01 +04:00
|
|
|
get voicemailNumber() {
|
2012-12-26 14:49:08 +04:00
|
|
|
return this.getVoicemailInfo().number;
|
2012-11-23 08:09:01 +04:00
|
|
|
},
|
|
|
|
get voicemailDisplayName() {
|
2012-12-26 14:49:08 +04:00
|
|
|
return this.getVoicemailInfo().displayName;
|
2012-11-23 08:09:01 +04:00
|
|
|
},
|
2012-07-19 07:27:08 +04:00
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
registerListener: function registerListener(listenerType, listener) {
|
|
|
|
let listeners = this[listenerType];
|
|
|
|
if (!listeners) {
|
|
|
|
listeners = this[listenerType] = [];
|
2012-07-19 07:27:08 +04:00
|
|
|
}
|
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
if (listeners.indexOf(listener) != -1) {
|
|
|
|
throw new Error("Already registered this listener!");
|
2012-04-24 19:44:42 +04:00
|
|
|
}
|
2012-07-19 07:27:08 +04:00
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
listeners.push(listener);
|
|
|
|
if (DEBUG) debug("Registered " + listenerType + " listener: " + listener);
|
2012-04-24 19:44:42 +04:00
|
|
|
},
|
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
unregisterListener: function unregisterListener(listenerType, listener) {
|
|
|
|
let listeners = this[listenerType];
|
|
|
|
if (!listeners) {
|
2012-04-24 19:44:42 +04:00
|
|
|
return;
|
|
|
|
}
|
2012-07-19 07:27:08 +04:00
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
let index = listeners.indexOf(listener);
|
2012-04-24 19:44:42 +04:00
|
|
|
if (index != -1) {
|
2013-03-06 13:53:31 +04:00
|
|
|
listeners.splice(index, 1);
|
|
|
|
if (DEBUG) debug("Unregistered listener: " + listener);
|
2012-04-24 19:44:42 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
registerMobileConnectionMsg: function registerMobileConnectionMsg(listener) {
|
|
|
|
debug("Registering for mobile connection related messages");
|
|
|
|
this.registerListener("_mobileConnectionListeners", listener);
|
|
|
|
cpmm.sendAsyncMessage("RIL:RegisterMobileConnectionMsg");
|
|
|
|
},
|
|
|
|
|
|
|
|
unregisterMobileConnectionMsg: function unregisteMobileConnectionMsg(listener) {
|
|
|
|
this.unregisterListener("_mobileConnectionListeners", listener);
|
|
|
|
},
|
|
|
|
|
|
|
|
registerTelephonyMsg: function registerTelephonyMsg(listener) {
|
|
|
|
debug("Registering for telephony-related messages");
|
|
|
|
this.registerListener("_telephonyListeners", listener);
|
|
|
|
cpmm.sendAsyncMessage("RIL:RegisterTelephonyMsg");
|
2012-07-19 07:27:08 +04:00
|
|
|
},
|
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
unregisterTelephonyMsg: function unregisteTelephonyMsg(listener) {
|
|
|
|
this.unregisterListener("_telephonyListeners", listener);
|
2013-01-31 06:37:13 +04:00
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
// We also need to make sure the listener is removed from
|
2013-01-31 06:37:13 +04:00
|
|
|
// _enumerateTelephonyCallbacks.
|
2013-03-06 13:53:31 +04:00
|
|
|
let index = this._enumerateTelephonyCallbacks.indexOf(listener);
|
2013-01-31 06:37:13 +04:00
|
|
|
if (index != -1) {
|
|
|
|
this._enumerateTelephonyCallbacks.splice(index, 1);
|
2013-03-06 13:53:31 +04:00
|
|
|
if (DEBUG) debug("Unregistered enumerateTelephony callback: " + listener);
|
2013-01-31 06:37:13 +04:00
|
|
|
}
|
2012-07-19 07:27:08 +04:00
|
|
|
},
|
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
registerVoicemailMsg: function registerVoicemailMsg(listener) {
|
|
|
|
debug("Registering for voicemail-related messages");
|
|
|
|
this.registerListener("_voicemailListeners", listener);
|
|
|
|
cpmm.sendAsyncMessage("RIL:RegisterVoicemailMsg");
|
2012-12-04 06:40:47 +04:00
|
|
|
},
|
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
unregisterVoicemailMsg: function unregisteVoicemailMsg(listener) {
|
|
|
|
this.unregisterListener("_voicemailListeners", listener);
|
2012-12-04 06:40:47 +04:00
|
|
|
},
|
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
registerCellBroadcastMsg: function registerCellBroadcastMsg(listener) {
|
|
|
|
debug("Registering for Cell Broadcast related messages");
|
|
|
|
this.registerListener("_cellBroadcastListeners", listener);
|
|
|
|
cpmm.sendAsyncMessage("RIL:RegisterCellBroadcastMsg");
|
2012-10-09 14:07:11 +04:00
|
|
|
},
|
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
unregisterCellBroadcastMsg: function unregisterCellBroadcastMsg(listener) {
|
|
|
|
this.unregisterListener("_cellBroadcastListeners", listener);
|
2012-10-09 14:07:11 +04:00
|
|
|
},
|
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
registerIccMsg: function registerIccMsg(listener) {
|
|
|
|
debug("Registering for ICC related messages");
|
|
|
|
this.registerListener("_iccListeners", listener);
|
|
|
|
cpmm.sendAsyncMessage("RIL:RegisterIccMsg");
|
2012-10-09 14:07:11 +04:00
|
|
|
},
|
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
unregisterIccMsg: function unregisterIccMsg(listener) {
|
|
|
|
this.unregisterListener("_iccListeners", listener);
|
2012-12-04 06:40:47 +04:00
|
|
|
},
|
|
|
|
|
2012-04-24 19:44:42 +04:00
|
|
|
enumerateCalls: function enumerateCalls(callback) {
|
|
|
|
debug("Requesting enumeration of calls for callback: " + callback);
|
2012-08-17 07:46:34 +04:00
|
|
|
// We need 'requestId' to meet the 'RILContentHelper <--> RadioInterfaceLayer'
|
|
|
|
// protocol.
|
|
|
|
let requestId = this._getRandomId();
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:EnumerateCalls", {
|
|
|
|
clientId: 0,
|
|
|
|
data: {
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
2012-10-30 13:24:31 +04:00
|
|
|
if (!this._enumerateTelephonyCallbacks) {
|
|
|
|
this._enumerateTelephonyCallbacks = [];
|
2012-04-24 19:44:42 +04:00
|
|
|
}
|
2012-10-30 13:24:31 +04:00
|
|
|
this._enumerateTelephonyCallbacks.push(callback);
|
2012-04-24 19:44:42 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
startTone: function startTone(dtmfChar) {
|
|
|
|
debug("Sending Tone for " + dtmfChar);
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:StartTone", {
|
|
|
|
clientId: 0,
|
|
|
|
data: dtmfChar
|
|
|
|
});
|
2012-04-24 19:44:42 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
stopTone: function stopTone() {
|
|
|
|
debug("Stopping Tone");
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:StopTone", {clientId: 0});
|
2012-04-24 19:44:42 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
dial: function dial(number) {
|
|
|
|
debug("Dialing " + number);
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:Dial", {
|
|
|
|
clientId: 0,
|
|
|
|
data: number
|
|
|
|
});
|
2012-04-24 19:44:42 +04:00
|
|
|
},
|
|
|
|
|
2012-07-20 16:08:24 +04:00
|
|
|
dialEmergency: function dialEmergency(number) {
|
|
|
|
debug("Dialing emergency " + number);
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:DialEmergency", {
|
|
|
|
clientId: 0,
|
|
|
|
data: number
|
|
|
|
});
|
2012-07-20 16:08:24 +04:00
|
|
|
},
|
|
|
|
|
2012-04-24 19:44:42 +04:00
|
|
|
hangUp: function hangUp(callIndex) {
|
|
|
|
debug("Hanging up call no. " + callIndex);
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:HangUp", {
|
|
|
|
clientId: 0,
|
|
|
|
data: callIndex
|
|
|
|
});
|
2012-04-24 19:44:42 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
answerCall: function answerCall(callIndex) {
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:AnswerCall", {
|
|
|
|
clientId: 0,
|
|
|
|
data: callIndex
|
|
|
|
});
|
2012-04-24 19:44:42 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
rejectCall: function rejectCall(callIndex) {
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:RejectCall", {
|
|
|
|
clientId: 0,
|
|
|
|
data: callIndex
|
|
|
|
});
|
2012-04-24 19:44:42 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
holdCall: function holdCall(callIndex) {
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:HoldCall", {
|
|
|
|
clientId: 0,
|
|
|
|
data: callIndex
|
|
|
|
});
|
2012-04-24 19:44:42 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
resumeCall: function resumeCall(callIndex) {
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:ResumeCall", {
|
|
|
|
clientId: 0,
|
|
|
|
data: callIndex
|
|
|
|
});
|
2012-04-24 19:44:42 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
get microphoneMuted() {
|
2013-07-02 13:36:40 +04:00
|
|
|
return cpmm.sendSyncMessage("RIL:GetMicrophoneMuted", {clientId: 0})[0];
|
2012-04-24 19:44:42 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
set microphoneMuted(value) {
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:SetMicrophoneMuted", {
|
|
|
|
clientId: 0,
|
|
|
|
data: value
|
|
|
|
});
|
2012-04-24 19:44:42 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
get speakerEnabled() {
|
2013-07-02 13:36:40 +04:00
|
|
|
return cpmm.sendSyncMessage("RIL:GetSpeakerEnabled", {clientId: 0})[0];
|
2012-04-24 19:44:42 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
set speakerEnabled(value) {
|
2013-07-02 13:36:40 +04:00
|
|
|
cpmm.sendAsyncMessage("RIL:SetSpeakerEnabled", {
|
|
|
|
clientId: 0,
|
|
|
|
data: value
|
|
|
|
});
|
2012-04-24 19:44:42 +04:00
|
|
|
},
|
|
|
|
|
2012-04-20 01:33:25 +04:00
|
|
|
// nsIObserver
|
|
|
|
|
|
|
|
observe: function observe(subject, topic, data) {
|
|
|
|
if (topic == "xpcom-shutdown") {
|
2013-07-09 01:55:42 +04:00
|
|
|
this.destroyDOMRequestHelper();
|
2012-04-20 01:33:25 +04:00
|
|
|
Services.obs.removeObserver(this, "xpcom-shutdown");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-08-27 18:13:02 +04:00
|
|
|
// nsIMessageListener
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2012-06-13 01:05:50 +04:00
|
|
|
fireRequestSuccess: function fireRequestSuccess(requestId, result) {
|
|
|
|
let request = this.takeRequest(requestId);
|
|
|
|
if (!request) {
|
|
|
|
if (DEBUG) {
|
2012-06-20 02:52:06 +04:00
|
|
|
debug("not firing success for id: " + requestId +
|
|
|
|
", result: " + JSON.stringify(result));
|
2012-06-13 01:05:50 +04:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DEBUG) {
|
2012-06-20 02:52:06 +04:00
|
|
|
debug("fire request success, id: " + requestId +
|
|
|
|
", result: " + JSON.stringify(result));
|
2012-06-13 01:05:50 +04:00
|
|
|
}
|
|
|
|
Services.DOMRequest.fireSuccess(request, result);
|
|
|
|
},
|
|
|
|
|
2012-06-20 02:52:06 +04:00
|
|
|
dispatchFireRequestSuccess: function dispatchFireRequestSuccess(requestId, result) {
|
|
|
|
let currentThread = Services.tm.currentThread;
|
|
|
|
|
|
|
|
currentThread.dispatch(this.fireRequestSuccess.bind(this, requestId, result),
|
|
|
|
Ci.nsIThread.DISPATCH_NORMAL);
|
|
|
|
},
|
|
|
|
|
2012-06-13 01:05:50 +04:00
|
|
|
fireRequestError: function fireRequestError(requestId, error) {
|
|
|
|
let request = this.takeRequest(requestId);
|
|
|
|
if (!request) {
|
|
|
|
if (DEBUG) {
|
2012-06-20 02:52:06 +04:00
|
|
|
debug("not firing error for id: " + requestId +
|
|
|
|
", error: " + JSON.stringify(error));
|
2012-06-13 01:05:50 +04:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DEBUG) {
|
2012-06-20 02:52:06 +04:00
|
|
|
debug("fire request error, id: " + requestId +
|
|
|
|
", result: " + JSON.stringify(error));
|
2012-06-13 01:05:50 +04:00
|
|
|
}
|
|
|
|
Services.DOMRequest.fireError(request, error);
|
|
|
|
},
|
|
|
|
|
2012-10-31 17:58:39 +04:00
|
|
|
dispatchFireRequestError: function dispatchFireRequestError(requestId, error) {
|
|
|
|
let currentThread = Services.tm.currentThread;
|
|
|
|
|
|
|
|
currentThread.dispatch(this.fireRequestError.bind(this, requestId, error),
|
|
|
|
Ci.nsIThread.DISPATCH_NORMAL);
|
|
|
|
},
|
|
|
|
|
2012-04-20 01:33:25 +04:00
|
|
|
receiveMessage: function receiveMessage(msg) {
|
2012-04-12 08:01:49 +04:00
|
|
|
let request;
|
2012-04-20 01:33:25 +04:00
|
|
|
debug("Received message '" + msg.name + "': " + JSON.stringify(msg.json));
|
|
|
|
switch (msg.name) {
|
2013-07-02 13:36:40 +04:00
|
|
|
case "RIL:CardStateChanged": {
|
|
|
|
let data = msg.json.data;
|
|
|
|
if (this.rilContext.cardState != data.cardState) {
|
|
|
|
this.rilContext.cardState = data.cardState;
|
2013-05-22 13:32:18 +04:00
|
|
|
this._deliverEvent("_iccListeners",
|
2013-03-06 13:53:31 +04:00
|
|
|
"notifyCardStateChanged",
|
|
|
|
null);
|
2012-04-20 01:33:25 +04:00
|
|
|
}
|
|
|
|
break;
|
2013-07-02 13:36:40 +04:00
|
|
|
}
|
2012-09-04 01:43:59 +04:00
|
|
|
case "RIL:IccInfoChanged":
|
2013-07-02 13:36:40 +04:00
|
|
|
this.updateInfo(msg.json.data, this.rilContext.iccInfo);
|
2013-05-30 15:14:39 +04:00
|
|
|
this._deliverEvent("_iccListeners", "notifyIccInfoChanged", null);
|
2012-09-04 01:43:59 +04:00
|
|
|
break;
|
2012-04-20 01:33:25 +04:00
|
|
|
case "RIL:VoiceInfoChanged":
|
2013-07-02 13:36:40 +04:00
|
|
|
this.updateConnectionInfo(msg.json.data,
|
|
|
|
this.rilContext.voiceConnectionInfo);
|
2013-03-06 13:53:31 +04:00
|
|
|
this._deliverEvent("_mobileConnectionListeners",
|
|
|
|
"notifyVoiceChanged",
|
|
|
|
null);
|
2012-04-20 01:33:25 +04:00
|
|
|
break;
|
|
|
|
case "RIL:DataInfoChanged":
|
2013-07-02 13:36:40 +04:00
|
|
|
this.updateConnectionInfo(msg.json.data,
|
|
|
|
this.rilContext.dataConnectionInfo);
|
2013-03-06 13:53:31 +04:00
|
|
|
this._deliverEvent("_mobileConnectionListeners",
|
|
|
|
"notifyDataChanged",
|
|
|
|
null);
|
2012-04-20 01:33:25 +04:00
|
|
|
break;
|
2012-04-24 19:44:42 +04:00
|
|
|
case "RIL:EnumerateCalls":
|
2012-08-17 07:46:34 +04:00
|
|
|
this.handleEnumerateCalls(msg.json.calls);
|
2012-04-24 19:44:42 +04:00
|
|
|
break;
|
2012-06-02 01:10:39 +04:00
|
|
|
case "RIL:GetAvailableNetworks":
|
|
|
|
this.handleGetAvailableNetworks(msg.json);
|
|
|
|
break;
|
2012-06-20 02:52:06 +04:00
|
|
|
case "RIL:NetworkSelectionModeChanged":
|
2013-07-02 13:36:40 +04:00
|
|
|
this.rilContext.networkSelectionMode = msg.json.data.mode;
|
2012-06-20 02:52:06 +04:00
|
|
|
break;
|
|
|
|
case "RIL:SelectNetwork":
|
|
|
|
this.handleSelectNetwork(msg.json,
|
|
|
|
RIL.GECKO_NETWORK_SELECTION_MANUAL);
|
|
|
|
break;
|
|
|
|
case "RIL:SelectNetworkAuto":
|
|
|
|
this.handleSelectNetwork(msg.json,
|
|
|
|
RIL.GECKO_NETWORK_SELECTION_AUTOMATIC);
|
|
|
|
break;
|
2013-07-02 13:36:40 +04:00
|
|
|
case "RIL:CallStateChanged": {
|
|
|
|
let data = msg.json.data;
|
2013-03-06 13:53:31 +04:00
|
|
|
this._deliverEvent("_telephonyListeners",
|
|
|
|
"callStateChanged",
|
2013-07-02 13:36:40 +04:00
|
|
|
[data.callIndex, data.state,
|
|
|
|
data.number, data.isActive,
|
|
|
|
data.isOutgoing, data.isEmergency]);
|
2012-05-15 08:13:06 +04:00
|
|
|
break;
|
2013-07-02 13:36:40 +04:00
|
|
|
}
|
|
|
|
case "RIL:CallError": {
|
|
|
|
let data = msg.json.data;
|
2013-03-06 13:53:31 +04:00
|
|
|
this._deliverEvent("_telephonyListeners",
|
|
|
|
"notifyError",
|
2013-07-02 13:36:40 +04:00
|
|
|
[data.callIndex, data.errorMsg]);
|
2012-07-19 07:27:08 +04:00
|
|
|
break;
|
2013-07-02 13:36:40 +04:00
|
|
|
}
|
2012-07-19 07:27:08 +04:00
|
|
|
case "RIL:VoicemailNotification":
|
2013-07-02 13:36:40 +04:00
|
|
|
this.handleVoicemailNotification(msg.json.data);
|
2012-06-02 01:10:39 +04:00
|
|
|
break;
|
2012-11-23 08:09:01 +04:00
|
|
|
case "RIL:VoicemailInfoChanged":
|
2013-07-02 13:36:40 +04:00
|
|
|
this.updateInfo(msg.json.data, this.voicemailInfo);
|
2012-07-21 04:19:38 +04:00
|
|
|
break;
|
2012-08-15 20:49:12 +04:00
|
|
|
case "RIL:CardLockResult":
|
|
|
|
if (msg.json.success) {
|
2013-04-11 11:12:09 +04:00
|
|
|
let result = new MobileIccCardLockResult(msg.json);
|
2012-09-10 07:54:49 +04:00
|
|
|
this.fireRequestSuccess(msg.json.requestId, result);
|
2012-08-15 20:49:12 +04:00
|
|
|
} else {
|
2012-10-03 10:51:53 +04:00
|
|
|
if (msg.json.rilMessageType == "iccSetCardLock" ||
|
|
|
|
msg.json.rilMessageType == "iccUnlockCardLock") {
|
2013-04-11 11:12:09 +04:00
|
|
|
this._deliverEvent("_iccListeners",
|
2013-03-06 13:53:31 +04:00
|
|
|
"notifyIccCardLockError",
|
|
|
|
[msg.json.lockType, msg.json.retryCount]);
|
2012-10-03 10:51:53 +04:00
|
|
|
}
|
|
|
|
this.fireRequestError(msg.json.requestId, msg.json.errorMsg);
|
2012-08-15 20:49:12 +04:00
|
|
|
}
|
2012-04-12 08:01:49 +04:00
|
|
|
break;
|
Bug 875710: Added getCardLockRetryCount to nsIIccProvider, r=vyang, sr=mounir
This patch adds getCardLockRetryCount to nsIIccProvider and its
implementations. This method allows callers to query the number
of remaining tries for unlocking a SIM-card lock. Supported locks
are 'pin', 'puk', 'pin2', 'puk2', 'nck', 'cck', and 'spck'. The
call returns a DOM request that returns the retry count in its
success handler, or signals an appropriate error.
Reading the retry count is an optional feature and may not be
supported for all lock types. In this case the DOM request receives
and error with the name GECKO_ERROR_NOT_SUPPORTED. For an invalid
lock type, the error name is GECKO_ERROR_GENERIC_FAILURE.
getCardLockRetryCount replaces retryCount in nsIDOMMobileConnection,
which is now deprecated.
--HG--
extra : rebase_source : d1d11612f836652dca85f7c701f09e7af962e3b7
2013-07-09 18:06:05 +04:00
|
|
|
case "RIL:CardLockRetryCount":
|
|
|
|
if (msg.json.success) {
|
|
|
|
let result = new MobileIccCardLockRetryCount(msg.json);
|
|
|
|
this.fireRequestSuccess(msg.json.requestId, result);
|
|
|
|
} else {
|
|
|
|
this.fireRequestError(msg.json.requestId, msg.json.errorMsg);
|
|
|
|
}
|
|
|
|
break;
|
2013-07-02 13:36:40 +04:00
|
|
|
case "RIL:USSDReceived": {
|
|
|
|
let data = msg.json.data;
|
2013-03-06 13:53:31 +04:00
|
|
|
this._deliverEvent("_mobileConnectionListeners",
|
|
|
|
"notifyUssdReceived",
|
2013-07-02 13:36:40 +04:00
|
|
|
[data.message, data.sessionEnded]);
|
2012-06-10 01:07:18 +04:00
|
|
|
break;
|
2013-07-02 13:36:40 +04:00
|
|
|
}
|
2012-10-05 18:08:55 +04:00
|
|
|
case "RIL:SendMMI:Return:OK":
|
|
|
|
case "RIL:CancelMMI:Return:OK":
|
|
|
|
case "RIL:SendMMI:Return:KO":
|
|
|
|
case "RIL:CancelMMI:Return:KO":
|
2013-06-30 16:21:32 +04:00
|
|
|
this.handleSendCancelMMI(msg.json);
|
2012-06-10 01:07:18 +04:00
|
|
|
break;
|
2012-04-10 16:04:27 +04:00
|
|
|
case "RIL:StkCommand":
|
2013-03-06 13:53:31 +04:00
|
|
|
this._deliverEvent("_iccListeners", "notifyStkCommand",
|
2013-07-02 13:36:40 +04:00
|
|
|
[JSON.stringify(msg.json.data)]);
|
2012-04-10 16:04:27 +04:00
|
|
|
break;
|
|
|
|
case "RIL:StkSessionEnd":
|
2013-03-06 13:53:31 +04:00
|
|
|
this._deliverEvent("_iccListeners", "notifyStkSessionEnd", null);
|
2012-09-25 23:22:38 +04:00
|
|
|
break;
|
2013-02-25 13:27:26 +04:00
|
|
|
case "RIL:IccOpenChannel":
|
|
|
|
this.handleIccOpenChannel(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:IccCloseChannel":
|
|
|
|
this.handleIccCloseChannel(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:IccExchangeAPDU":
|
|
|
|
this.handleIccExchangeAPDU(msg.json);
|
|
|
|
break;
|
2013-03-06 06:51:40 +04:00
|
|
|
case "RIL:ReadIccContacts":
|
|
|
|
this.handleReadIccContacts(msg.json);
|
|
|
|
break;
|
2013-03-25 07:09:01 +04:00
|
|
|
case "RIL:UpdateIccContact":
|
|
|
|
this.handleUpdateIccContact(msg.json);
|
2013-03-06 06:12:23 +04:00
|
|
|
break;
|
2013-07-02 13:36:40 +04:00
|
|
|
case "RIL:DataError": {
|
|
|
|
let data = msg.json.data;
|
|
|
|
this.updateConnectionInfo(data, this.rilContext.dataConnectionInfo);
|
2013-03-06 13:53:31 +04:00
|
|
|
this._deliverEvent("_mobileConnectionListeners", "notifyDataError",
|
2013-07-02 13:36:40 +04:00
|
|
|
[data.errorMsg]);
|
2012-09-25 23:22:38 +04:00
|
|
|
break;
|
2013-07-02 13:36:40 +04:00
|
|
|
}
|
2012-10-31 17:58:39 +04:00
|
|
|
case "RIL:GetCallForwardingOption":
|
|
|
|
this.handleGetCallForwardingOption(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:SetCallForwardingOption":
|
|
|
|
this.handleSetCallForwardingOption(msg.json);
|
|
|
|
break;
|
2013-05-21 09:13:37 +04:00
|
|
|
case "RIL:GetCallBarringOption":
|
|
|
|
this.handleGetCallBarringOption(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:SetCallBarringOption":
|
|
|
|
this.handleSetCallBarringOption(msg.json);
|
|
|
|
break;
|
2013-04-18 16:18:50 +04:00
|
|
|
case "RIL:GetCallWaitingOption":
|
|
|
|
this.handleGetCallWaitingOption(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:SetCallWaitingOption":
|
|
|
|
this.handleSetCallWaitingOption(msg.json);
|
|
|
|
break;
|
2013-07-02 13:36:40 +04:00
|
|
|
case "RIL:CfStateChanged": {
|
|
|
|
let data = msg.json.data;
|
2013-03-06 13:53:31 +04:00
|
|
|
this._deliverEvent("_mobileConnectionListeners",
|
|
|
|
"notifyCFStateChange",
|
2013-07-02 13:36:40 +04:00
|
|
|
[data.success, data.action,
|
|
|
|
data.reason, data.number,
|
|
|
|
data.timeSeconds, data.serviceClass]);
|
2013-01-25 22:45:23 +04:00
|
|
|
break;
|
2013-07-02 13:36:40 +04:00
|
|
|
}
|
2013-07-18 01:18:29 +04:00
|
|
|
case "RIL:GetCallingLineIdRestriction":
|
|
|
|
this.handleGetCallingLineIdRestriction(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:SetCallingLineIdRestriction":
|
|
|
|
this.handleSetCallingLineIdRestriction(msg.json);
|
|
|
|
break;
|
2013-07-02 13:36:40 +04:00
|
|
|
case "RIL:CellBroadcastReceived": {
|
|
|
|
let message = new CellBroadcastMessage(msg.json.data);
|
2013-03-06 13:53:31 +04:00
|
|
|
this._deliverEvent("_cellBroadcastListeners",
|
|
|
|
"notifyMessageReceived",
|
|
|
|
[message]);
|
2012-12-04 06:40:47 +04:00
|
|
|
break;
|
2013-07-02 13:36:40 +04:00
|
|
|
}
|
2012-04-24 19:44:42 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-05-15 08:13:06 +04:00
|
|
|
handleEnumerateCalls: function handleEnumerateCalls(calls) {
|
|
|
|
debug("handleEnumerateCalls: " + JSON.stringify(calls));
|
2012-10-30 13:24:31 +04:00
|
|
|
let callback = this._enumerateTelephonyCallbacks.shift();
|
2013-05-10 10:58:06 +04:00
|
|
|
if (!calls.length) {
|
|
|
|
callback.enumerateCallStateComplete();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-24 19:44:42 +04:00
|
|
|
for (let i in calls) {
|
|
|
|
let call = calls[i];
|
|
|
|
let keepGoing;
|
|
|
|
try {
|
|
|
|
keepGoing =
|
|
|
|
callback.enumerateCallState(call.callIndex, call.state, call.number,
|
2013-05-14 10:05:46 +04:00
|
|
|
call.isActive, call.isOutgoing,
|
|
|
|
call.isEmergency);
|
2012-04-24 19:44:42 +04:00
|
|
|
} catch (e) {
|
|
|
|
debug("callback handler for 'enumerateCallState' threw an " +
|
|
|
|
" exception: " + e);
|
|
|
|
keepGoing = true;
|
|
|
|
}
|
|
|
|
if (!keepGoing) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-05-10 10:58:06 +04:00
|
|
|
|
|
|
|
callback.enumerateCallStateComplete();
|
2012-04-24 19:44:42 +04:00
|
|
|
},
|
|
|
|
|
2012-06-02 01:10:39 +04:00
|
|
|
handleGetAvailableNetworks: function handleGetAvailableNetworks(message) {
|
|
|
|
debug("handleGetAvailableNetworks: " + JSON.stringify(message));
|
|
|
|
|
|
|
|
let requestId = message.requestId;
|
|
|
|
let request = this.takeRequest(requestId);
|
|
|
|
if (!request) {
|
|
|
|
debug("no DOMRequest found with request ID: " + requestId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-07 14:35:57 +04:00
|
|
|
if (message.errorMsg) {
|
|
|
|
debug("Received error from getAvailableNetworks: " + message.errorMsg);
|
|
|
|
Services.DOMRequest.fireError(request, message.errorMsg);
|
2012-06-02 01:10:39 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let networks = message.networks;
|
|
|
|
for (let i = 0; i < networks.length; i++) {
|
|
|
|
let network = networks[i];
|
2012-06-13 01:05:50 +04:00
|
|
|
let info = new MobileNetworkInfo();
|
2013-01-28 07:41:34 +04:00
|
|
|
this.updateInfo(network, info);
|
2012-06-02 01:10:39 +04:00
|
|
|
networks[i] = info;
|
|
|
|
}
|
|
|
|
|
|
|
|
Services.DOMRequest.fireSuccess(request, networks);
|
|
|
|
},
|
|
|
|
|
2012-06-20 02:52:06 +04:00
|
|
|
handleSelectNetwork: function handleSelectNetwork(message, mode) {
|
|
|
|
this._selectingNetwork = null;
|
2013-04-01 10:26:45 +04:00
|
|
|
this.rilContext.networkSelectionMode = mode;
|
2012-06-20 02:52:06 +04:00
|
|
|
|
2013-03-07 14:35:57 +04:00
|
|
|
if (message.errorMsg) {
|
|
|
|
this.fireRequestError(message.requestId, message.errorMsg);
|
2012-06-20 02:52:06 +04:00
|
|
|
} else {
|
|
|
|
this.fireRequestSuccess(message.requestId, null);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-02-25 13:27:26 +04:00
|
|
|
handleIccOpenChannel: function handleIccOpenChannel(message) {
|
2013-03-07 14:35:57 +04:00
|
|
|
if (message.errorMsg) {
|
|
|
|
this.fireRequestError(message.requestId, message.errorMsg);
|
2013-02-25 13:27:26 +04:00
|
|
|
} else {
|
|
|
|
this.fireRequestSuccess(message.requestId, message.channel);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
handleIccCloseChannel: function handleIccCloseChannel(message) {
|
2013-03-07 14:35:57 +04:00
|
|
|
if (message.errorMsg) {
|
|
|
|
this.fireRequestError(message.requestId, message.errorMsg);
|
2013-02-25 13:27:26 +04:00
|
|
|
} else {
|
|
|
|
this.fireRequestSuccess(message.requestId, null);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
handleIccExchangeAPDU: function handleIccExchangeAPDU(message) {
|
2013-03-07 14:35:57 +04:00
|
|
|
if (message.errorMsg) {
|
|
|
|
this.fireRequestError(message.requestId, message.errorMsg);
|
2013-02-25 13:27:26 +04:00
|
|
|
} else {
|
|
|
|
var result = [message.sw1, message.sw2, message.simResponse];
|
|
|
|
this.fireRequestSuccess(message.requestId, result);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-03-06 06:51:40 +04:00
|
|
|
handleReadIccContacts: function handleReadIccContacts(message) {
|
|
|
|
if (message.errorMsg) {
|
|
|
|
this.fireRequestError(message.requestId, message.errorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let window = this._windowsMap[message.requestId];
|
|
|
|
delete this._windowsMap[message.requestId];
|
|
|
|
let contacts = message.contacts;
|
|
|
|
let result = contacts.map(function(c) {
|
|
|
|
let contact = Cc["@mozilla.org/contact;1"].createInstance(Ci.nsIDOMContact);
|
|
|
|
let prop = {name: [c.alphaId], tel: [{value: c.number}]};
|
|
|
|
|
|
|
|
if (c.email) {
|
|
|
|
prop.email = [{value: c.email}];
|
|
|
|
}
|
|
|
|
|
|
|
|
// ANR - Additional Number
|
|
|
|
let anrLen = c.anr ? c.anr.length : 0;
|
|
|
|
for (let i = 0; i < anrLen; i++) {
|
|
|
|
prop.tel.push({value: c.anr[i]});
|
|
|
|
}
|
|
|
|
|
|
|
|
contact.init(prop);
|
|
|
|
return contact;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.fireRequestSuccess(message.requestId,
|
|
|
|
ObjectWrapper.wrap(result, window));
|
|
|
|
},
|
|
|
|
|
2013-03-25 07:09:01 +04:00
|
|
|
handleUpdateIccContact: function handleUpdateIccContact(message) {
|
2013-03-06 06:12:23 +04:00
|
|
|
if (message.errorMsg) {
|
|
|
|
this.fireRequestError(message.requestId, message.errorMsg);
|
|
|
|
} else {
|
|
|
|
this.fireRequestSuccess(message.requestId, null);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-07-19 07:27:08 +04:00
|
|
|
handleVoicemailNotification: function handleVoicemailNotification(message) {
|
|
|
|
let changed = false;
|
|
|
|
if (!this.voicemailStatus) {
|
|
|
|
this.voicemailStatus = new VoicemailStatus();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.voicemailStatus.hasMessages != message.active) {
|
|
|
|
changed = true;
|
|
|
|
this.voicemailStatus.hasMessages = message.active;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.voicemailStatus.messageCount != message.msgCount) {
|
|
|
|
changed = true;
|
|
|
|
this.voicemailStatus.messageCount = message.msgCount;
|
2013-05-03 02:22:25 +04:00
|
|
|
} else if (message.msgCount == -1) {
|
|
|
|
// For MWI using DCS the message count is not available
|
|
|
|
changed = true;
|
2012-07-19 07:27:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.voicemailStatus.returnNumber != message.returnNumber) {
|
|
|
|
changed = true;
|
|
|
|
this.voicemailStatus.returnNumber = message.returnNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.voicemailStatus.returnMessage != message.returnMessage) {
|
|
|
|
changed = true;
|
|
|
|
this.voicemailStatus.returnMessage = message.returnMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed) {
|
2013-03-06 13:53:31 +04:00
|
|
|
this._deliverEvent("_voicemailListeners",
|
|
|
|
"voicemailNotification",
|
|
|
|
[this.voicemailStatus]);
|
2012-07-19 07:27:08 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-11-08 02:13:48 +04:00
|
|
|
_cfRulesToMobileCfInfo: function _cfRulesToMobileCfInfo(rules) {
|
|
|
|
for (let i = 0; i < rules.length; i++) {
|
|
|
|
let rule = rules[i];
|
|
|
|
let info = new MobileCFInfo();
|
2013-01-28 07:41:34 +04:00
|
|
|
this.updateInfo(rule, info);
|
2012-11-08 02:13:48 +04:00
|
|
|
rules[i] = info;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-10-31 17:58:39 +04:00
|
|
|
handleGetCallForwardingOption: function handleGetCallForwardingOption(message) {
|
|
|
|
let requestId = message.requestId;
|
|
|
|
let request = this.takeRequest(requestId);
|
|
|
|
if (!request) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!message.success) {
|
|
|
|
Services.DOMRequest.fireError(request, message.errorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-08 02:13:48 +04:00
|
|
|
this._cfRulesToMobileCfInfo(message.rules);
|
|
|
|
Services.DOMRequest.fireSuccess(request, message.rules);
|
2012-10-31 17:58:39 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
handleSetCallForwardingOption: function handleSetCallForwardingOption(message) {
|
|
|
|
let requestId = message.requestId;
|
|
|
|
let request = this.takeRequest(requestId);
|
|
|
|
if (!request) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!message.success) {
|
|
|
|
Services.DOMRequest.fireError(request, message.errorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Services.DOMRequest.fireSuccess(request, null);
|
|
|
|
},
|
|
|
|
|
2013-05-21 09:13:37 +04:00
|
|
|
handleGetCallBarringOption: function handleGetCallBarringOption(message) {
|
|
|
|
if (!message.success) {
|
|
|
|
this.fireRequestError(message.requestId, message.errorMsg);
|
|
|
|
} else {
|
|
|
|
let option = new CallBarringOption(message);
|
|
|
|
this.fireRequestSuccess(message.requestId, option);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
handleSetCallBarringOption: function handleSetCallBarringOption(message) {
|
|
|
|
if (!message.success) {
|
|
|
|
this.fireRequestError(message.requestId, message.errorMsg);
|
|
|
|
} else {
|
|
|
|
this.fireRequestSuccess(message.requestId, null);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-04-18 16:18:50 +04:00
|
|
|
handleGetCallWaitingOption: function handleGetCallWaitingOption(message) {
|
|
|
|
let requestId = message.requestId;
|
|
|
|
let request = this.takeRequest(requestId);
|
|
|
|
if (!request) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!message.success) {
|
|
|
|
Services.DOMRequest.fireError(request, message.errorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Services.DOMRequest.fireSuccess(request, message.enabled);
|
|
|
|
},
|
|
|
|
|
|
|
|
handleSetCallWaitingOption: function handleSetCallWaitingOption(message) {
|
|
|
|
let requestId = message.requestId;
|
|
|
|
let request = this.takeRequest(requestId);
|
|
|
|
if (!request) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!message.success) {
|
|
|
|
Services.DOMRequest.fireError(request, message.errorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Services.DOMRequest.fireSuccess(request, null);
|
|
|
|
},
|
|
|
|
|
2013-07-18 01:18:29 +04:00
|
|
|
handleGetCallingLineIdRestriction:
|
|
|
|
function handleGetCallingLineIdRestriction(message) {
|
|
|
|
let requestId = message.requestId;
|
|
|
|
let request = this.takeRequest(requestId);
|
|
|
|
if (!request) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!message.success) {
|
|
|
|
Services.DOMRequest.fireError(request, message.errorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let status = new DOMCLIRStatus(message);
|
|
|
|
Services.DOMRequest.fireSuccess(request, status);
|
|
|
|
},
|
|
|
|
|
|
|
|
handleSetCallingLineIdRestriction:
|
|
|
|
function handleSetCallingLineIdRestriction(message) {
|
|
|
|
let requestId = message.requestId;
|
|
|
|
let request = this.takeRequest(requestId);
|
|
|
|
if (!request) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!message.success) {
|
|
|
|
Services.DOMRequest.fireError(request, message.errorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Services.DOMRequest.fireSuccess(request, null);
|
|
|
|
},
|
|
|
|
|
2013-06-30 16:21:32 +04:00
|
|
|
handleSendCancelMMI: function handleSendCancelMMI(message) {
|
|
|
|
debug("handleSendCancelMMI " + JSON.stringify(message));
|
2012-11-08 02:13:48 +04:00
|
|
|
let request = this.takeRequest(message.requestId);
|
|
|
|
if (!request) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-30 16:21:32 +04:00
|
|
|
let success = message.success;
|
|
|
|
|
2013-06-30 21:01:02 +04:00
|
|
|
// We expect to have an IMEI at this point if the request was supposed
|
|
|
|
// to query for the IMEI, so getting a successful reply from the RIL
|
|
|
|
// without containing an actual IMEI number is considered an error.
|
|
|
|
if (message.mmiServiceCode === RIL.MMI_KS_SC_IMEI &&
|
|
|
|
!message.statusMessage) {
|
|
|
|
message.errorMsg = message.errorMsg ?
|
|
|
|
message.errorMsg : RIL.GECKO_ERROR_GENERIC_FAILURE;
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
2013-06-30 21:23:52 +04:00
|
|
|
// MMI query call forwarding options request returns a set of rules that
|
|
|
|
// will be exposed in the form of an array of nsIDOMMozMobileCFInfo
|
|
|
|
// instances.
|
|
|
|
if (message.mmiServiceCode === RIL.MMI_KS_SC_CALL_FORWARDING &&
|
|
|
|
message.additionalInformation) {
|
|
|
|
this._cfRulesToMobileCfInfo(message.additionalInformation);
|
|
|
|
}
|
|
|
|
|
2013-06-30 16:21:32 +04:00
|
|
|
let result = {
|
2013-06-30 21:01:02 +04:00
|
|
|
serviceCode: message.mmiServiceCode,
|
|
|
|
additionalInformation: message.additionalInformation
|
2013-06-30 16:21:32 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
if (success) {
|
2013-06-30 21:01:02 +04:00
|
|
|
result.statusMessage = message.statusMessage;
|
2013-06-30 16:21:32 +04:00
|
|
|
let mmiResult = new DOMMMIResult(result);
|
|
|
|
Services.DOMRequest.fireSuccess(request, mmiResult);
|
|
|
|
} else {
|
|
|
|
let mmiError = new this._window.DOMMMIError(result.serviceCode,
|
2013-06-30 21:01:02 +04:00
|
|
|
message.errorMsg,
|
|
|
|
null,
|
2013-06-30 16:21:32 +04:00
|
|
|
result.additionalInformation);
|
|
|
|
Services.DOMRequest.fireDetailedError(request, mmiError);
|
|
|
|
}
|
2012-11-08 02:13:48 +04:00
|
|
|
},
|
|
|
|
|
2012-08-17 07:46:34 +04:00
|
|
|
_getRandomId: function _getRandomId() {
|
|
|
|
return gUUIDGenerator.generateUUID().toString();
|
|
|
|
},
|
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
_deliverEvent: function _deliverEvent(listenerType, name, args) {
|
|
|
|
let thisListeners = this[listenerType];
|
|
|
|
if (!thisListeners) {
|
2012-04-24 19:44:42 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-06 13:53:31 +04:00
|
|
|
let listeners = thisListeners.slice();
|
2013-06-10 06:41:14 +04:00
|
|
|
for (let listener of listeners) {
|
2013-03-06 13:53:31 +04:00
|
|
|
if (thisListeners.indexOf(listener) == -1) {
|
2012-04-24 19:44:42 +04:00
|
|
|
continue;
|
|
|
|
}
|
2013-03-06 13:53:31 +04:00
|
|
|
let handler = listener[name];
|
2012-04-24 19:44:42 +04:00
|
|
|
if (typeof handler != "function") {
|
|
|
|
throw new Error("No handler for " + name);
|
|
|
|
}
|
|
|
|
try {
|
2013-03-06 13:53:31 +04:00
|
|
|
handler.apply(listener, args);
|
2012-04-24 19:44:42 +04:00
|
|
|
} catch (e) {
|
2013-03-06 13:53:31 +04:00
|
|
|
debug("listener for " + name + " threw an exception: " + e);
|
2012-04-24 19:44:42 +04:00
|
|
|
}
|
2012-04-20 01:33:25 +04:00
|
|
|
}
|
2012-10-31 17:58:39 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for guarding us again invalid reason values for call forwarding.
|
|
|
|
*/
|
2013-06-10 06:41:14 +04:00
|
|
|
_isValidCFReason: function _isValidCFReason(reason) {
|
|
|
|
switch (reason) {
|
|
|
|
case Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_REASON_UNCONDITIONAL:
|
|
|
|
case Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_REASON_MOBILE_BUSY:
|
|
|
|
case Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_REASON_NO_REPLY:
|
|
|
|
case Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_REASON_NOT_REACHABLE:
|
|
|
|
case Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_REASON_ALL_CALL_FORWARDING:
|
|
|
|
case Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_REASON_ALL_CONDITIONAL_CALL_FORWARDING:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
2012-10-31 17:58:39 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for guarding us again invalid action values for call forwarding.
|
|
|
|
*/
|
2013-06-10 06:41:14 +04:00
|
|
|
_isValidCFAction: function _isValidCFAction(action) {
|
|
|
|
switch (action) {
|
|
|
|
case Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_ACTION_DISABLE:
|
|
|
|
case Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_ACTION_ENABLE:
|
|
|
|
case Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_ACTION_REGISTRATION:
|
|
|
|
case Ci.nsIDOMMozMobileCFInfo.CALL_FORWARD_ACTION_ERASURE:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
2013-05-21 09:13:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for guarding us against invalid program values for call barring.
|
|
|
|
*/
|
|
|
|
_isValidCallBarringProgram: function _isValidCallBarringProgram(program) {
|
|
|
|
switch (program) {
|
|
|
|
case Ci.nsIDOMMozMobileConnection.CALL_BARRING_PROGRAM_ALL_OUTGOING:
|
|
|
|
case Ci.nsIDOMMozMobileConnection.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL:
|
|
|
|
case Ci.nsIDOMMozMobileConnection.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL_EXCEPT_HOME:
|
|
|
|
case Ci.nsIDOMMozMobileConnection.CALL_BARRING_PROGRAM_ALL_INCOMING:
|
|
|
|
case Ci.nsIDOMMozMobileConnection.CALL_BARRING_PROGRAM_INCOMING_ROAMING:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for guarding us against invalid option for call barring.
|
|
|
|
*/
|
|
|
|
_isValidCallBarringOption: function _isValidCallBarringOption(option) {
|
|
|
|
return (option
|
|
|
|
&& option.serviceClass != null
|
|
|
|
&& this._isValidCallBarringProgram(option.program));
|
2012-07-19 07:27:08 +04:00
|
|
|
}
|
2012-04-20 01:33:25 +04:00
|
|
|
};
|
|
|
|
|
2013-06-30 16:21:32 +04:00
|
|
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RILContentHelper,
|
|
|
|
DOMMMIError]);
|
2012-04-20 01:33:25 +04:00
|
|
|
|