2012-07-20 02:10:44 -07: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-19 14:33:25 -07:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
|
|
|
|
2012-04-11 21:01:49 -07:00
|
|
|
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
2013-03-05 18:51:40 -08:00
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
2012-04-19 14:33:25 -07:00
|
|
|
|
|
|
|
var RIL = {};
|
|
|
|
Cu.import("resource://gre/modules/ril_consts.js", RIL);
|
|
|
|
|
2013-10-24 01:14:59 -07:00
|
|
|
const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown";
|
|
|
|
|
|
|
|
const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
|
|
|
|
|
2013-10-24 01:15:06 -07:00
|
|
|
const kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
|
2013-10-24 01:14:59 -07:00
|
|
|
const kPrefRilDebuggingEnabled = "ril.debugging.enabled";
|
2013-10-24 01:15:06 -07:00
|
|
|
const kPrefVoicemailDefaultServiceId = "dom.voicemail.defaultServiceId";
|
2013-10-24 01:14:59 -07:00
|
|
|
|
|
|
|
let DEBUG;
|
|
|
|
function debug(s) {
|
|
|
|
dump("-*- RILContentHelper: " + s + "\n");
|
2013-06-09 19:41:14 -07:00
|
|
|
}
|
2012-04-19 14:33:25 -07:00
|
|
|
|
|
|
|
const RILCONTENTHELPER_CID =
|
|
|
|
Components.ID("{472816e1-1fd6-4405-996c-806f9ea68174}");
|
2013-08-11 23:59:17 -07:00
|
|
|
const GSMICCINFO_CID =
|
|
|
|
Components.ID("{e0fa785b-ad3f-46ed-bc56-fcb0d6fe4fa8}");
|
|
|
|
const CDMAICCINFO_CID =
|
|
|
|
Components.ID("{3d1f844f-9ec5-48fb-8907-aed2e5421709}");
|
2012-04-19 14:33:25 -07:00
|
|
|
const MOBILECONNECTIONINFO_CID =
|
|
|
|
Components.ID("{a35cfd39-2d93-4489-ac7d-396475dacb27}");
|
2012-06-12 14:05:50 -07:00
|
|
|
const MOBILENETWORKINFO_CID =
|
2012-06-01 14:10:39 -07:00
|
|
|
Components.ID("{a6c8416c-09b4-46d1-bf29-6520d677d085}");
|
2012-08-15 18:36:56 -07:00
|
|
|
const MOBILECELLINFO_CID =
|
2013-07-03 20:48:48 -07:00
|
|
|
Components.ID("{ae724dd4-ccaf-4006-98f1-6ce66a092464}");
|
2012-07-18 20:27:08 -07:00
|
|
|
const VOICEMAILSTATUS_CID=
|
|
|
|
Components.ID("{5467f2eb-e214-43ea-9b89-67711241ec8e}");
|
2012-10-31 06:58:39 -07:00
|
|
|
const MOBILECFINFO_CID=
|
|
|
|
Components.ID("{a4756f16-e728-4d9f-8baa-8464f894888a}");
|
2012-12-03 18:40:47 -08:00
|
|
|
const CELLBROADCASTMESSAGE_CID =
|
|
|
|
Components.ID("{29474c96-3099-486f-bb4a-3c9a1da834e4}");
|
|
|
|
const CELLBROADCASTETWSINFO_CID =
|
|
|
|
Components.ID("{59f176ee-9dcd-4005-9d47-f6be0cd08e17}");
|
2013-06-30 05:21:32 -07:00
|
|
|
const DOMMMIERROR_CID =
|
|
|
|
Components.ID("{6b204c42-7928-4e71-89ad-f90cd82aff96}");
|
2013-09-25 01:14:23 -07:00
|
|
|
const ICCCARDLOCKERROR_CID =
|
|
|
|
Components.ID("{08a71987-408c-44ff-93fd-177c0a85c3dd}");
|
2012-04-19 14:33:25 -07:00
|
|
|
|
|
|
|
const RIL_IPC_MSG_NAMES = [
|
|
|
|
"RIL:CardStateChanged",
|
2012-09-03 14:43:59 -07:00
|
|
|
"RIL:IccInfoChanged",
|
2012-04-19 14:33:25 -07:00
|
|
|
"RIL:VoiceInfoChanged",
|
|
|
|
"RIL:DataInfoChanged",
|
2012-06-01 14:10:39 -07:00
|
|
|
"RIL:GetAvailableNetworks",
|
2012-06-19 15:52:06 -07:00
|
|
|
"RIL:NetworkSelectionModeChanged",
|
|
|
|
"RIL:SelectNetwork",
|
|
|
|
"RIL:SelectNetworkAuto",
|
2013-08-14 05:50:36 -07:00
|
|
|
"RIL:EmergencyCbModeChanged",
|
2012-07-18 20:27:08 -07:00
|
|
|
"RIL:VoicemailNotification",
|
2012-11-22 20:09:01 -08:00
|
|
|
"RIL:VoicemailInfoChanged",
|
2012-08-15 09:49:12 -07: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 07:06:05 -07:00
|
|
|
"RIL:CardLockRetryCount",
|
2012-10-05 07:08:55 -07:00
|
|
|
"RIL:USSDReceived",
|
2013-08-13 05:14:13 -07:00
|
|
|
"RIL:SendMMI",
|
|
|
|
"RIL:CancelMMI",
|
2012-04-10 05:04:27 -07:00
|
|
|
"RIL:StkCommand",
|
2012-09-25 12:22:38 -07:00
|
|
|
"RIL:StkSessionEnd",
|
2012-10-31 06:58:39 -07:00
|
|
|
"RIL:DataError",
|
2013-10-29 21:04:21 -07:00
|
|
|
"RIL:SetCallForwardingOptions",
|
|
|
|
"RIL:GetCallForwardingOptions",
|
|
|
|
"RIL:SetCallBarringOptions",
|
|
|
|
"RIL:GetCallBarringOptions",
|
2013-08-26 18:59:17 -07:00
|
|
|
"RIL:ChangeCallBarringPassword",
|
2013-10-29 21:04:21 -07:00
|
|
|
"RIL:SetCallWaitingOptions",
|
|
|
|
"RIL:GetCallWaitingOptions",
|
2013-07-17 14:18:29 -07:00
|
|
|
"RIL:SetCallingLineIdRestriction",
|
|
|
|
"RIL:GetCallingLineIdRestriction",
|
2013-01-25 10:45:23 -08:00
|
|
|
"RIL:CellBroadcastReceived",
|
2013-02-25 01:27:26 -08:00
|
|
|
"RIL:CfStateChanged",
|
|
|
|
"RIL:IccOpenChannel",
|
|
|
|
"RIL:IccCloseChannel",
|
2013-03-05 18:12:23 -08:00
|
|
|
"RIL:IccExchangeAPDU",
|
2013-03-05 18:51:40 -08:00
|
|
|
"RIL:ReadIccContacts",
|
2013-06-10 00:47:03 -07:00
|
|
|
"RIL:UpdateIccContact",
|
|
|
|
"RIL:SetRoamingPreference",
|
2013-07-30 02:24:43 -07:00
|
|
|
"RIL:GetRoamingPreference",
|
2013-08-14 01:22:38 -07:00
|
|
|
"RIL:ExitEmergencyCbMode",
|
|
|
|
"RIL:SetVoicePrivacyMode",
|
2013-07-06 03:40:58 -07:00
|
|
|
"RIL:GetVoicePrivacyMode",
|
2013-08-27 05:25:54 -07:00
|
|
|
"RIL:OtaStatusChanged"
|
2012-04-19 14:33:25 -07:00
|
|
|
];
|
|
|
|
|
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
|
|
|
"@mozilla.org/childprocessmessagemanager;1",
|
2012-08-27 07:13:02 -07:00
|
|
|
"nsISyncMessageSender");
|
2012-04-19 14:33:25 -07:00
|
|
|
|
2013-10-01 20:13:56 -07:00
|
|
|
XPCOMUtils.defineLazyGetter(this, "gNumRadioInterfaces", function () {
|
|
|
|
let appInfo = Cc["@mozilla.org/xre/app-info;1"];
|
|
|
|
let isParentProcess = !appInfo || appInfo.getService(Ci.nsIXULRuntime)
|
|
|
|
.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
|
|
|
|
|
|
|
if (isParentProcess) {
|
|
|
|
let ril = Cc["@mozilla.org/ril;1"].getService(Ci.nsIRadioInterfaceLayer);
|
|
|
|
return ril.numRadioInterfaces;
|
|
|
|
}
|
|
|
|
|
2013-10-24 01:15:06 -07:00
|
|
|
return Services.prefs.getIntPref(kPrefRilNumRadioInterfaces);
|
2013-10-01 20:13:56 -07:00
|
|
|
});
|
|
|
|
|
2013-04-11 00:12:09 -07:00
|
|
|
function MobileIccCardLockResult(options) {
|
2012-09-09 20:54:49 -07:00
|
|
|
this.lockType = options.lockType;
|
|
|
|
this.enabled = options.enabled;
|
|
|
|
this.retryCount = options.retryCount;
|
|
|
|
this.success = options.success;
|
2013-06-09 19:41:14 -07:00
|
|
|
}
|
2013-04-11 00:12:09 -07:00
|
|
|
MobileIccCardLockResult.prototype = {
|
2012-09-09 20:54:49 -07: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 07:06:05 -07: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 04:14:39 -07:00
|
|
|
function IccInfo() {}
|
|
|
|
IccInfo.prototype = {
|
2013-08-11 23:59:17 -07:00
|
|
|
iccType: null,
|
2012-09-14 03:30:44 -07:00
|
|
|
iccid: null,
|
2013-02-24 19:47:27 -08:00
|
|
|
mcc: null,
|
|
|
|
mnc: null,
|
2012-10-22 23:54:51 -07:00
|
|
|
spn: null,
|
2013-08-11 23:59:17 -07:00
|
|
|
isDisplayNetworkNameRequired: null,
|
|
|
|
isDisplaySpnRequired: null
|
|
|
|
};
|
|
|
|
|
|
|
|
function GsmIccInfo() {}
|
|
|
|
GsmIccInfo.prototype = {
|
|
|
|
__proto__: IccInfo.prototype,
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozGsmIccInfo]),
|
|
|
|
classID: GSMICCINFO_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({
|
|
|
|
classID: GSMICCINFO_CID,
|
|
|
|
classDescription: "MozGsmIccInfo",
|
|
|
|
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
|
|
|
interfaces: [Ci.nsIDOMMozGsmIccInfo]
|
|
|
|
}),
|
|
|
|
|
|
|
|
// nsIDOMMozGsmIccInfo
|
|
|
|
|
2012-11-22 20:09:01 -08:00
|
|
|
msisdn: null
|
|
|
|
};
|
|
|
|
|
2013-08-11 23:59:17 -07:00
|
|
|
function CdmaIccInfo() {}
|
|
|
|
CdmaIccInfo.prototype = {
|
|
|
|
__proto__: IccInfo.prototype,
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozCdmaIccInfo]),
|
|
|
|
classID: CDMAICCINFO_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({
|
|
|
|
classID: CDMAICCINFO_CID,
|
|
|
|
classDescription: "MozCdmaIccInfo",
|
|
|
|
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
|
|
|
interfaces: [Ci.nsIDOMMozCdmaIccInfo]
|
|
|
|
}),
|
|
|
|
|
|
|
|
// nsIDOMMozCdmaIccInfo
|
|
|
|
|
2013-11-04 00:39:27 -08:00
|
|
|
mdn: null
|
2013-08-11 23:59:17 -07:00
|
|
|
};
|
|
|
|
|
2012-12-26 02:49:08 -08:00
|
|
|
function VoicemailInfo() {}
|
|
|
|
VoicemailInfo.prototype = {
|
2012-11-22 20:09:01 -08:00
|
|
|
number: null,
|
|
|
|
displayName: null
|
2012-09-03 14:43:59 -07:00
|
|
|
};
|
|
|
|
|
2012-04-19 14:33:25 -07: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 12:11:48 -07:00
|
|
|
state: null,
|
2012-04-19 14:33:25 -07:00
|
|
|
emergencyCallsOnly: false,
|
|
|
|
roaming: false,
|
2012-06-12 14:05:50 -07:00
|
|
|
network: null,
|
2012-08-15 18:36:56 -07:00
|
|
|
cell: null,
|
2012-04-19 14:33:25 -07:00
|
|
|
type: null,
|
|
|
|
signalStrength: null,
|
|
|
|
relSignalStrength: null
|
|
|
|
};
|
|
|
|
|
2012-06-12 14:05:50 -07:00
|
|
|
function MobileNetworkInfo() {}
|
|
|
|
MobileNetworkInfo.prototype = {
|
2012-09-09 20:54:49 -07:00
|
|
|
__exposedProps__ : {shortName: 'r',
|
|
|
|
longName: 'r',
|
|
|
|
mcc: 'r',
|
|
|
|
mnc: 'r',
|
|
|
|
state: 'r'},
|
|
|
|
|
2012-06-12 14:05:50 -07:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozMobileNetworkInfo]),
|
|
|
|
classID: MOBILENETWORKINFO_CID,
|
2012-06-01 14:10:39 -07:00
|
|
|
classInfo: XPCOMUtils.generateCI({
|
2012-06-12 14:05:50 -07:00
|
|
|
classID: MOBILENETWORKINFO_CID,
|
|
|
|
classDescription: "MobileNetworkInfo",
|
2012-06-01 14:10:39 -07:00
|
|
|
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
2012-06-12 14:05:50 -07:00
|
|
|
interfaces: [Ci.nsIDOMMozMobileNetworkInfo]
|
2012-06-01 14:10:39 -07:00
|
|
|
}),
|
|
|
|
|
2012-06-12 14:05:50 -07:00
|
|
|
// nsIDOMMozMobileNetworkInfo
|
2012-06-01 14:10:39 -07:00
|
|
|
|
|
|
|
shortName: null,
|
|
|
|
longName: null,
|
2013-02-24 19:47:27 -08:00
|
|
|
mcc: null,
|
|
|
|
mnc: null,
|
2012-06-01 14:10:39 -07:00
|
|
|
state: null
|
|
|
|
};
|
2012-04-19 14:33:25 -07:00
|
|
|
|
2012-08-15 18:36:56 -07: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
|
|
|
|
|
2013-07-03 20:48:48 -07:00
|
|
|
gsmLocationAreaCode: -1,
|
|
|
|
gsmCellId: -1,
|
|
|
|
cdmaBaseStationId: -1,
|
|
|
|
cdmaBaseStationLatitude: -2147483648,
|
|
|
|
cdmaBaseStationLongitude: -2147483648,
|
|
|
|
cdmaSystemId: -1,
|
|
|
|
cdmaNetworkId: -1
|
2012-08-15 18:36:56 -07:00
|
|
|
};
|
|
|
|
|
2013-10-29 02:40:44 -07:00
|
|
|
function VoicemailStatus(clientId) {
|
|
|
|
this.serviceId = clientId;
|
|
|
|
}
|
2012-07-18 20:27:08 -07:00
|
|
|
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
|
|
|
|
|
2013-10-29 02:40:44 -07:00
|
|
|
serviceId: -1,
|
2012-07-18 20:27:08 -07:00
|
|
|
hasMessages: false,
|
2013-10-29 02:40:44 -07:00
|
|
|
messageCount: -1, // Count unknown.
|
2012-07-18 20:27:08 -07:00
|
|
|
returnNumber: null,
|
|
|
|
returnMessage: null
|
|
|
|
};
|
|
|
|
|
2012-10-31 06:58:39 -07:00
|
|
|
function MobileCFInfo() {}
|
|
|
|
MobileCFInfo.prototype = {
|
|
|
|
__exposedProps__ : {active: 'r',
|
|
|
|
action: 'r',
|
|
|
|
reason: 'r',
|
|
|
|
number: 'r',
|
2012-12-03 01:30:59 -08:00
|
|
|
timeSeconds: 'r',
|
|
|
|
serviceClass: 'r'},
|
2012-10-31 06:58:39 -07: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 01:30:59 -08:00
|
|
|
timeSeconds: 0,
|
|
|
|
serviceClass: -1
|
2012-10-31 06:58:39 -07:00
|
|
|
};
|
|
|
|
|
2012-12-03 18:40:47 -08:00
|
|
|
function CellBroadcastMessage(pdu) {
|
2013-10-27 23:06:48 -07:00
|
|
|
this.gsmGeographicalScope = RIL.CB_GSM_GEOGRAPHICAL_SCOPE_NAMES[pdu.geographicalScope];
|
2012-12-03 18:40:47 -08:00
|
|
|
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);
|
|
|
|
}
|
2013-10-27 23:06:48 -07:00
|
|
|
|
|
|
|
this.cdmaServiceCategory = pdu.serviceCategory;
|
2012-12-03 18:40:47 -08:00
|
|
|
}
|
|
|
|
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
|
|
|
|
|
2013-10-27 23:06:48 -07:00
|
|
|
gsmGeographicalScope: null,
|
2012-12-03 18:40:47 -08:00
|
|
|
messageCode: null,
|
|
|
|
messageId: null,
|
|
|
|
language: null,
|
|
|
|
body: null,
|
|
|
|
messageClass: null,
|
|
|
|
timestamp: null,
|
|
|
|
|
2013-10-27 23:06:48 -07:00
|
|
|
etws: null,
|
|
|
|
cdmaServiceCategory: null
|
2012-12-03 18:40:47 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
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-10-29 21:04:21 -07:00
|
|
|
function CallBarringOptions(options) {
|
|
|
|
this.program = options.program;
|
|
|
|
this.enabled = options.enabled;
|
|
|
|
this.password = options.password;
|
|
|
|
this.serviceClass = options.serviceClass;
|
2013-05-20 22:13:37 -07:00
|
|
|
}
|
2013-10-29 21:04:21 -07:00
|
|
|
CallBarringOptions.prototype = {
|
2013-05-20 22:13:37 -07:00
|
|
|
__exposedProps__ : {program: 'r',
|
|
|
|
enabled: 'r',
|
|
|
|
password: 'r',
|
|
|
|
serviceClass: 'r'}
|
|
|
|
};
|
|
|
|
|
2013-06-30 05:21:32 -07:00
|
|
|
function DOMMMIResult(result) {
|
|
|
|
this.serviceCode = result.serviceCode;
|
|
|
|
this.statusMessage = result.statusMessage;
|
|
|
|
this.additionalInformation = result.additionalInformation;
|
2013-07-31 01:03:57 -07:00
|
|
|
}
|
2013-06-30 05:21:32 -07:00
|
|
|
DOMMMIResult.prototype = {
|
|
|
|
__exposedProps__: {serviceCode: 'r',
|
|
|
|
statusMessage: 'r',
|
|
|
|
additionalInformation: 'r'}
|
|
|
|
};
|
|
|
|
|
2013-07-17 14:18:29 -07:00
|
|
|
function DOMCLIRStatus(option) {
|
|
|
|
this.n = option.n;
|
|
|
|
this.m = option.m;
|
2013-07-31 01:03:57 -07:00
|
|
|
}
|
2013-07-17 14:18:29 -07:00
|
|
|
DOMCLIRStatus.prototype = {
|
|
|
|
__exposedProps__ : {n: 'r',
|
|
|
|
m: 'r'}
|
|
|
|
};
|
|
|
|
|
2013-06-30 05:21:32 -07:00
|
|
|
function DOMMMIError() {
|
2013-07-31 01:03:57 -07:00
|
|
|
}
|
2013-06-30 05:21:32 -07:00
|
|
|
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;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2013-09-25 01:14:23 -07:00
|
|
|
function IccCardLockError() {
|
|
|
|
}
|
|
|
|
IccCardLockError.prototype = {
|
|
|
|
classDescription: "IccCardLockError",
|
|
|
|
classID: ICCCARDLOCKERROR_CID,
|
|
|
|
contractID: "@mozilla.org/dom/icccardlock-error;1",
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]),
|
|
|
|
__init: function(lockType, errorMsg, retryCount) {
|
|
|
|
this.__DOM_IMPL__.init(errorMsg);
|
|
|
|
this.lockType = lockType;
|
|
|
|
this.retryCount = retryCount;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-04-19 14:33:25 -07:00
|
|
|
function RILContentHelper() {
|
2013-10-24 01:14:59 -07:00
|
|
|
this.updateDebugFlag();
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
this.numClients = gNumRadioInterfaces;
|
2013-11-08 02:38:16 -08:00
|
|
|
if (DEBUG) debug("Number of clients: " + this.numClients);
|
2013-10-29 21:04:21 -07:00
|
|
|
|
|
|
|
this.rilContexts = [];
|
2013-10-29 02:40:44 -07:00
|
|
|
this.voicemailInfos = [];
|
|
|
|
this.voicemailStatuses = [];
|
2013-10-29 21:04:21 -07:00
|
|
|
for (let clientId = 0; clientId < this.numClients; clientId++) {
|
|
|
|
this.rilContexts[clientId] = {
|
|
|
|
cardState: RIL.GECKO_CARDSTATE_UNKNOWN,
|
|
|
|
networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN,
|
|
|
|
iccInfo: null,
|
|
|
|
voiceConnectionInfo: new MobileConnectionInfo(),
|
|
|
|
dataConnectionInfo: new MobileConnectionInfo()
|
|
|
|
};
|
2013-10-29 02:40:44 -07:00
|
|
|
|
|
|
|
this.voicemailInfos[clientId] = new VoicemailInfo();
|
2013-10-29 21:04:21 -07:00
|
|
|
}
|
|
|
|
|
2013-10-24 01:15:06 -07:00
|
|
|
this.voicemailDefaultServiceId = this.getVoicemailDefaultServiceId();
|
2012-04-19 14:33:25 -07:00
|
|
|
|
2013-07-08 14:55:42 -07:00
|
|
|
this.initDOMRequestHelper(/* aWindow */ null, RIL_IPC_MSG_NAMES);
|
2013-06-09 19:41:14 -07:00
|
|
|
this._windowsMap = [];
|
2013-10-29 21:04:21 -07:00
|
|
|
this._selectingNetworks = [];
|
|
|
|
this._mobileConnectionListeners = [];
|
|
|
|
this._cellBroadcastListeners = [];
|
|
|
|
this._voicemailListeners = [];
|
|
|
|
this._iccListeners = [];
|
2013-10-24 01:14:59 -07:00
|
|
|
|
|
|
|
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
|
|
|
|
|
|
|
Services.prefs.addObserver(kPrefRilDebuggingEnabled, this, false);
|
2013-10-24 01:15:06 -07:00
|
|
|
Services.prefs.addObserver(kPrefVoicemailDefaultServiceId, this, false);
|
2012-04-19 14:33:25 -07:00
|
|
|
}
|
2012-06-12 14:05:50 -07:00
|
|
|
|
2012-04-19 14:33:25 -07:00
|
|
|
RILContentHelper.prototype = {
|
2012-04-11 21:01:49 -07:00
|
|
|
__proto__: DOMRequestIpcHelper.prototype,
|
|
|
|
|
2012-04-19 14:33:25 -07:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionProvider,
|
2013-03-06 01:53:31 -08:00
|
|
|
Ci.nsICellBroadcastProvider,
|
|
|
|
Ci.nsIVoicemailProvider,
|
|
|
|
Ci.nsIIccProvider,
|
2013-07-08 14:55:42 -07:00
|
|
|
Ci.nsIObserver,
|
|
|
|
Ci.nsISupportsWeakReference]),
|
2012-04-19 14:33:25 -07:00
|
|
|
classID: RILCONTENTHELPER_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({classID: RILCONTENTHELPER_CID,
|
|
|
|
classDescription: "RILContentHelper",
|
|
|
|
interfaces: [Ci.nsIMobileConnectionProvider,
|
2013-03-06 01:53:31 -08:00
|
|
|
Ci.nsICellBroadcastProvider,
|
|
|
|
Ci.nsIVoicemailProvider,
|
|
|
|
Ci.nsIIccProvider]}),
|
2012-04-19 14:33:25 -07:00
|
|
|
|
2013-10-24 01:14:59 -07:00
|
|
|
updateDebugFlag: function updateDebugFlag() {
|
|
|
|
try {
|
|
|
|
DEBUG = RIL.DEBUG_CONTENT_HELPER ||
|
|
|
|
Services.prefs.getBoolPref(kPrefRilDebuggingEnabled);
|
|
|
|
} catch (e) {}
|
|
|
|
},
|
|
|
|
|
2013-01-27 19:41:34 -08:00
|
|
|
// An utility function to copy objects.
|
|
|
|
updateInfo: function updateInfo(srcInfo, destInfo) {
|
2012-11-22 20:09:01 -08:00
|
|
|
for (let key in srcInfo) {
|
|
|
|
destInfo[key] = srcInfo[key];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-06-12 14:05:50 -07:00
|
|
|
updateConnectionInfo: function updateConnectionInfo(srcInfo, destInfo) {
|
|
|
|
for (let key in srcInfo) {
|
2012-08-15 18:36:56 -07:00
|
|
|
if ((key != "network") && (key != "cell")) {
|
2012-06-12 14:05:50 -07:00
|
|
|
destInfo[key] = srcInfo[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-15 18:36:56 -07:00
|
|
|
let srcCell = srcInfo.cell;
|
|
|
|
if (!srcCell) {
|
|
|
|
destInfo.cell = null;
|
|
|
|
} else {
|
|
|
|
let cell = destInfo.cell;
|
|
|
|
if (!cell) {
|
|
|
|
cell = destInfo.cell = new MobileCellInfo();
|
|
|
|
}
|
|
|
|
|
2013-07-03 20:48:48 -07:00
|
|
|
this.updateInfo(srcCell, cell);
|
2012-08-15 18:36:56 -07:00
|
|
|
}
|
|
|
|
|
2012-06-12 14:05:50 -07:00
|
|
|
let srcNetwork = srcInfo.network;
|
|
|
|
if (!srcNetwork) {
|
|
|
|
destInfo.network= null;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let network = destInfo.network;
|
|
|
|
if (!network) {
|
|
|
|
network = destInfo.network = new MobileNetworkInfo();
|
|
|
|
}
|
|
|
|
|
2013-01-27 19:41:34 -08:00
|
|
|
this.updateInfo(srcNetwork, network);
|
2013-08-11 23:59:17 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* We need to consider below cases when update iccInfo:
|
|
|
|
* 1. Should clear iccInfo to null if there is no card detected.
|
|
|
|
* 2. Need to create corresponding object based on iccType.
|
|
|
|
*/
|
2013-10-29 21:04:21 -07:00
|
|
|
updateIccInfo: function updateIccInfo(clientId, newInfo) {
|
|
|
|
let rilContext = this.rilContexts[clientId];
|
|
|
|
|
2013-08-11 23:59:17 -07:00
|
|
|
// Card is not detected, clear iccInfo to null.
|
|
|
|
if (!newInfo || !newInfo.iccType) {
|
2013-10-29 21:04:21 -07:00
|
|
|
if (rilContext.iccInfo) {
|
|
|
|
rilContext.iccInfo = null;
|
|
|
|
this._deliverEvent(clientId,
|
|
|
|
"_mobileConnectionListeners",
|
|
|
|
"notifyIccChanged",
|
|
|
|
null);
|
|
|
|
}
|
2013-08-11 23:59:17 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If iccInfo is null, new corresponding object based on iccType.
|
2013-10-29 21:04:21 -07:00
|
|
|
if (!rilContext.iccInfo) {
|
2013-08-11 23:59:17 -07:00
|
|
|
if (newInfo.iccType === "ruim" || newInfo.iccType === "csim") {
|
2013-10-29 21:04:21 -07:00
|
|
|
rilContext.iccInfo = new CdmaIccInfo();
|
2013-08-11 23:59:17 -07:00
|
|
|
} else {
|
2013-10-29 21:04:21 -07:00
|
|
|
rilContext.iccInfo = new GsmIccInfo();
|
2013-08-11 23:59:17 -07:00
|
|
|
}
|
|
|
|
}
|
2013-10-29 21:04:21 -07:00
|
|
|
let changed = (rilContext.iccInfo.iccid != newInfo.iccid) ?
|
|
|
|
true : false;
|
2013-08-11 23:59:17 -07:00
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
this.updateInfo(newInfo, rilContext.iccInfo);
|
|
|
|
|
|
|
|
// Deliver event after info is updated.
|
|
|
|
if (changed) {
|
|
|
|
this._deliverEvent(clientId,
|
|
|
|
"_mobileConnectionListeners",
|
|
|
|
"notifyIccChanged",
|
|
|
|
null);
|
|
|
|
}
|
2013-08-11 23:59:17 -07:00
|
|
|
},
|
2012-06-12 14:05:50 -07:00
|
|
|
|
2013-03-05 18:51:40 -08:00
|
|
|
_windowsMap: null,
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
rilContexts: null,
|
2013-01-07 23:57:34 -08:00
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
getRilContext: function getRilContext(clientId) {
|
|
|
|
// Update ril contexts by sending IPC message to chrome only when the first
|
2013-01-07 23:57:34 -08:00
|
|
|
// time we require it. The information will be updated by following info
|
|
|
|
// changed messages.
|
2013-10-29 21:04:21 -07:00
|
|
|
this.getRilContext = function getRilContext(clientId) {
|
|
|
|
return this.rilContexts[clientId];
|
2013-01-07 23:57:34 -08:00
|
|
|
};
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
for (let cId = 0; cId < this.numClients; cId++) {
|
|
|
|
let rilContext =
|
|
|
|
cpmm.sendSyncMessage("RIL:GetRilContext", {clientId: cId})[0];
|
|
|
|
if (!rilContext) {
|
2013-11-08 02:38:16 -08:00
|
|
|
if (DEBUG) debug("Received null rilContext from chrome process.");
|
2013-10-29 21:04:21 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
this.rilContexts[cId].cardState = rilContext.cardState;
|
|
|
|
this.rilContexts[cId].networkSelectionMode = rilContext.networkSelectionMode;
|
|
|
|
this.updateIccInfo(cId, rilContext.iccInfo);
|
|
|
|
this.updateConnectionInfo(rilContext.voice, this.rilContexts[cId].voiceConnectionInfo);
|
|
|
|
this.updateConnectionInfo(rilContext.data, this.rilContexts[cId].dataConnectionInfo);
|
2013-01-07 23:57:34 -08:00
|
|
|
}
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
return this.rilContexts[clientId];
|
2013-01-07 23:57:34 -08:00
|
|
|
},
|
|
|
|
|
2013-07-02 02:36:40 -07:00
|
|
|
/**
|
2013-10-29 21:04:21 -07:00
|
|
|
* nsIIccProvider
|
2013-07-02 02:36:40 -07:00
|
|
|
*/
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
getIccInfo: function getIccInfo(clientId) {
|
|
|
|
let context = this.getRilContext(clientId);
|
2013-05-12 19:18:19 -07:00
|
|
|
return context && context.iccInfo;
|
2013-01-07 23:57:34 -08:00
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
getCardState: function getIccInfo(clientId) {
|
|
|
|
let context = this.getRilContext(clientId);
|
2013-10-29 21:04:21 -07:00
|
|
|
return context && context.cardState;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nsIMobileConnectionProvider
|
|
|
|
*/
|
|
|
|
|
|
|
|
getVoiceConnectionInfo: function getVoiceConnectionInfo(clientId) {
|
|
|
|
let context = this.getRilContext(clientId);
|
2013-05-12 19:18:19 -07:00
|
|
|
return context && context.voiceConnectionInfo;
|
2013-01-07 23:57:34 -08:00
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
getDataConnectionInfo: function getDataConnectionInfo(clientId) {
|
|
|
|
let context = this.getRilContext(clientId);
|
2013-05-12 19:18:19 -07:00
|
|
|
return context && context.dataConnectionInfo;
|
2013-01-07 23:57:34 -08:00
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
getIccId: function getIccId(clientId) {
|
|
|
|
let context = this.getRilContext(clientId);
|
|
|
|
return context && context.iccInfo && context.iccInfo.iccid;
|
2013-01-07 23:57:34 -08:00
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
getNetworkSelectionMode: function getNetworkSelectionMode(clientId) {
|
|
|
|
let context = this.getRilContext(clientId);
|
2013-05-12 19:18:19 -07:00
|
|
|
return context && context.networkSelectionMode;
|
2013-03-28 19:56:07 -07:00
|
|
|
},
|
|
|
|
|
2012-06-19 15:52:06 -07:00
|
|
|
/**
|
2013-10-29 21:04:21 -07:00
|
|
|
* The networks that are currently trying to be selected (or "automatic").
|
|
|
|
* This helps ensure that only one network per client is selected at a time.
|
2012-06-19 15:52:06 -07:00
|
|
|
*/
|
2013-10-29 21:04:21 -07:00
|
|
|
_selectingNetworks: null,
|
2012-04-19 14:33:25 -07:00
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
getNetworks: function getNetworks(clientId, window) {
|
2012-06-01 14:10:39 -07: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 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:GetAvailableNetworks", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
2012-06-01 14:10:39 -07:00
|
|
|
return request;
|
2012-04-19 14:33:25 -07:00
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
selectNetwork: function selectNetwork(clientId, window, network) {
|
2012-06-19 15:52:06 -07:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
if (this._selectingNetworks[clientId]) {
|
|
|
|
throw new Error("Already selecting a network: " + this._selectingNetworks[clientId]);
|
2012-06-19 15:52:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!network) {
|
|
|
|
throw new Error("Invalid network provided: " + network);
|
|
|
|
}
|
|
|
|
|
2013-02-24 19:47:27 -08:00
|
|
|
if (isNaN(parseInt(network.mnc, 10))) {
|
|
|
|
throw new Error("Invalid network MNC: " + network.mnc);
|
2012-06-19 15:52:06 -07:00
|
|
|
}
|
|
|
|
|
2013-02-24 19:47:27 -08:00
|
|
|
if (isNaN(parseInt(network.mcc, 10))) {
|
|
|
|
throw new Error("Invalid network MCC: " + network.mcc);
|
2012-06-19 15:52:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
if (this.rilContexts[clientId].networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_MANUAL &&
|
|
|
|
this.rilContexts[clientId].voiceConnectionInfo.network === network) {
|
2012-06-19 15:52:06 -07:00
|
|
|
|
|
|
|
// Already manually selected this network, so schedule
|
|
|
|
// onsuccess to be fired on the next tick
|
|
|
|
this.dispatchFireRequestSuccess(requestId, null);
|
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
this._selectingNetworks[clientId] = network;
|
2012-06-19 15:52:06 -07:00
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:SelectNetwork", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
mnc: network.mnc,
|
|
|
|
mcc: network.mcc
|
|
|
|
}
|
2012-06-19 15:52:06 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
selectNetworkAutomatically: function selectNetworkAutomatically(clientId, window) {
|
2012-06-19 15:52:06 -07:00
|
|
|
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
if (this._selectingNetworks[clientId]) {
|
|
|
|
throw new Error("Already selecting a network: " + this._selectingNetworks[clientId]);
|
2012-06-19 15:52:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
if (this.rilContexts[clientId].networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_AUTOMATIC) {
|
2012-06-19 15:52:06 -07:00
|
|
|
// Already using automatic selection mode, so schedule
|
|
|
|
// onsuccess to be be fired on the next tick
|
|
|
|
this.dispatchFireRequestSuccess(requestId, null);
|
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
this._selectingNetworks[clientId] = "automatic";
|
2013-07-02 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:SelectNetworkAuto", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
2012-06-19 15:52:06 -07:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
setRoamingPreference: function setRoamingPreference(clientId, window, mode) {
|
2013-06-10 00:47:03 -07: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);
|
|
|
|
|
|
|
|
if (!mode) {
|
2013-09-04 05:30:44 -07:00
|
|
|
this.dispatchFireRequestError(requestId,
|
|
|
|
RIL.GECKO_ERROR_INVALID_PARAMETER);
|
2013-06-10 00:47:03 -07:00
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:SetRoamingPreference", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-06-10 00:47:03 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
mode: mode
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
getRoamingPreference: function getRoamingPreference(clientId, window) {
|
2013-06-10 00:47:03 -07: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);
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:GetRoamingPreference", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-06-10 00:47:03 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
setVoicePrivacyMode: function setVoicePrivacyMode(clientId, window, enabled) {
|
2013-08-14 01:22:38 -07: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);
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:SetVoicePrivacyMode", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-08-14 01:22:38 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
enabled: enabled
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
getVoicePrivacyMode: function getVoicePrivacyMode(clientId, window) {
|
2013-08-14 01:22:38 -07: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);
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:GetVoicePrivacyMode", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-08-14 01:22:38 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
getCardLockState: function getCardLockState(clientId, window, lockType) {
|
2012-04-11 21:01:49 -07: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-09-25 01:14:23 -07:00
|
|
|
this._windowsMap[requestId] = window;
|
|
|
|
|
2013-07-02 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:GetCardLockState", {
|
2013-09-30 03:46:02 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
lockType: lockType,
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
2012-04-11 21:01:49 -07:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
unlockCardLock: function unlockCardLock(clientId, window, info) {
|
2012-04-11 21:01:49 -07:00
|
|
|
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-09-25 01:14:23 -07:00
|
|
|
this._windowsMap[info.requestId] = window;
|
|
|
|
|
2013-07-02 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:UnlockCardLock", {
|
2013-09-30 03:46:02 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: info
|
|
|
|
});
|
2012-04-11 21:01:49 -07:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
setCardLock: function setCardLock(clientId, window, info) {
|
2012-04-11 21:01:49 -07:00
|
|
|
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-09-25 01:14:23 -07:00
|
|
|
this._windowsMap[info.requestId] = window;
|
|
|
|
|
2013-07-02 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:SetCardLock", {
|
2013-09-30 03:46:02 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: info
|
|
|
|
});
|
2012-04-11 21:01:49 -07:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
getCardLockRetryCount: function getCardLockRetryCount(clientId,
|
|
|
|
window,
|
|
|
|
lockType) {
|
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 07:06:05 -07: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);
|
|
|
|
cpmm.sendAsyncMessage("RIL:GetCardLockRetryCount", {
|
2013-09-30 03:46:02 -07:00
|
|
|
clientId: clientId,
|
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 07:06:05 -07:00
|
|
|
data: {
|
|
|
|
lockType: lockType,
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
sendMMI: function sendMMI(clientId, window, mmi) {
|
2013-11-08 02:38:16 -08:00
|
|
|
if (DEBUG) debug("Sending MMI " + mmi);
|
2012-06-09 14:07:18 -07:00
|
|
|
if (!window) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
2013-06-30 05:21:32 -07:00
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
2012-06-09 14:07:18 -07:00
|
|
|
}
|
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
2013-10-14 03:47:55 -07:00
|
|
|
// We need to save the global window to get the proper MMIError
|
|
|
|
// constructor once we get the reply from the parent process.
|
|
|
|
this._windowsMap[requestId] = window;
|
|
|
|
|
2013-07-02 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:SendMMI", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
mmi: mmi,
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
2012-06-09 14:07:18 -07:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
cancelMMI: function cancelMMI(clientId, window) {
|
2013-11-08 02:38:16 -08:00
|
|
|
if (DEBUG) debug("Cancel MMI");
|
2012-06-09 14:07:18 -07: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 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:CancelMMI", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
2012-06-09 14:07:18 -07:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
sendStkResponse: function sendStkResponse(clientId, window, command, response) {
|
2012-04-10 05:04:27 -07:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2012-08-29 15:09:12 -07:00
|
|
|
response.command = command;
|
2013-07-02 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:SendStkResponse", {
|
2013-09-30 03:46:02 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: response
|
|
|
|
});
|
2012-04-10 05:04:27 -07:00
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
sendStkMenuSelection: function sendStkMenuSelection(clientId,
|
|
|
|
window,
|
2012-04-10 05:04:27 -07:00
|
|
|
itemIdentifier,
|
|
|
|
helpRequested) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2013-07-02 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:SendStkMenuSelection", {
|
2013-09-30 03:46:02 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
itemIdentifier: itemIdentifier,
|
|
|
|
helpRequested: helpRequested
|
|
|
|
}
|
|
|
|
});
|
2012-04-10 05:04:27 -07:00
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
sendStkTimerExpiration: function sendStkTimerExpiration(clientId,
|
|
|
|
window,
|
2012-11-28 00:16:20 -08:00
|
|
|
timer) {
|
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2013-07-02 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:SendStkTimerExpiration", {
|
2013-09-30 03:46:02 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
timer: timer
|
|
|
|
}
|
|
|
|
});
|
2012-11-28 00:16:20 -08:00
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
sendStkEventDownload: function sendStkEventDownload(clientId, window, event) {
|
2012-09-10 19:34:36 -07:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2013-07-02 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:SendStkEventDownload", {
|
2013-09-30 03:46:02 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
event: event
|
|
|
|
}
|
|
|
|
});
|
2012-09-10 19:34:36 -07:00
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
iccOpenChannel: function iccOpenChannel(clientId, window, aid) {
|
2013-02-25 01:27:26 -08: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 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:IccOpenChannel", {
|
2013-09-30 03:46:02 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
aid: aid
|
|
|
|
}
|
|
|
|
});
|
2013-02-25 01:27:26 -08:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
iccExchangeAPDU: function iccExchangeAPDU(clientId, window, channel, apdu) {
|
2013-02-25 01:27:26 -08: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);
|
|
|
|
|
|
|
|
//Potentially you need serialization here and can't pass the jsval through
|
2013-07-02 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:IccExchangeAPDU", {
|
2013-09-30 03:46:02 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
channel: channel,
|
|
|
|
apdu: apdu
|
|
|
|
}
|
|
|
|
});
|
2013-02-25 01:27:26 -08:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
iccCloseChannel: function iccCloseChannel(clientId, window, channel) {
|
2013-02-25 01:27:26 -08: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 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:IccCloseChannel", {
|
2013-09-30 03:46:02 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
channel: channel
|
|
|
|
}
|
|
|
|
});
|
2013-02-25 01:27:26 -08:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
readContacts: function readContacts(clientId, window, contactType) {
|
2013-03-05 18:51:40 -08: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);
|
|
|
|
this._windowsMap[requestId] = window;
|
|
|
|
|
2013-07-02 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:ReadIccContacts", {
|
2013-09-30 03:46:02 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
contactType: contactType
|
|
|
|
}
|
|
|
|
});
|
2013-03-05 18:51:40 -08:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
updateContact: function updateContact(clientId, window, contactType, contact, pin2) {
|
2013-03-05 18:12:23 -08: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);
|
|
|
|
|
|
|
|
// Parsing nsDOMContact to Icc Contact format
|
|
|
|
let iccContact = {};
|
|
|
|
|
2013-08-09 01:00:38 -07:00
|
|
|
if (Array.isArray(contact.name) && contact.name[0]) {
|
2013-03-05 18:12:23 -08:00
|
|
|
iccContact.alphaId = contact.name[0];
|
|
|
|
}
|
|
|
|
|
2013-08-09 01:00:38 -07:00
|
|
|
if (Array.isArray(contact.tel)) {
|
|
|
|
iccContact.number = contact.tel[0] && contact.tel[0].value;
|
|
|
|
let telArray = contact.tel.slice(1);
|
|
|
|
let length = telArray.length;
|
|
|
|
if (length > 0) {
|
|
|
|
iccContact.anr = [];
|
|
|
|
}
|
|
|
|
for (let i = 0; i < telArray.length; i++) {
|
|
|
|
iccContact.anr.push(telArray[i].value);
|
|
|
|
}
|
2013-03-05 18:12:23 -08:00
|
|
|
}
|
|
|
|
|
2013-08-09 01:00:38 -07:00
|
|
|
if (Array.isArray(contact.email) && contact.email[0]) {
|
2013-04-29 23:53:47 -07:00
|
|
|
iccContact.email = contact.email[0].value;
|
|
|
|
}
|
|
|
|
|
2013-11-08 02:49:38 -08:00
|
|
|
iccContact.contactId = contact.id;
|
2013-09-12 14:52:07 -07:00
|
|
|
|
2013-07-02 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:UpdateIccContact", {
|
2013-09-30 03:46:02 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
contactType: contactType,
|
|
|
|
contact: iccContact,
|
|
|
|
pin2: pin2
|
|
|
|
}
|
|
|
|
});
|
2013-03-05 18:12:23 -08:00
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
getCallForwardingOption: function getCallForwardingOption(clientId, window, reason) {
|
2012-10-31 06:58:39 -07: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);
|
|
|
|
|
|
|
|
if (!this._isValidCFReason(reason)){
|
2013-09-04 05:30:44 -07:00
|
|
|
this.dispatchFireRequestError(requestId,
|
|
|
|
RIL.GECKO_ERROR_INVALID_PARAMETER);
|
2012-10-31 06:58:39 -07:00
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:GetCallForwardingOptions", {
|
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
reason: reason
|
|
|
|
}
|
2012-10-31 06:58:39 -07:00
|
|
|
});
|
|
|
|
|
2013-07-02 02:36:40 -07:00
|
|
|
return request;
|
2012-10-31 06:58:39 -07:00
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
setCallForwardingOption: function setCallForwardingOption(clientId, window, cfInfo) {
|
2012-10-31 06:58:39 -07: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);
|
|
|
|
|
|
|
|
if (!cfInfo ||
|
|
|
|
!this._isValidCFReason(cfInfo.reason) ||
|
|
|
|
!this._isValidCFAction(cfInfo.action)){
|
2013-09-04 05:30:44 -07:00
|
|
|
this.dispatchFireRequestError(requestId,
|
|
|
|
RIL.GECKO_ERROR_INVALID_PARAMETER);
|
2012-10-31 06:58:39 -07:00
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:SetCallForwardingOptions", {
|
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
active: cfInfo.active,
|
|
|
|
action: cfInfo.action,
|
|
|
|
reason: cfInfo.reason,
|
|
|
|
number: cfInfo.number,
|
|
|
|
timeSeconds: cfInfo.timeSeconds
|
|
|
|
}
|
2012-10-31 06:58:39 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
getCallBarringOption: function getCallBarringOption(clientId, window, option) {
|
2013-05-20 22:13:37 -07: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);
|
|
|
|
|
|
|
|
if (DEBUG) debug("getCallBarringOption: " + JSON.stringify(option));
|
2013-10-29 21:04:21 -07:00
|
|
|
if (!this._isValidCallBarringOptions(option)) {
|
2013-09-04 05:30:44 -07:00
|
|
|
this.dispatchFireRequestError(requestId,
|
|
|
|
RIL.GECKO_ERROR_INVALID_PARAMETER);
|
2013-05-20 22:13:37 -07:00
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:GetCallBarringOptions", {
|
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
program: option.program,
|
|
|
|
password: option.password,
|
|
|
|
serviceClass: option.serviceClass
|
|
|
|
}
|
2013-05-20 22:13:37 -07:00
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
setCallBarringOption: function setCallBarringOption(clientId, window, option) {
|
2013-05-20 22:13:37 -07: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);
|
|
|
|
|
|
|
|
if (DEBUG) debug("setCallBarringOption: " + JSON.stringify(option));
|
2013-10-29 21:04:21 -07:00
|
|
|
if (!this._isValidCallBarringOptions(option, true)) {
|
2013-09-04 05:30:44 -07:00
|
|
|
this.dispatchFireRequestError(requestId,
|
|
|
|
RIL.GECKO_ERROR_INVALID_PARAMETER);
|
2013-05-20 22:13:37 -07:00
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:SetCallBarringOptions", {
|
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
program: option.program,
|
|
|
|
enabled: option.enabled,
|
|
|
|
password: option.password,
|
|
|
|
serviceClass: option.serviceClass
|
|
|
|
}
|
2013-05-20 22:13:37 -07:00
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
changeCallBarringPassword: function changeCallBarringPassword(clientId, window, info) {
|
2013-08-26 18:59:17 -07: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);
|
|
|
|
|
|
|
|
// Checking valid PIN for supplementary services. See TS.22.004 clause 5.2.
|
|
|
|
if (info.pin == null || !info.pin.match(/^\d{4}$/) ||
|
|
|
|
info.newPin == null || !info.newPin.match(/^\d{4}$/)) {
|
|
|
|
this.dispatchFireRequestError(requestId, "InvalidPassword");
|
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DEBUG) debug("changeCallBarringPassword: " + JSON.stringify(info));
|
|
|
|
info.requestId = requestId;
|
|
|
|
cpmm.sendAsyncMessage("RIL:ChangeCallBarringPassword", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-08-26 18:59:17 -07:00
|
|
|
data: info
|
|
|
|
});
|
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
getCallWaitingOption: function getCallWaitingOption(clientId, window) {
|
2013-04-18 05:18:50 -07: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-10-29 21:04:21 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:GetCallWaitingOptions", {
|
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId
|
|
|
|
}
|
2013-04-18 05:18:50 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
setCallWaitingOption: function setCallWaitingOption(clientId, window, enabled) {
|
2013-04-18 05:18:50 -07: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-10-29 21:04:21 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:SetCallWaitingOptions", {
|
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
enabled: enabled
|
|
|
|
}
|
2013-04-18 05:18:50 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
getCallingLineIdRestriction: function getCallingLineIdRestriction(clientId, window) {
|
2013-07-17 14:18:29 -07: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);
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:GetCallingLineIdRestriction", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-07-17 14:18:29 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
|
|
|
setCallingLineIdRestriction:
|
2013-10-29 21:04:21 -07:00
|
|
|
function setCallingLineIdRestriction(clientId, window, clirMode) {
|
2013-07-17 14:18:29 -07: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);
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:SetCallingLineIdRestriction", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-07-17 14:18:29 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
clirMode: clirMode
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
exitEmergencyCbMode: function exitEmergencyCbMode(clientId, window) {
|
2013-08-14 05:50:36 -07: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);
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:ExitEmergencyCbMode", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-08-14 05:50:36 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-03-06 01:53:31 -08:00
|
|
|
_mobileConnectionListeners: null,
|
|
|
|
_cellBroadcastListeners: null,
|
|
|
|
_voicemailListeners: null,
|
|
|
|
_iccListeners: null,
|
2012-04-24 08:44:42 -07:00
|
|
|
|
2013-10-29 02:40:44 -07:00
|
|
|
voicemailInfos: null,
|
|
|
|
voicemailStatuses: null,
|
2012-12-26 02:49:08 -08:00
|
|
|
|
2013-10-24 01:15:06 -07:00
|
|
|
voicemailDefaultServiceId: 0,
|
|
|
|
getVoicemailDefaultServiceId: function getVoicemailDefaultServiceId() {
|
|
|
|
let id = Services.prefs.getIntPref(kPrefVoicemailDefaultServiceId);
|
|
|
|
|
|
|
|
if (id >= gNumRadioInterfaces || id < 0) {
|
|
|
|
id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return id;
|
|
|
|
},
|
|
|
|
|
2013-10-29 02:40:44 -07:00
|
|
|
getVoicemailInfo: function getVoicemailInfo(clientId) {
|
2012-12-26 02:49:08 -08:00
|
|
|
// Get voicemail infomation by IPC only on first time.
|
2013-10-29 02:40:44 -07:00
|
|
|
this.getVoicemailInfo = function getVoicemailInfo(clientId) {
|
|
|
|
return this.voicemailInfos[clientId];
|
2012-12-26 02:49:08 -08:00
|
|
|
};
|
|
|
|
|
2013-10-29 02:40:44 -07:00
|
|
|
for (let cId = 0; cId < gNumRadioInterfaces; cId++) {
|
|
|
|
let voicemailInfo =
|
|
|
|
cpmm.sendSyncMessage("RIL:GetVoicemailInfo", {clientId: cId})[0];
|
|
|
|
if (voicemailInfo) {
|
|
|
|
this.updateInfo(voicemailInfo, this.voicemailInfos[cId]);
|
|
|
|
}
|
2012-12-26 02:49:08 -08:00
|
|
|
}
|
|
|
|
|
2013-10-29 02:40:44 -07:00
|
|
|
return this.voicemailInfos[clientId];
|
2012-12-26 02:49:08 -08:00
|
|
|
},
|
2013-10-24 01:15:06 -07:00
|
|
|
|
2013-10-29 02:40:44 -07:00
|
|
|
getVoicemailNumber: function getVoicemailNumber(clientId) {
|
|
|
|
return this.getVoicemailInfo(clientId).number;
|
2012-11-22 20:09:01 -08:00
|
|
|
},
|
2013-10-24 01:15:06 -07:00
|
|
|
|
2013-10-29 02:40:44 -07:00
|
|
|
getVoicemailDisplayName: function getVoicemailDisplayName(clientId) {
|
|
|
|
return this.getVoicemailInfo(clientId).displayName;
|
|
|
|
},
|
|
|
|
|
|
|
|
getVoicemailStatus: function getVoicemailStatus(clientId) {
|
|
|
|
return this.voicemailStatuses[clientId];
|
2012-11-22 20:09:01 -08:00
|
|
|
},
|
2012-07-18 20:27:08 -07:00
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
registerListener: function registerListener(listenerType, clientId, listener) {
|
|
|
|
if (!this[listenerType]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let listeners = this[listenerType][clientId];
|
2013-03-06 01:53:31 -08:00
|
|
|
if (!listeners) {
|
2013-10-29 21:04:21 -07:00
|
|
|
listeners = this[listenerType][clientId] = [];
|
2012-07-18 20:27:08 -07:00
|
|
|
}
|
|
|
|
|
2013-03-06 01:53:31 -08:00
|
|
|
if (listeners.indexOf(listener) != -1) {
|
|
|
|
throw new Error("Already registered this listener!");
|
2012-04-24 08:44:42 -07:00
|
|
|
}
|
2012-07-18 20:27:08 -07:00
|
|
|
|
2013-03-06 01:53:31 -08:00
|
|
|
listeners.push(listener);
|
|
|
|
if (DEBUG) debug("Registered " + listenerType + " listener: " + listener);
|
2012-04-24 08:44:42 -07:00
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
unregisterListener: function unregisterListener(listenerType, clientId, listener) {
|
|
|
|
if (!this[listenerType]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let listeners = this[listenerType][clientId];
|
2013-03-06 01:53:31 -08:00
|
|
|
if (!listeners) {
|
2012-04-24 08:44:42 -07:00
|
|
|
return;
|
|
|
|
}
|
2012-07-18 20:27:08 -07:00
|
|
|
|
2013-03-06 01:53:31 -08:00
|
|
|
let index = listeners.indexOf(listener);
|
2012-04-24 08:44:42 -07:00
|
|
|
if (index != -1) {
|
2013-03-06 01:53:31 -08:00
|
|
|
listeners.splice(index, 1);
|
|
|
|
if (DEBUG) debug("Unregistered listener: " + listener);
|
2012-04-24 08:44:42 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
registerMobileConnectionMsg: function registerMobileConnectionMsg(clientId, listener) {
|
2013-11-08 02:38:16 -08:00
|
|
|
if (DEBUG) debug("Registering for mobile connection related messages");
|
2013-10-29 21:04:21 -07:00
|
|
|
this.registerListener("_mobileConnectionListeners", clientId, listener);
|
2013-03-06 01:53:31 -08:00
|
|
|
cpmm.sendAsyncMessage("RIL:RegisterMobileConnectionMsg");
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
unregisterMobileConnectionMsg: function unregisteMobileConnectionMsg(clientId, listener) {
|
|
|
|
this.unregisterListener("_mobileConnectionListeners", clientId, listener);
|
2013-03-06 01:53:31 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
registerVoicemailMsg: function registerVoicemailMsg(listener) {
|
2013-11-08 02:38:16 -08:00
|
|
|
if (DEBUG) debug("Registering for voicemail-related messages");
|
2013-10-29 02:40:44 -07:00
|
|
|
// To follow the listener registration scheme, we add a dummy clientId 0.
|
|
|
|
// All voicemail events are routed to listener for client id 0.
|
|
|
|
// See |handleVoicemailNotification|.
|
2013-10-29 21:04:21 -07:00
|
|
|
this.registerListener("_voicemailListeners", 0, listener);
|
2013-03-06 01:53:31 -08:00
|
|
|
cpmm.sendAsyncMessage("RIL:RegisterVoicemailMsg");
|
2012-12-03 18:40:47 -08:00
|
|
|
},
|
|
|
|
|
2013-03-06 01:53:31 -08:00
|
|
|
unregisterVoicemailMsg: function unregisteVoicemailMsg(listener) {
|
2013-10-29 02:40:44 -07:00
|
|
|
// To follow the listener unregistration scheme, we add a dummy clientId 0.
|
|
|
|
// All voicemail events are routed to listener for client id 0.
|
|
|
|
// See |handleVoicemailNotification|.
|
2013-10-29 21:04:21 -07:00
|
|
|
this.unregisterListener("_voicemailListeners", 0, listener);
|
2012-12-03 18:40:47 -08:00
|
|
|
},
|
|
|
|
|
2013-03-06 01:53:31 -08:00
|
|
|
registerCellBroadcastMsg: function registerCellBroadcastMsg(listener) {
|
2013-11-08 02:38:16 -08:00
|
|
|
if (DEBUG) debug("Registering for Cell Broadcast related messages");
|
2013-10-29 21:04:21 -07:00
|
|
|
//TODO: Bug 921326 - Cellbroadcast API: support multiple sim cards
|
|
|
|
this.registerListener("_cellBroadcastListeners", 0, listener);
|
2013-03-06 01:53:31 -08:00
|
|
|
cpmm.sendAsyncMessage("RIL:RegisterCellBroadcastMsg");
|
2012-10-09 03:07:11 -07:00
|
|
|
},
|
|
|
|
|
2013-03-06 01:53:31 -08:00
|
|
|
unregisterCellBroadcastMsg: function unregisterCellBroadcastMsg(listener) {
|
2013-10-29 21:04:21 -07:00
|
|
|
//TODO: Bug 921326 - Cellbroadcast API: support multiple sim cards
|
|
|
|
this.unregisterListener("_cellBroadcastListeners", 0, listener);
|
2012-10-09 03:07:11 -07:00
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
registerIccMsg: function registerIccMsg(clientId, listener) {
|
2013-11-08 02:38:16 -08:00
|
|
|
if (DEBUG) debug("Registering for ICC related messages");
|
2013-09-30 03:46:02 -07:00
|
|
|
this.registerListener("_iccListeners", clientId, listener);
|
2013-03-06 01:53:31 -08:00
|
|
|
cpmm.sendAsyncMessage("RIL:RegisterIccMsg");
|
2012-10-09 03:07:11 -07:00
|
|
|
},
|
|
|
|
|
2013-09-30 03:46:02 -07:00
|
|
|
unregisterIccMsg: function unregisterIccMsg(clientId, listener) {
|
|
|
|
this.unregisterListener("_iccListeners", clientId, listener);
|
2012-12-03 18:40:47 -08:00
|
|
|
},
|
|
|
|
|
2012-04-19 14:33:25 -07:00
|
|
|
// nsIObserver
|
|
|
|
|
|
|
|
observe: function observe(subject, topic, data) {
|
2013-10-24 01:14:59 -07:00
|
|
|
switch (topic) {
|
|
|
|
case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
|
|
|
|
if (data == kPrefRilDebuggingEnabled) {
|
|
|
|
this.updateDebugFlag();
|
2013-10-24 01:15:06 -07:00
|
|
|
} else if (data == kPrefVoicemailDefaultServiceId) {
|
|
|
|
this.voicemailDefaultServiceId = this.getVoicemailDefaultServiceId();
|
2013-10-24 01:14:59 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
|
|
|
|
this.destroyDOMRequestHelper();
|
|
|
|
Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
|
|
|
break;
|
2012-04-19 14:33:25 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-08-27 07:13:02 -07:00
|
|
|
// nsIMessageListener
|
2012-04-19 14:33:25 -07:00
|
|
|
|
2012-06-12 14:05:50 -07:00
|
|
|
fireRequestSuccess: function fireRequestSuccess(requestId, result) {
|
|
|
|
let request = this.takeRequest(requestId);
|
|
|
|
if (!request) {
|
|
|
|
if (DEBUG) {
|
2012-06-19 15:52:06 -07:00
|
|
|
debug("not firing success for id: " + requestId +
|
|
|
|
", result: " + JSON.stringify(result));
|
2012-06-12 14:05:50 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DEBUG) {
|
2012-06-19 15:52:06 -07:00
|
|
|
debug("fire request success, id: " + requestId +
|
|
|
|
", result: " + JSON.stringify(result));
|
2012-06-12 14:05:50 -07:00
|
|
|
}
|
|
|
|
Services.DOMRequest.fireSuccess(request, result);
|
|
|
|
},
|
|
|
|
|
2012-06-19 15:52:06 -07: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-12 14:05:50 -07:00
|
|
|
fireRequestError: function fireRequestError(requestId, error) {
|
|
|
|
let request = this.takeRequest(requestId);
|
|
|
|
if (!request) {
|
|
|
|
if (DEBUG) {
|
2012-06-19 15:52:06 -07:00
|
|
|
debug("not firing error for id: " + requestId +
|
|
|
|
", error: " + JSON.stringify(error));
|
2012-06-12 14:05:50 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DEBUG) {
|
2012-06-19 15:52:06 -07:00
|
|
|
debug("fire request error, id: " + requestId +
|
|
|
|
", result: " + JSON.stringify(error));
|
2012-06-12 14:05:50 -07:00
|
|
|
}
|
|
|
|
Services.DOMRequest.fireError(request, error);
|
|
|
|
},
|
|
|
|
|
2012-10-31 06:58:39 -07:00
|
|
|
dispatchFireRequestError: function dispatchFireRequestError(requestId, error) {
|
|
|
|
let currentThread = Services.tm.currentThread;
|
|
|
|
|
|
|
|
currentThread.dispatch(this.fireRequestError.bind(this, requestId, error),
|
|
|
|
Ci.nsIThread.DISPATCH_NORMAL);
|
|
|
|
},
|
|
|
|
|
2013-09-25 01:14:23 -07:00
|
|
|
fireRequestDetailedError: function fireRequestDetailedError(requestId, detailedError) {
|
|
|
|
let request = this.takeRequest(requestId);
|
|
|
|
if (!request) {
|
|
|
|
if (DEBUG) {
|
|
|
|
debug("not firing detailed error for id: " + requestId +
|
|
|
|
", detailedError: " + JSON.stringify(detailedError));
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Services.DOMRequest.fireDetailedError(request, detailedError);
|
|
|
|
},
|
|
|
|
|
2012-04-19 14:33:25 -07:00
|
|
|
receiveMessage: function receiveMessage(msg) {
|
2012-04-11 21:01:49 -07:00
|
|
|
let request;
|
2013-11-08 02:38:16 -08:00
|
|
|
if (DEBUG) {
|
|
|
|
debug("Received message '" + msg.name + "': " + JSON.stringify(msg.json));
|
|
|
|
}
|
2013-09-29 17:56:00 -07:00
|
|
|
|
|
|
|
let data = msg.json.data;
|
2013-10-29 21:04:21 -07:00
|
|
|
let clientId = msg.json.clientId;
|
2012-04-19 14:33:25 -07:00
|
|
|
switch (msg.name) {
|
2013-09-29 17:56:00 -07:00
|
|
|
case "RIL:CardStateChanged":
|
2013-10-29 21:04:21 -07:00
|
|
|
if (this.rilContexts[clientId].cardState != data.cardState) {
|
|
|
|
this.rilContexts[clientId].cardState = data.cardState;
|
|
|
|
this._deliverEvent(clientId,
|
|
|
|
"_iccListeners",
|
2013-03-06 01:53:31 -08:00
|
|
|
"notifyCardStateChanged",
|
|
|
|
null);
|
2012-04-19 14:33:25 -07:00
|
|
|
}
|
|
|
|
break;
|
2012-09-03 14:43:59 -07:00
|
|
|
case "RIL:IccInfoChanged":
|
2013-10-29 21:04:21 -07:00
|
|
|
this.updateIccInfo(clientId, data);
|
|
|
|
this._deliverEvent(clientId,
|
|
|
|
"_iccListeners",
|
|
|
|
"notifyIccInfoChanged",
|
|
|
|
null);
|
2012-09-03 14:43:59 -07:00
|
|
|
break;
|
2012-04-19 14:33:25 -07:00
|
|
|
case "RIL:VoiceInfoChanged":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.updateConnectionInfo(data,
|
2013-10-29 21:04:21 -07:00
|
|
|
this.rilContexts[clientId].voiceConnectionInfo);
|
|
|
|
this._deliverEvent(clientId,
|
|
|
|
"_mobileConnectionListeners",
|
2013-03-06 01:53:31 -08:00
|
|
|
"notifyVoiceChanged",
|
|
|
|
null);
|
2012-04-19 14:33:25 -07:00
|
|
|
break;
|
|
|
|
case "RIL:DataInfoChanged":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.updateConnectionInfo(data,
|
2013-10-29 21:04:21 -07:00
|
|
|
this.rilContexts[clientId].dataConnectionInfo);
|
|
|
|
this._deliverEvent(clientId,
|
|
|
|
"_mobileConnectionListeners",
|
2013-03-06 01:53:31 -08:00
|
|
|
"notifyDataChanged",
|
|
|
|
null);
|
2012-04-19 14:33:25 -07:00
|
|
|
break;
|
2013-08-27 05:25:54 -07:00
|
|
|
case "RIL:OtaStatusChanged":
|
2013-10-29 21:04:21 -07:00
|
|
|
this._deliverEvent(clientId,
|
|
|
|
"_mobileConnectionListeners",
|
2013-08-27 05:25:54 -07:00
|
|
|
"notifyOtaStatusChanged",
|
2013-09-29 17:56:00 -07:00
|
|
|
[data]);
|
2013-08-27 05:25:54 -07:00
|
|
|
break;
|
2012-06-01 14:10:39 -07:00
|
|
|
case "RIL:GetAvailableNetworks":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleGetAvailableNetworks(data);
|
2012-06-01 14:10:39 -07:00
|
|
|
break;
|
2012-06-19 15:52:06 -07:00
|
|
|
case "RIL:NetworkSelectionModeChanged":
|
2013-10-29 21:04:21 -07:00
|
|
|
this.rilContexts[clientId].networkSelectionMode = data.mode;
|
2012-06-19 15:52:06 -07:00
|
|
|
break;
|
|
|
|
case "RIL:SelectNetwork":
|
2013-10-29 21:04:21 -07:00
|
|
|
this.handleSelectNetwork(clientId, data,
|
2012-06-19 15:52:06 -07:00
|
|
|
RIL.GECKO_NETWORK_SELECTION_MANUAL);
|
|
|
|
break;
|
|
|
|
case "RIL:SelectNetworkAuto":
|
2013-10-29 21:04:21 -07:00
|
|
|
this.handleSelectNetwork(clientId, data,
|
2012-06-19 15:52:06 -07:00
|
|
|
RIL.GECKO_NETWORK_SELECTION_AUTOMATIC);
|
|
|
|
break;
|
2012-07-18 20:27:08 -07:00
|
|
|
case "RIL:VoicemailNotification":
|
2013-10-29 21:04:21 -07:00
|
|
|
this.handleVoicemailNotification(clientId, data);
|
2012-06-01 14:10:39 -07:00
|
|
|
break;
|
2012-11-22 20:09:01 -08:00
|
|
|
case "RIL:VoicemailInfoChanged":
|
2013-10-29 02:40:44 -07:00
|
|
|
this.updateInfo(data, this.voicemailInfos[clientId]);
|
2012-07-20 17:19:38 -07:00
|
|
|
break;
|
2013-09-25 01:14:23 -07:00
|
|
|
case "RIL:CardLockResult": {
|
|
|
|
let requestId = data.requestId;
|
|
|
|
let requestWindow = this._windowsMap[requestId];
|
|
|
|
delete this._windowsMap[requestId];
|
|
|
|
|
2013-09-29 17:56:00 -07:00
|
|
|
if (data.success) {
|
|
|
|
let result = new MobileIccCardLockResult(data);
|
2013-09-25 01:14:23 -07:00
|
|
|
this.fireRequestSuccess(requestId, result);
|
2012-08-15 09:49:12 -07:00
|
|
|
} else {
|
2013-09-29 17:56:00 -07:00
|
|
|
if (data.rilMessageType == "iccSetCardLock" ||
|
|
|
|
data.rilMessageType == "iccUnlockCardLock") {
|
2013-09-25 01:14:23 -07:00
|
|
|
let cardLockError = new requestWindow.IccCardLockError(data.lockType,
|
|
|
|
data.errorMsg,
|
|
|
|
data.retryCount);
|
|
|
|
this.fireRequestDetailedError(requestId, cardLockError);
|
|
|
|
} else {
|
|
|
|
this.fireRequestError(requestId, data.errorMsg);
|
2012-10-02 23:51:53 -07:00
|
|
|
}
|
2012-08-15 09:49:12 -07:00
|
|
|
}
|
2012-04-11 21:01:49 -07:00
|
|
|
break;
|
2013-09-25 01:14:23 -07:00
|
|
|
}
|
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 07:06:05 -07:00
|
|
|
case "RIL:CardLockRetryCount":
|
2013-09-29 17:56:00 -07:00
|
|
|
if (data.success) {
|
|
|
|
let result = new MobileIccCardLockRetryCount(data);
|
|
|
|
this.fireRequestSuccess(data.requestId, result);
|
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 07:06:05 -07:00
|
|
|
} else {
|
2013-09-29 17:56:00 -07:00
|
|
|
this.fireRequestError(data.requestId, data.errorMsg);
|
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 07:06:05 -07:00
|
|
|
}
|
|
|
|
break;
|
2013-09-29 17:56:00 -07:00
|
|
|
case "RIL:USSDReceived":
|
2013-10-29 21:04:21 -07:00
|
|
|
this._deliverEvent(clientId,
|
|
|
|
"_mobileConnectionListeners",
|
2013-03-06 01:53:31 -08:00
|
|
|
"notifyUssdReceived",
|
2013-07-02 02:36:40 -07:00
|
|
|
[data.message, data.sessionEnded]);
|
2012-06-09 14:07:18 -07:00
|
|
|
break;
|
2013-08-13 05:14:13 -07:00
|
|
|
case "RIL:SendMMI":
|
|
|
|
case "RIL:CancelMMI":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleSendCancelMMI(data);
|
2012-06-09 14:07:18 -07:00
|
|
|
break;
|
2012-04-10 05:04:27 -07:00
|
|
|
case "RIL:StkCommand":
|
2013-10-29 21:04:21 -07:00
|
|
|
this._deliverEvent(clientId, "_iccListeners", "notifyStkCommand",
|
2013-09-29 17:56:00 -07:00
|
|
|
[JSON.stringify(data)]);
|
2012-04-10 05:04:27 -07:00
|
|
|
break;
|
|
|
|
case "RIL:StkSessionEnd":
|
2013-10-29 21:04:21 -07:00
|
|
|
this._deliverEvent(clientId, "_iccListeners", "notifyStkSessionEnd", null);
|
2012-09-25 12:22:38 -07:00
|
|
|
break;
|
2013-02-25 01:27:26 -08:00
|
|
|
case "RIL:IccOpenChannel":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleSimpleRequest(data.requestId, data.errorMsg,
|
|
|
|
data.channel);
|
2013-02-25 01:27:26 -08:00
|
|
|
break;
|
|
|
|
case "RIL:IccCloseChannel":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleSimpleRequest(data.requestId, data.errorMsg, null);
|
2013-02-25 01:27:26 -08:00
|
|
|
break;
|
|
|
|
case "RIL:IccExchangeAPDU":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleIccExchangeAPDU(data);
|
2013-02-25 01:27:26 -08:00
|
|
|
break;
|
2013-03-05 18:51:40 -08:00
|
|
|
case "RIL:ReadIccContacts":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleReadIccContacts(data);
|
2013-03-05 18:51:40 -08:00
|
|
|
break;
|
2013-03-24 20:09:01 -07:00
|
|
|
case "RIL:UpdateIccContact":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleSimpleRequest(data.requestId, data.errorMsg, null);
|
2013-03-05 18:12:23 -08:00
|
|
|
break;
|
2013-09-29 17:56:00 -07:00
|
|
|
case "RIL:DataError":
|
2013-10-29 21:04:21 -07:00
|
|
|
this.updateConnectionInfo(data, this.rilContexts[clientId].dataConnectionInfo);
|
|
|
|
this._deliverEvent(clientId, "_mobileConnectionListeners", "notifyDataError",
|
2013-07-02 02:36:40 -07:00
|
|
|
[data.errorMsg]);
|
2012-09-25 12:22:38 -07:00
|
|
|
break;
|
2013-10-29 21:04:21 -07:00
|
|
|
case "RIL:GetCallForwardingOptions":
|
|
|
|
this.handleGetCallForwardingOptions(data);
|
2012-10-31 06:58:39 -07:00
|
|
|
break;
|
2013-10-29 21:04:21 -07:00
|
|
|
case "RIL:SetCallForwardingOptions":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleSimpleRequest(data.requestId, data.errorMsg, null);
|
2012-10-31 06:58:39 -07:00
|
|
|
break;
|
2013-10-29 21:04:21 -07:00
|
|
|
case "RIL:GetCallBarringOptions":
|
|
|
|
this.handleGetCallBarringOptions(data);
|
2013-05-20 22:13:37 -07:00
|
|
|
break;
|
2013-10-29 21:04:21 -07:00
|
|
|
case "RIL:SetCallBarringOptions":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleSimpleRequest(data.requestId, data.errorMsg, null);
|
2013-05-20 22:13:37 -07:00
|
|
|
break;
|
2013-08-26 18:59:17 -07:00
|
|
|
case "RIL:ChangeCallBarringPassword":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleSimpleRequest(data.requestId, data.errorMsg, null);
|
2013-08-26 18:59:17 -07:00
|
|
|
break;
|
2013-10-29 21:04:21 -07:00
|
|
|
case "RIL:GetCallWaitingOptions":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleSimpleRequest(data.requestId, data.errorMsg,
|
|
|
|
data.enabled);
|
2013-04-18 05:18:50 -07:00
|
|
|
break;
|
2013-10-29 21:04:21 -07:00
|
|
|
case "RIL:SetCallWaitingOptions":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleSimpleRequest(data.requestId, data.errorMsg, null);
|
2013-04-18 05:18:50 -07:00
|
|
|
break;
|
2013-09-29 17:56:00 -07:00
|
|
|
case "RIL:CfStateChanged":
|
2013-10-29 21:04:21 -07:00
|
|
|
this._deliverEvent(clientId,
|
|
|
|
"_mobileConnectionListeners",
|
2013-03-06 01:53:31 -08:00
|
|
|
"notifyCFStateChange",
|
2013-07-02 02:36:40 -07:00
|
|
|
[data.success, data.action,
|
|
|
|
data.reason, data.number,
|
|
|
|
data.timeSeconds, data.serviceClass]);
|
2013-01-25 10:45:23 -08:00
|
|
|
break;
|
2013-07-17 14:18:29 -07:00
|
|
|
case "RIL:GetCallingLineIdRestriction":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleGetCallingLineIdRestriction(data);
|
2013-07-17 14:18:29 -07:00
|
|
|
break;
|
|
|
|
case "RIL:SetCallingLineIdRestriction":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleSimpleRequest(data.requestId, data.errorMsg, null);
|
2013-07-17 14:18:29 -07:00
|
|
|
break;
|
2013-07-02 02:36:40 -07:00
|
|
|
case "RIL:CellBroadcastReceived": {
|
2013-09-29 17:56:00 -07:00
|
|
|
let message = new CellBroadcastMessage(data);
|
2013-10-29 21:04:21 -07:00
|
|
|
this._deliverEvent(clientId,
|
|
|
|
"_cellBroadcastListeners",
|
2013-03-06 01:53:31 -08:00
|
|
|
"notifyMessageReceived",
|
|
|
|
[message]);
|
2012-12-03 18:40:47 -08:00
|
|
|
break;
|
2013-07-02 02:36:40 -07:00
|
|
|
}
|
2013-06-10 00:47:03 -07:00
|
|
|
case "RIL:SetRoamingPreference":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleSimpleRequest(data.requestId, data.errorMsg, null);
|
2013-06-10 00:47:03 -07:00
|
|
|
break;
|
|
|
|
case "RIL:GetRoamingPreference":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleSimpleRequest(data.requestId, data.errorMsg,
|
|
|
|
data.mode);
|
2013-06-10 00:47:03 -07:00
|
|
|
break;
|
2013-08-14 05:50:36 -07:00
|
|
|
case "RIL:ExitEmergencyCbMode":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleExitEmergencyCbMode(data);
|
2013-08-14 05:50:36 -07:00
|
|
|
break;
|
|
|
|
case "RIL:EmergencyCbModeChanged":
|
2013-10-29 21:04:21 -07:00
|
|
|
this._deliverEvent(clientId,
|
|
|
|
"_mobileConnectionListeners",
|
2013-08-14 05:50:36 -07:00
|
|
|
"notifyEmergencyCbModeChanged",
|
|
|
|
[data.active, data.timeoutMs]);
|
|
|
|
break;
|
2013-08-14 01:22:38 -07:00
|
|
|
case "RIL:SetVoicePrivacyMode":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleSimpleRequest(data.requestId, data.errorMsg, null);
|
2013-08-14 01:22:38 -07:00
|
|
|
break;
|
|
|
|
case "RIL:GetVoicePrivacyMode":
|
2013-09-29 17:56:00 -07:00
|
|
|
this.handleSimpleRequest(data.requestId, data.errorMsg,
|
|
|
|
data.enabled);
|
2013-08-14 01:22:38 -07:00
|
|
|
break;
|
2012-04-24 08:44:42 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-07-31 00:39:52 -07:00
|
|
|
handleSimpleRequest: function handleSimpleRequest(requestId, errorMsg, result) {
|
|
|
|
if (errorMsg) {
|
|
|
|
this.fireRequestError(requestId, errorMsg);
|
|
|
|
} else {
|
|
|
|
this.fireRequestSuccess(requestId, result);
|
2012-06-01 14:10:39 -07:00
|
|
|
}
|
2013-07-31 00:39:52 -07:00
|
|
|
},
|
2012-06-01 14:10:39 -07:00
|
|
|
|
2013-07-31 00:39:52 -07:00
|
|
|
handleGetAvailableNetworks: function handleGetAvailableNetworks(message) {
|
2013-11-08 02:38:16 -08:00
|
|
|
if (DEBUG) debug("handleGetAvailableNetworks: " + JSON.stringify(message));
|
2013-03-07 02:35:57 -08:00
|
|
|
if (message.errorMsg) {
|
2013-11-08 02:38:16 -08:00
|
|
|
if (DEBUG) {
|
|
|
|
debug("Received error from getAvailableNetworks: " + message.errorMsg);
|
|
|
|
}
|
2013-07-31 00:39:52 -07:00
|
|
|
this.fireRequestError(message.requestId, message.errorMsg);
|
2012-06-01 14:10:39 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let networks = message.networks;
|
|
|
|
for (let i = 0; i < networks.length; i++) {
|
|
|
|
let network = networks[i];
|
2012-06-12 14:05:50 -07:00
|
|
|
let info = new MobileNetworkInfo();
|
2013-01-27 19:41:34 -08:00
|
|
|
this.updateInfo(network, info);
|
2012-06-01 14:10:39 -07:00
|
|
|
networks[i] = info;
|
|
|
|
}
|
|
|
|
|
2013-07-31 00:39:52 -07:00
|
|
|
this.fireRequestSuccess(message.requestId, networks);
|
2012-06-01 14:10:39 -07:00
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
handleSelectNetwork: function handleSelectNetwork(clientId, message, mode) {
|
|
|
|
this._selectingNetworks[clientId] = null;
|
|
|
|
this.rilContexts[clientId].networkSelectionMode = mode;
|
2012-06-19 15:52:06 -07:00
|
|
|
|
2013-03-07 02:35:57 -08:00
|
|
|
if (message.errorMsg) {
|
|
|
|
this.fireRequestError(message.requestId, message.errorMsg);
|
2012-06-19 15:52:06 -07:00
|
|
|
} else {
|
|
|
|
this.fireRequestSuccess(message.requestId, null);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-02-25 01:27:26 -08:00
|
|
|
handleIccExchangeAPDU: function handleIccExchangeAPDU(message) {
|
2013-03-07 02:35:57 -08:00
|
|
|
if (message.errorMsg) {
|
|
|
|
this.fireRequestError(message.requestId, message.errorMsg);
|
2013-02-25 01:27:26 -08:00
|
|
|
} else {
|
|
|
|
var result = [message.sw1, message.sw2, message.simResponse];
|
|
|
|
this.fireRequestSuccess(message.requestId, result);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-03-05 18:51:40 -08: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 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]});
|
|
|
|
}
|
|
|
|
|
2013-10-17 14:29:56 -07:00
|
|
|
let contact = new window.mozContact(prop);
|
2013-11-08 02:49:38 -08:00
|
|
|
contact.id = c.contactId;
|
2013-03-05 18:51:40 -08:00
|
|
|
return contact;
|
|
|
|
});
|
|
|
|
|
2013-10-21 23:57:44 -07:00
|
|
|
this.fireRequestSuccess(message.requestId, result);
|
2013-03-05 18:51:40 -08:00
|
|
|
},
|
|
|
|
|
2013-10-29 02:40:44 -07:00
|
|
|
handleVoicemailNotification: function handleVoicemailNotification(clientId,
|
|
|
|
message) {
|
2012-07-18 20:27:08 -07:00
|
|
|
let changed = false;
|
2013-10-29 02:40:44 -07:00
|
|
|
if (!this.voicemailStatuses[clientId]) {
|
|
|
|
this.voicemailStatuses[clientId] = new VoicemailStatus(clientId);
|
2012-07-18 20:27:08 -07:00
|
|
|
}
|
|
|
|
|
2013-10-29 02:40:44 -07:00
|
|
|
let voicemailStatus = this.voicemailStatuses[clientId];
|
|
|
|
if (voicemailStatus.hasMessages != message.active) {
|
2012-07-18 20:27:08 -07:00
|
|
|
changed = true;
|
2013-10-29 02:40:44 -07:00
|
|
|
voicemailStatus.hasMessages = message.active;
|
2012-07-18 20:27:08 -07:00
|
|
|
}
|
|
|
|
|
2013-10-29 02:40:44 -07:00
|
|
|
if (voicemailStatus.messageCount != message.msgCount) {
|
2012-07-18 20:27:08 -07:00
|
|
|
changed = true;
|
2013-10-29 02:40:44 -07:00
|
|
|
voicemailStatus.messageCount = message.msgCount;
|
2013-05-02 15:22:25 -07:00
|
|
|
} else if (message.msgCount == -1) {
|
|
|
|
// For MWI using DCS the message count is not available
|
|
|
|
changed = true;
|
2012-07-18 20:27:08 -07:00
|
|
|
}
|
|
|
|
|
2013-10-29 02:40:44 -07:00
|
|
|
if (voicemailStatus.returnNumber != message.returnNumber) {
|
2012-07-18 20:27:08 -07:00
|
|
|
changed = true;
|
2013-10-29 02:40:44 -07:00
|
|
|
voicemailStatus.returnNumber = message.returnNumber;
|
2012-07-18 20:27:08 -07:00
|
|
|
}
|
|
|
|
|
2013-10-29 02:40:44 -07:00
|
|
|
if (voicemailStatus.returnMessage != message.returnMessage) {
|
2012-07-18 20:27:08 -07:00
|
|
|
changed = true;
|
2013-10-29 02:40:44 -07:00
|
|
|
voicemailStatus.returnMessage = message.returnMessage;
|
2012-07-18 20:27:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (changed) {
|
2013-10-29 02:40:44 -07:00
|
|
|
// To follow the event delivering scheme, we add a dummy clientId 0.
|
|
|
|
// All voicemail events are routed to listener for client id 0.
|
|
|
|
this._deliverEvent(0,
|
2013-10-29 21:04:21 -07:00
|
|
|
"_voicemailListeners",
|
2013-08-13 19:23:58 -07:00
|
|
|
"notifyStatusChanged",
|
2013-10-29 02:40:44 -07:00
|
|
|
[voicemailStatus]);
|
2012-07-18 20:27:08 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-11-07 14:13:48 -08:00
|
|
|
_cfRulesToMobileCfInfo: function _cfRulesToMobileCfInfo(rules) {
|
|
|
|
for (let i = 0; i < rules.length; i++) {
|
|
|
|
let rule = rules[i];
|
|
|
|
let info = new MobileCFInfo();
|
2013-01-27 19:41:34 -08:00
|
|
|
this.updateInfo(rule, info);
|
2012-11-07 14:13:48 -08:00
|
|
|
rules[i] = info;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
handleGetCallForwardingOptions: function handleGetCallForwardingOptions(message) {
|
2013-07-31 00:39:52 -07:00
|
|
|
if (message.errorMsg) {
|
|
|
|
this.fireRequestError(message.requestId, message.errorMsg);
|
2012-10-31 06:58:39 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-07 14:13:48 -08:00
|
|
|
this._cfRulesToMobileCfInfo(message.rules);
|
2013-07-31 00:39:52 -07:00
|
|
|
this.fireRequestSuccess(message.requestId, message.rules);
|
2012-10-31 06:58:39 -07:00
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
handleGetCallBarringOptions: function handleGetCallBarringOptions(message) {
|
2013-05-20 22:13:37 -07:00
|
|
|
if (!message.success) {
|
|
|
|
this.fireRequestError(message.requestId, message.errorMsg);
|
|
|
|
} else {
|
2013-10-29 21:04:21 -07:00
|
|
|
let options = new CallBarringOptions(message);
|
|
|
|
this.fireRequestSuccess(message.requestId, options);
|
2013-05-20 22:13:37 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-07-17 14:18:29 -07:00
|
|
|
handleGetCallingLineIdRestriction:
|
|
|
|
function handleGetCallingLineIdRestriction(message) {
|
2013-07-31 00:39:52 -07:00
|
|
|
if (message.errorMsg) {
|
|
|
|
this.fireRequestError(message.requestId, message.errorMsg);
|
2013-07-17 14:18:29 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let status = new DOMCLIRStatus(message);
|
2013-07-31 00:39:52 -07:00
|
|
|
this.fireRequestSuccess(message.requestId, status);
|
2013-07-17 14:18:29 -07:00
|
|
|
},
|
|
|
|
|
2013-08-14 05:50:36 -07:00
|
|
|
handleExitEmergencyCbMode: function handleExitEmergencyCbMode(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 05:21:32 -07:00
|
|
|
handleSendCancelMMI: function handleSendCancelMMI(message) {
|
2013-11-08 02:38:16 -08:00
|
|
|
if (DEBUG) debug("handleSendCancelMMI " + JSON.stringify(message));
|
2012-11-07 14:13:48 -08:00
|
|
|
let request = this.takeRequest(message.requestId);
|
2013-10-14 03:47:55 -07:00
|
|
|
let requestWindow = this._windowsMap[message.requestId];
|
|
|
|
delete this._windowsMap[message.requestId];
|
2012-11-07 14:13:48 -08:00
|
|
|
if (!request) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-30 05:21:32 -07:00
|
|
|
let success = message.success;
|
|
|
|
|
2013-06-30 10:01:02 -07: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 10:23:52 -07: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 05:21:32 -07:00
|
|
|
let result = {
|
2013-06-30 10:01:02 -07:00
|
|
|
serviceCode: message.mmiServiceCode,
|
|
|
|
additionalInformation: message.additionalInformation
|
2013-06-30 05:21:32 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
if (success) {
|
2013-06-30 10:01:02 -07:00
|
|
|
result.statusMessage = message.statusMessage;
|
2013-06-30 05:21:32 -07:00
|
|
|
let mmiResult = new DOMMMIResult(result);
|
|
|
|
Services.DOMRequest.fireSuccess(request, mmiResult);
|
|
|
|
} else {
|
2013-10-14 03:47:55 -07:00
|
|
|
let mmiError = new requestWindow.DOMMMIError(result.serviceCode,
|
|
|
|
message.errorMsg,
|
|
|
|
null,
|
|
|
|
result.additionalInformation);
|
2013-06-30 05:21:32 -07:00
|
|
|
Services.DOMRequest.fireDetailedError(request, mmiError);
|
|
|
|
}
|
2012-11-07 14:13:48 -08:00
|
|
|
},
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
_deliverEvent: function _deliverEvent(clientId, listenerType, name, args) {
|
|
|
|
if (!this[listenerType]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let thisListeners = this[listenerType][clientId];
|
2013-03-06 01:53:31 -08:00
|
|
|
if (!thisListeners) {
|
2012-04-24 08:44:42 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-06 01:53:31 -08:00
|
|
|
let listeners = thisListeners.slice();
|
2013-06-09 19:41:14 -07:00
|
|
|
for (let listener of listeners) {
|
2013-03-06 01:53:31 -08:00
|
|
|
if (thisListeners.indexOf(listener) == -1) {
|
2012-04-24 08:44:42 -07:00
|
|
|
continue;
|
|
|
|
}
|
2013-03-06 01:53:31 -08:00
|
|
|
let handler = listener[name];
|
2012-04-24 08:44:42 -07:00
|
|
|
if (typeof handler != "function") {
|
|
|
|
throw new Error("No handler for " + name);
|
|
|
|
}
|
|
|
|
try {
|
2013-03-06 01:53:31 -08:00
|
|
|
handler.apply(listener, args);
|
2012-04-24 08:44:42 -07:00
|
|
|
} catch (e) {
|
2013-11-08 02:38:16 -08:00
|
|
|
if (DEBUG) debug("listener for " + name + " threw an exception: " + e);
|
2012-04-24 08:44:42 -07:00
|
|
|
}
|
2012-04-19 14:33:25 -07:00
|
|
|
}
|
2012-10-31 06:58:39 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for guarding us again invalid reason values for call forwarding.
|
|
|
|
*/
|
2013-06-09 19:41:14 -07: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 06:58:39 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for guarding us again invalid action values for call forwarding.
|
|
|
|
*/
|
2013-06-09 19:41:14 -07: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-20 22:13:37 -07: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;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-10-29 21:04:21 -07:00
|
|
|
* Helper for guarding us against invalid options for call barring.
|
2013-05-20 22:13:37 -07:00
|
|
|
*/
|
2013-10-29 21:04:21 -07:00
|
|
|
_isValidCallBarringOptions:
|
|
|
|
function _isValidCallBarringOptions(options, usedForSetting) {
|
|
|
|
if (!options ||
|
|
|
|
options.serviceClass == null ||
|
|
|
|
!this._isValidCallBarringProgram(options.program)) {
|
2013-09-03 05:50:55 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
// For setting callbarring options, |enabled| and |password| are required.
|
|
|
|
if (usedForSetting && (options.enabled == null || options.password == null)) {
|
2013-09-03 05:50:55 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2012-07-18 20:27:08 -07:00
|
|
|
}
|
2012-04-19 14:33:25 -07:00
|
|
|
};
|
|
|
|
|
2013-06-30 05:21:32 -07:00
|
|
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RILContentHelper,
|
2013-09-25 01:14:23 -07:00
|
|
|
DOMMMIError,
|
|
|
|
IccCardLockError]);
|
2012-04-19 14:33:25 -07:00
|
|
|
|