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
|
|
|
|
2014-05-07 15:53:17 -07:00
|
|
|
XPCOMUtils.defineLazyGetter(this, "RIL", function () {
|
|
|
|
let obj = {};
|
|
|
|
Cu.import("resource://gre/modules/ril_consts.js", obj);
|
|
|
|
return obj;
|
|
|
|
});
|
2012-04-19 14:33:25 -07:00
|
|
|
|
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";
|
|
|
|
|
|
|
|
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 =
|
2014-08-28 16:51:41 -07:00
|
|
|
Components.ID("{472816e1-1fd6-4405-996c-806f9ea68174}");
|
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",
|
2014-10-28 04:48:12 -07:00
|
|
|
"RIL:GetCardLockResult",
|
|
|
|
"RIL:SetUnlockCardLockResult",
|
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-04-10 05:04:27 -07:00
|
|
|
"RIL:StkCommand",
|
2012-09-25 12:22:38 -07:00
|
|
|
"RIL:StkSessionEnd",
|
2013-02-25 01:27:26 -08:00
|
|
|
"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",
|
2014-02-10 03:55:22 -08:00
|
|
|
"RIL:MatchMvno"
|
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
|
|
|
|
2014-01-12 18:44:33 -08:00
|
|
|
XPCOMUtils.defineLazyGetter(this, "gNumRadioInterfaces", function() {
|
2013-10-01 20:13:56 -07:00
|
|
|
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-05-30 04:14:39 -07:00
|
|
|
function IccInfo() {}
|
|
|
|
IccInfo.prototype = {
|
2014-09-19 00:53:05 -07:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIIccInfo]),
|
2014-08-18 00:15:16 -07:00
|
|
|
|
2014-09-19 00:53:05 -07:00
|
|
|
// nsIIccInfo
|
2014-08-18 00:15:16 -07:00
|
|
|
|
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 = {
|
2014-10-22 23:33:13 -07:00
|
|
|
__proto__: IccInfo.prototype,
|
2014-09-19 00:53:05 -07:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIGsmIccInfo,
|
|
|
|
Ci.nsIIccInfo]),
|
|
|
|
|
|
|
|
// nsIGsmIccInfo
|
2013-08-11 23:59:17 -07:00
|
|
|
|
2012-11-22 20:09:01 -08:00
|
|
|
msisdn: null
|
|
|
|
};
|
|
|
|
|
2013-08-11 23:59:17 -07:00
|
|
|
function CdmaIccInfo() {}
|
|
|
|
CdmaIccInfo.prototype = {
|
2014-10-22 23:33:13 -07:00
|
|
|
__proto__: IccInfo.prototype,
|
2014-09-19 00:53:05 -07:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsICdmaIccInfo,
|
|
|
|
Ci.nsIIccInfo]),
|
|
|
|
|
|
|
|
// nsICdmaIccInfo
|
2013-08-11 23:59:17 -07:00
|
|
|
|
2014-04-07 00:29:04 -07:00
|
|
|
mdn: null,
|
|
|
|
prlVersion: 0
|
2013-08-11 23:59:17 -07:00
|
|
|
};
|
|
|
|
|
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 = [];
|
|
|
|
for (let clientId = 0; clientId < this.numClients; clientId++) {
|
|
|
|
this.rilContexts[clientId] = {
|
2014-09-03 04:31:00 -07:00
|
|
|
cardState: Ci.nsIIccProvider.CARD_STATE_UNKNOWN,
|
|
|
|
iccInfo: null
|
2013-10-29 21:04:21 -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._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);
|
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,
|
|
|
|
|
2014-08-13 03:28:34 -07:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIIccProvider,
|
2013-07-08 14:55:42 -07:00
|
|
|
Ci.nsIObserver,
|
2014-02-10 03:55:22 -08:00
|
|
|
Ci.nsISupportsWeakReference]),
|
2012-04-19 14:33:25 -07:00
|
|
|
classID: RILCONTENTHELPER_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({classID: RILCONTENTHELPER_CID,
|
|
|
|
classDescription: "RILContentHelper",
|
2014-08-13 03:28:34 -07:00
|
|
|
interfaces: [Ci.nsIIccProvider]}),
|
2012-04-19 14:33:25 -07:00
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
updateDebugFlag: function() {
|
2013-10-24 01:14:59 -07:00
|
|
|
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.
|
2014-01-12 18:44:40 -08:00
|
|
|
updateInfo: function(srcInfo, destInfo) {
|
2012-11-22 20:09:01 -08:00
|
|
|
for (let key in srcInfo) {
|
|
|
|
destInfo[key] = srcInfo[key];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
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.
|
|
|
|
*/
|
2014-01-12 18:44:40 -08:00
|
|
|
updateIccInfo: function(clientId, newInfo) {
|
2013-10-29 21:04:21 -07:00
|
|
|
let rilContext = this.rilContexts[clientId];
|
|
|
|
|
2013-08-11 23:59:17 -07:00
|
|
|
// Card is not detected, clear iccInfo to null.
|
2014-08-18 00:15:16 -07:00
|
|
|
if (!newInfo || !newInfo.iccid) {
|
2013-10-29 21:04:21 -07:00
|
|
|
if (rilContext.iccInfo) {
|
|
|
|
rilContext.iccInfo = 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();
|
2014-08-18 00:15:16 -07:00
|
|
|
} else if (newInfo.iccType === "sim" || newInfo.iccType === "usim") {
|
2013-10-29 21:04:21 -07:00
|
|
|
rilContext.iccInfo = new GsmIccInfo();
|
2014-08-18 00:15:16 -07:00
|
|
|
} else {
|
|
|
|
rilContext.iccInfo = new IccInfo();
|
2013-08-11 23:59:17 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-29 21:04:21 -07:00
|
|
|
this.updateInfo(newInfo, rilContext.iccInfo);
|
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
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
getRilContext: function(clientId) {
|
2013-10-29 21:04:21 -07:00
|
|
|
// 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.updateIccInfo(cId, rilContext.iccInfo);
|
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
|
|
|
*/
|
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
getIccInfo: function(clientId) {
|
2013-09-30 03:46:02 -07:00
|
|
|
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
|
|
|
},
|
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
getCardState: function(clientId) {
|
2013-09-30 03:46:02 -07:00
|
|
|
let context = this.getRilContext(clientId);
|
2013-10-29 21:04:21 -07:00
|
|
|
return context && context.cardState;
|
|
|
|
},
|
|
|
|
|
2014-01-27 10:22:00 -08:00
|
|
|
matchMvno: function(clientId, window, mvnoType, mvnoData) {
|
|
|
|
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:MatchMvno", {
|
|
|
|
clientId: clientId,
|
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
|
|
|
mvnoType: mvnoType,
|
|
|
|
mvnoData: mvnoData
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2014-11-11 20:39:04 -08:00
|
|
|
getCardLockEnabled: function(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);
|
|
|
|
}
|
2014-11-11 20:39:04 -08:00
|
|
|
|
2012-04-11 21:01:49 -07:00
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
2013-09-25 01:14:23 -07:00
|
|
|
this._windowsMap[requestId] = window;
|
|
|
|
|
2014-11-11 20:39:04 -08:00
|
|
|
cpmm.sendAsyncMessage("RIL:GetCardLockEnabled", {
|
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;
|
|
|
|
},
|
|
|
|
|
2014-11-11 20:39:04 -08:00
|
|
|
unlockCardLock: function(clientId, window, lockType, password, newPin) {
|
2012-04-11 21:01:49 -07:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2014-11-11 20:39:04 -08:00
|
|
|
|
2012-04-11 21:01:49 -07:00
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
2014-11-11 20:39:04 -08:00
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
this._windowsMap[requestId] = window;
|
2013-09-25 01:14:23 -07:00
|
|
|
|
2013-07-02 02:36:40 -07:00
|
|
|
cpmm.sendAsyncMessage("RIL:UnlockCardLock", {
|
2013-09-30 03:46:02 -07:00
|
|
|
clientId: clientId,
|
2014-11-11 20:39:04 -08:00
|
|
|
data: {
|
|
|
|
lockType: lockType,
|
|
|
|
password: password,
|
|
|
|
newPin: newPin,
|
|
|
|
requestId: requestId
|
|
|
|
}
|
2013-07-02 02:36:40 -07:00
|
|
|
});
|
2012-04-11 21:01:49 -07:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2014-11-11 20:39:04 -08:00
|
|
|
setCardLockEnabled: function(clientId, window, lockType, password, enabled) {
|
2012-04-11 21:01:49 -07:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2014-11-11 20:39:04 -08:00
|
|
|
|
2012-04-11 21:01:49 -07:00
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
2014-11-11 20:39:04 -08:00
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
this._windowsMap[requestId] = window;
|
2013-09-25 01:14:23 -07:00
|
|
|
|
2014-11-11 20:39:04 -08:00
|
|
|
cpmm.sendAsyncMessage("RIL:SetCardLockEnabled", {
|
2013-09-30 03:46:02 -07:00
|
|
|
clientId: clientId,
|
2014-11-11 20:39:04 -08:00
|
|
|
data: {
|
|
|
|
lockType: lockType,
|
|
|
|
password: password,
|
|
|
|
enabled: enabled,
|
|
|
|
requestId: requestId
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
|
|
|
changeCardLockPassword: function(clientId, window, lockType, password,
|
|
|
|
newPassword) {
|
|
|
|
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;
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:ChangeCardLockPassword", {
|
|
|
|
clientId: clientId,
|
|
|
|
data: {
|
|
|
|
lockType: lockType,
|
|
|
|
password: password,
|
|
|
|
newPassword: newPassword,
|
|
|
|
requestId: requestId
|
|
|
|
}
|
2013-07-02 02:36:40 -07:00
|
|
|
});
|
2012-04-11 21:01:49 -07:00
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2014-01-12 18:44:44 -08:00
|
|
|
getCardLockRetryCount: function(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);
|
2014-10-28 20:30:39 -07:00
|
|
|
this._windowsMap[requestId] = window;
|
|
|
|
|
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
|
|
|
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;
|
|
|
|
},
|
|
|
|
|
2014-02-10 03:55:22 -08:00
|
|
|
sendStkResponse: function(clientId, window, command, response) {
|
2013-05-20 22:13:37 -07:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2014-02-10 03:55:22 -08:00
|
|
|
response.command = command;
|
|
|
|
cpmm.sendAsyncMessage("RIL:SendStkResponse", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2014-02-10 03:55:22 -08:00
|
|
|
data: response
|
2013-05-20 22:13:37 -07:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-02-10 03:55:22 -08:00
|
|
|
sendStkMenuSelection: function(clientId, window, itemIdentifier,
|
|
|
|
helpRequested) {
|
2013-05-20 22:13:37 -07:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2014-02-10 03:55:22 -08:00
|
|
|
cpmm.sendAsyncMessage("RIL:SendStkMenuSelection", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
2014-02-10 03:55:22 -08:00
|
|
|
itemIdentifier: itemIdentifier,
|
|
|
|
helpRequested: helpRequested
|
2013-07-02 02:36:40 -07:00
|
|
|
}
|
2013-05-20 22:13:37 -07:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-02-10 03:55:22 -08:00
|
|
|
sendStkTimerExpiration: function(clientId, window, timer) {
|
2013-08-26 18:59:17 -07:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2014-02-10 03:55:22 -08:00
|
|
|
cpmm.sendAsyncMessage("RIL:SendStkTimerExpiration", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2014-02-10 03:55:22 -08:00
|
|
|
data: {
|
|
|
|
timer: timer
|
|
|
|
}
|
2013-08-26 18:59:17 -07:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-02-10 03:55:22 -08:00
|
|
|
sendStkEventDownload: function(clientId, window, event) {
|
2013-04-18 05:18:50 -07:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2014-02-10 03:55:22 -08:00
|
|
|
cpmm.sendAsyncMessage("RIL:SendStkEventDownload", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
2014-02-10 03:55:22 -08:00
|
|
|
event: event
|
2013-07-02 02:36:40 -07:00
|
|
|
}
|
2013-04-18 05:18:50 -07:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-02-10 03:55:22 -08:00
|
|
|
iccOpenChannel: function(clientId, window, aid) {
|
2013-04-18 05:18:50 -07:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2014-02-10 03:55:22 -08:00
|
|
|
|
2013-04-18 05:18:50 -07:00
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
2014-02-10 03:55:22 -08:00
|
|
|
cpmm.sendAsyncMessage("RIL:IccOpenChannel", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-07-02 02:36:40 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
2014-02-10 03:55:22 -08:00
|
|
|
aid: aid
|
2013-07-02 02:36:40 -07:00
|
|
|
}
|
2013-04-18 05:18:50 -07:00
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2014-02-10 03:55:22 -08:00
|
|
|
iccExchangeAPDU: function(clientId, window, channel, apdu) {
|
2013-07-17 14:18:29 -07:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2014-02-10 03:55:22 -08:00
|
|
|
|
2013-07-17 14:18:29 -07:00
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
2014-02-10 03:55:22 -08:00
|
|
|
//Potentially you need serialization here and can't pass the jsval through
|
|
|
|
cpmm.sendAsyncMessage("RIL:IccExchangeAPDU", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-07-17 14:18:29 -07:00
|
|
|
data: {
|
2014-02-10 03:55:22 -08:00
|
|
|
requestId: requestId,
|
|
|
|
channel: channel,
|
|
|
|
apdu: apdu
|
2013-07-17 14:18:29 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2014-02-10 03:55:22 -08:00
|
|
|
iccCloseChannel: function(clientId, window, channel) {
|
2013-07-17 14:18:29 -07:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2014-02-10 03:55:22 -08:00
|
|
|
|
2013-07-17 14:18:29 -07:00
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
|
|
|
|
2014-02-10 03:55:22 -08:00
|
|
|
cpmm.sendAsyncMessage("RIL:IccCloseChannel", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-07-17 14:18:29 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
2014-02-10 03:55:22 -08:00
|
|
|
channel: channel
|
2013-07-17 14:18:29 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2014-02-10 03:55:22 -08:00
|
|
|
readContacts: function(clientId, window, contactType) {
|
2013-08-14 05:50:36 -07:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2014-02-10 03:55:22 -08:00
|
|
|
|
2013-08-14 05:50:36 -07:00
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
2014-02-10 03:55:22 -08:00
|
|
|
this._windowsMap[requestId] = window;
|
2013-08-14 05:50:36 -07:00
|
|
|
|
2014-02-10 03:55:22 -08:00
|
|
|
cpmm.sendAsyncMessage("RIL:ReadIccContacts", {
|
2013-10-29 21:04:21 -07:00
|
|
|
clientId: clientId,
|
2013-08-14 05:50:36 -07:00
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
2014-02-10 03:55:22 -08:00
|
|
|
contactType: contactType
|
2013-08-14 05:50:36 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2014-02-10 03:55:22 -08:00
|
|
|
updateContact: function(clientId, window, contactType, contact, pin2) {
|
2013-11-21 06:09:14 -08:00
|
|
|
if (window == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
2014-02-10 03:55:22 -08:00
|
|
|
|
2013-11-21 06:09:14 -08:00
|
|
|
let request = Services.DOMRequest.createRequest(window);
|
|
|
|
let requestId = this.getRequestId(request);
|
2014-02-10 03:55:22 -08:00
|
|
|
this._windowsMap[requestId] = window;
|
|
|
|
|
|
|
|
// Parsing nsDOMContact to Icc Contact format
|
|
|
|
let iccContact = {};
|
|
|
|
|
|
|
|
if (Array.isArray(contact.name) && contact.name[0]) {
|
|
|
|
iccContact.alphaId = contact.name[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Array.isArray(contact.email) && contact.email[0]) {
|
|
|
|
iccContact.email = contact.email[0].value;
|
|
|
|
}
|
2013-11-21 06:09:14 -08:00
|
|
|
|
2014-02-10 03:55:22 -08:00
|
|
|
iccContact.contactId = contact.id;
|
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("RIL:UpdateIccContact", {
|
2013-11-21 06:09:14 -08:00
|
|
|
clientId: clientId,
|
|
|
|
data: {
|
|
|
|
requestId: requestId,
|
2014-02-10 03:55:22 -08:00
|
|
|
contactType: contactType,
|
|
|
|
contact: iccContact,
|
|
|
|
pin2: pin2
|
2013-11-21 06:09:14 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return request;
|
|
|
|
},
|
|
|
|
|
2013-03-06 01:53:31 -08:00
|
|
|
_iccListeners: null,
|
2012-04-24 08:44:42 -07:00
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
registerListener: function(listenerType, clientId, listener) {
|
2013-10-29 21:04:21 -07:00
|
|
|
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
|
|
|
},
|
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
unregisterListener: function(listenerType, clientId, listener) {
|
2013-10-29 21:04:21 -07:00
|
|
|
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
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
registerIccMsg: function(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
|
|
|
},
|
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
unregisterIccMsg: function(clientId, listener) {
|
2013-09-30 03:46:02 -07:00
|
|
|
this.unregisterListener("_iccListeners", clientId, listener);
|
2012-12-03 18:40:47 -08:00
|
|
|
},
|
|
|
|
|
2012-04-19 14:33:25 -07:00
|
|
|
// nsIObserver
|
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
observe: function(subject, topic, data) {
|
2013-10-24 01:14:59 -07:00
|
|
|
switch (topic) {
|
|
|
|
case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
|
|
|
|
if (data == kPrefRilDebuggingEnabled) {
|
|
|
|
this.updateDebugFlag();
|
|
|
|
}
|
|
|
|
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
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
fireRequestSuccess: function(requestId, result) {
|
2012-06-12 14:05:50 -07:00
|
|
|
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);
|
|
|
|
},
|
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
dispatchFireRequestSuccess: function(requestId, result) {
|
2012-06-19 15:52:06 -07:00
|
|
|
let currentThread = Services.tm.currentThread;
|
|
|
|
|
|
|
|
currentThread.dispatch(this.fireRequestSuccess.bind(this, requestId, result),
|
|
|
|
Ci.nsIThread.DISPATCH_NORMAL);
|
|
|
|
},
|
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
fireRequestError: function(requestId, error) {
|
2012-06-12 14:05:50 -07:00
|
|
|
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);
|
|
|
|
},
|
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
dispatchFireRequestError: function(requestId, error) {
|
2012-10-31 06:58:39 -07:00
|
|
|
let currentThread = Services.tm.currentThread;
|
|
|
|
|
|
|
|
currentThread.dispatch(this.fireRequestError.bind(this, requestId, error),
|
|
|
|
Ci.nsIThread.DISPATCH_NORMAL);
|
|
|
|
},
|
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
fireRequestDetailedError: function(requestId, detailedError) {
|
2013-09-25 01:14:23 -07:00
|
|
|
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);
|
|
|
|
},
|
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
receiveMessage: function(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;
|
2014-10-28 04:48:12 -07:00
|
|
|
case "RIL:GetCardLockResult": {
|
2013-09-25 01:14:23 -07:00
|
|
|
let requestId = data.requestId;
|
|
|
|
let requestWindow = this._windowsMap[requestId];
|
|
|
|
delete this._windowsMap[requestId];
|
|
|
|
|
2014-10-28 04:48:12 -07:00
|
|
|
if (data.errorMsg) {
|
|
|
|
this.fireRequestError(requestId, data.errorMsg);
|
|
|
|
break;
|
2012-08-15 09:49:12 -07:00
|
|
|
}
|
2014-10-28 04:48:12 -07:00
|
|
|
|
2014-10-28 20:42:13 -07:00
|
|
|
this.fireRequestSuccess(requestId,
|
|
|
|
Cu.cloneInto({ enabled: data.enabled },
|
|
|
|
requestWindow));
|
2014-10-28 04:48:12 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "RIL:SetUnlockCardLockResult": {
|
|
|
|
let requestId = data.requestId;
|
|
|
|
let requestWindow = this._windowsMap[requestId];
|
|
|
|
delete this._windowsMap[requestId];
|
|
|
|
|
|
|
|
if (data.errorMsg) {
|
|
|
|
let cardLockError = new requestWindow.IccCardLockError(data.errorMsg,
|
|
|
|
data.retryCount);
|
|
|
|
this.fireRequestDetailedError(requestId, cardLockError);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-10-28 20:42:13 -07:00
|
|
|
this.fireRequestSuccess(requestId, null);
|
2012-04-11 21:01:49 -07:00
|
|
|
break;
|
2013-09-25 01:14:23 -07:00
|
|
|
}
|
2014-10-28 20:30:39 -07:00
|
|
|
case "RIL:CardLockRetryCount": {
|
|
|
|
let requestId = data.requestId;
|
|
|
|
let requestWindow = this._windowsMap[requestId];
|
|
|
|
delete this._windowsMap[requestId];
|
|
|
|
|
2014-10-28 04:48:12 -07:00
|
|
|
if (data.errorMsg) {
|
2013-09-29 17:56:00 -07:00
|
|
|
this.fireRequestError(data.requestId, data.errorMsg);
|
2014-10-28 04:48:12 -07:00
|
|
|
break;
|
Bug 875710: Added getCardLockRetryCount to nsIIccProvider, r=vyang, sr=mounir
This patch adds getCardLockRetryCount to nsIIccProvider and its
implementations. This method allows callers to query the number
of remaining tries for unlocking a SIM-card lock. Supported locks
are 'pin', 'puk', 'pin2', 'puk2', 'nck', 'cck', and 'spck'. The
call returns a DOM request that returns the retry count in its
success handler, or signals an appropriate error.
Reading the retry count is an optional feature and may not be
supported for all lock types. In this case the DOM request receives
and error with the name GECKO_ERROR_NOT_SUPPORTED. For an invalid
lock type, the error name is GECKO_ERROR_GENERIC_FAILURE.
getCardLockRetryCount replaces retryCount in nsIDOMMobileConnection,
which is now deprecated.
--HG--
extra : rebase_source : d1d11612f836652dca85f7c701f09e7af962e3b7
2013-07-09 07:06:05 -07:00
|
|
|
}
|
2014-10-28 04:48:12 -07:00
|
|
|
|
2014-10-28 20:42:13 -07:00
|
|
|
this.fireRequestSuccess(data.requestId,
|
|
|
|
Cu.cloneInto({ retryCount: data.retryCount },
|
|
|
|
requestWindow));
|
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;
|
2014-10-28 20:30:39 -07:00
|
|
|
}
|
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-11-28 01:50:01 -08:00
|
|
|
this.handleUpdateIccContact(data);
|
2013-03-05 18:12:23 -08:00
|
|
|
break;
|
2014-01-27 10:22:00 -08:00
|
|
|
case "RIL:MatchMvno":
|
|
|
|
this.handleSimpleRequest(data.requestId, data.errorMsg, data.result);
|
|
|
|
break;
|
2012-04-24 08:44:42 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
handleSimpleRequest: function(requestId, errorMsg, result) {
|
2013-07-31 00:39:52 -07:00
|
|
|
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
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
handleIccExchangeAPDU: function(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);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
handleReadIccContacts: function(message) {
|
2013-03-05 18:51:40 -08:00
|
|
|
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;
|
2014-10-03 01:05:51 -07:00
|
|
|
let result = new window.Array();
|
|
|
|
contacts.forEach(function(c) {
|
2013-03-05 18:51:40 -08:00
|
|
|
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;
|
2014-10-03 01:05:51 -07:00
|
|
|
result.push(contact);
|
2013-03-05 18:51:40 -08:00
|
|
|
});
|
|
|
|
|
2013-10-21 23:57:44 -07:00
|
|
|
this.fireRequestSuccess(message.requestId, result);
|
2013-03-05 18:51:40 -08:00
|
|
|
},
|
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
handleUpdateIccContact: function(message) {
|
2013-11-28 01:50:01 -08:00
|
|
|
if (message.errorMsg) {
|
|
|
|
this.fireRequestError(message.requestId, message.errorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let window = this._windowsMap[message.requestId];
|
|
|
|
delete this._windowsMap[message.requestId];
|
|
|
|
let iccContact = message.contact;
|
|
|
|
let prop = {name: [iccContact.alphaId], tel: [{value: iccContact.number}]};
|
|
|
|
if (iccContact.email) {
|
|
|
|
prop.email = [{value: iccContact.email}];
|
|
|
|
}
|
|
|
|
|
|
|
|
// ANR - Additional Number
|
|
|
|
let anrLen = iccContact.anr ? iccContact.anr.length : 0;
|
|
|
|
for (let i = 0; i < anrLen; i++) {
|
|
|
|
prop.tel.push({value: iccContact.anr[i]});
|
|
|
|
}
|
|
|
|
|
|
|
|
let contact = new window.mozContact(prop);
|
|
|
|
contact.id = iccContact.contactId;
|
|
|
|
|
|
|
|
this.fireRequestSuccess(message.requestId, contact);
|
|
|
|
},
|
|
|
|
|
2014-01-12 18:44:40 -08:00
|
|
|
_deliverEvent: function(clientId, listenerType, name, args) {
|
2013-10-29 21:04:21 -07:00
|
|
|
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-07-18 20:27:08 -07:00
|
|
|
}
|
2012-04-19 14:33:25 -07:00
|
|
|
};
|
|
|
|
|
2014-10-12 21:35:53 -07:00
|
|
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RILContentHelper]);
|