diff --git a/dom/icc/interfaces/nsIDOMIccManager.idl b/dom/icc/interfaces/nsIDOMIccManager.idl index ab218426ab7a..e5f7f4a11636 100644 --- a/dom/icc/interfaces/nsIDOMIccManager.idl +++ b/dom/icc/interfaces/nsIDOMIccManager.idl @@ -9,7 +9,7 @@ interface nsIDOMEventListener; interface nsIDOMDOMRequest; interface nsIDOMContact; -[scriptable, builtinclass, uuid(d21b7070-c2bc-11e2-8b8b-0800200c9a66)] +[scriptable, builtinclass, uuid(5f405112-4da9-4d4d-942c-4da3cb7928e1)] interface nsIDOMMozIccManager : nsIDOMEventTarget { /** @@ -432,6 +432,20 @@ interface nsIDOMMozIccManager : nsIDOMEventTarget */ [implicit_jscontext] attribute jsval onicccardlockerror; + /** + * Retrieve the number of remaining tries for unlocking the card. + * + * @param lockType + * Identifies the lock type, e.g. "pin" for the PIN lock, "puk" for + * the PUK lock. + * + * @return a DOM Request. + * If the lock type is "pin", or "puk", the request's result will be + * an object containing the number of retries for the specified + * lock. For any other lock type, the result is undefined. + */ + nsIDOMDOMRequest getCardLockRetryCount(in DOMString lockType); + // UICC Phonebook Interfaces. /** diff --git a/dom/icc/interfaces/nsIIccProvider.idl b/dom/icc/interfaces/nsIIccProvider.idl index d01e191be802..6b6b00fd62b3 100644 --- a/dom/icc/interfaces/nsIIccProvider.idl +++ b/dom/icc/interfaces/nsIIccProvider.idl @@ -21,7 +21,7 @@ interface nsIIccListener : nsISupports /** * XPCOM component (in the content process) that provides the ICC information. */ -[scriptable, uuid(77487bf0-c2be-11e2-8b8b-0800200c9a66)] +[scriptable, uuid(7131dfbe-9a2c-434d-b6b8-3eebf491ce1a)] interface nsIIccProvider : nsISupports { /** @@ -57,6 +57,7 @@ interface nsIIccProvider : nsISupports nsIDOMDOMRequest getCardLockState(in nsIDOMWindow window, in DOMString lockType); nsIDOMDOMRequest unlockCardLock(in nsIDOMWindow window, in jsval info); nsIDOMDOMRequest setCardLock(in nsIDOMWindow window, in jsval info); + nsIDOMDOMRequest getCardLockRetryCount(in nsIDOMWindow window, in DOMString lockType); /** * Phonebook interfaces. diff --git a/dom/icc/src/IccManager.cpp b/dom/icc/src/IccManager.cpp index 734008ea4c9a..5a0dd8eaadaa 100644 --- a/dom/icc/src/IccManager.cpp +++ b/dom/icc/src/IccManager.cpp @@ -170,6 +170,16 @@ IccManager::UnlockCardLock(const JS::Value& aInfo, nsIDOMDOMRequest** aDomReques return mProvider->UnlockCardLock(GetOwner(), aInfo, aDomRequest); } +NS_IMETHODIMP +IccManager::GetCardLockRetryCount(const nsAString& aLockType, nsIDOMDOMRequest** aDomRequest) +{ + if (!mProvider) { + return NS_ERROR_FAILURE; + } + + return mProvider->GetCardLockRetryCount(GetOwner(), aLockType, aDomRequest); +} + NS_IMETHODIMP IccManager::IccOpenChannel(const nsAString& aAid, nsIDOMDOMRequest** aRequest) { diff --git a/dom/system/gonk/RILContentHelper.js b/dom/system/gonk/RILContentHelper.js index 5e2bbc6cd5d6..70bde10fedfe 100644 --- a/dom/system/gonk/RILContentHelper.js +++ b/dom/system/gonk/RILContentHelper.js @@ -79,6 +79,7 @@ const RIL_IPC_MSG_NAMES = [ "RIL:VoicemailInfoChanged", "RIL:CallError", "RIL:CardLockResult", + "RIL:CardLockRetryCount", "RIL:USSDReceived", "RIL:SendMMI:Return:OK", "RIL:SendMMI:Return:KO", @@ -123,6 +124,17 @@ MobileIccCardLockResult.prototype = { success: 'r'} }; +function MobileIccCardLockRetryCount(options) { + this.lockType = options.lockType; + this.retryCount = options.retryCount; + this.success = options.success; +} +MobileIccCardLockRetryCount.prototype = { + __exposedProps__ : {lockType: 'r', + retryCount: 'r', + success: 'r'} +}; + function MobileICCInfo() {} MobileICCInfo.prototype = { QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozMobileICCInfo]), @@ -650,6 +662,23 @@ RILContentHelper.prototype = { return request; }, + getCardLockRetryCount: function getCardLockRetryCount(window, lockType) { + if (window == null) { + throw Components.Exception("Can't get window object", + Cr.NS_ERROR_UNEXPECTED); + } + let request = Services.DOMRequest.createRequest(window); + let requestId = this.getRequestId(request); + cpmm.sendAsyncMessage("RIL:GetCardLockRetryCount", { + clientId: 0, + data: { + lockType: lockType, + requestId: requestId + } + }); + return request; + }, + sendMMI: function sendMMI(window, mmi) { // We need to save the global window to get the proper MMIError // constructor once we get the reply from the parent process. @@ -1378,6 +1407,14 @@ RILContentHelper.prototype = { this.fireRequestError(msg.json.requestId, msg.json.errorMsg); } break; + case "RIL:CardLockRetryCount": + if (msg.json.success) { + let result = new MobileIccCardLockRetryCount(msg.json); + this.fireRequestSuccess(msg.json.requestId, result); + } else { + this.fireRequestError(msg.json.requestId, msg.json.errorMsg); + } + break; case "RIL:USSDReceived": { let data = msg.json.data; this._deliverEvent("_mobileConnectionListeners", diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index cb24a3f29b86..3e52a7bb842a 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -115,6 +115,7 @@ const RIL_IPC_ICCMANAGER_MSG_NAMES = [ "RIL:GetCardLockState", "RIL:UnlockCardLock", "RIL:SetCardLock", + "RIL:GetCardLockRetryCount", "RIL:IccOpenChannel", "RIL:IccExchangeAPDU", "RIL:IccCloseChannel", @@ -826,6 +827,10 @@ RadioInterface.prototype = { gMessageManager.saveRequestTarget(msg); this.setCardLock(msg.json.data); break; + case "RIL:GetCardLockRetryCount": + gMessageManager.saveRequestTarget(msg); + this.getCardLockRetryCount(msg.json.data); + break; case "RIL:SendMMI": gMessageManager.saveRequestTarget(msg); this.sendMMI(msg.json.data); @@ -1025,6 +1030,9 @@ RadioInterface.prototype = { case "iccUnlockCardLock": this.handleIccCardLockResult(message); break; + case "iccGetCardLockRetryCount": + this.handleIccCardLockRetryCount(message); + break; case "icccontacts": this.handleReadIccContacts(message); break; @@ -2107,6 +2115,10 @@ RadioInterface.prototype = { gMessageManager.sendRequestResults("RIL:CardLockResult", message); }, + handleIccCardLockRetryCount: function handleIccCardLockRetryCount(message) { + gMessageManager.sendRequestResults("RIL:CardLockRetryCount", message); + }, + handleUSSDReceived: function handleUSSDReceived(ussd) { if (DEBUG) this.debug("handleUSSDReceived " + JSON.stringify(ussd)); gSystemMessenger.broadcastMessage("ussd-received", ussd); @@ -3333,6 +3345,11 @@ RadioInterface.prototype = { this.worker.postMessage(message); }, + getCardLockRetryCount: function getCardLockRetryCount(message) { + message.rilMessageType = "iccGetCardLockRetryCount"; + this.worker.postMessage(message); + }, + readIccContacts: function readIccContacts(message) { message.rilMessageType = "readICCContacts"; this.worker.postMessage(message); diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index 69a85e4b567d..64478477ffaa 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -1196,6 +1196,36 @@ let RIL = { this.queryICCFacilityLock(options); }, + /** + * Helper function for fetching the number of unlock retries of ICC locks. + */ + iccGetCardLockRetryCount: function iccGetCardLockRetryCount(options) { + switch (options.lockType) { + case "pin": + case "puk": + case "pin2": + case "puk2": + case "nck": + case "cck": + case "spck": + options.errorMsg = GECKO_ERROR_REQUEST_NOT_SUPPORTED; + options.success = false; + this.sendDOMMessage(options); + return; + default: + options.errorMsg = GECKO_ERROR_GENERIC_FAILURE; + options.success = false; + this.sendDOMMessage(options); + return; + } + + // TODO: We currently don't have a way for + // reading the retry count. See bug 868896. + options.retryCount = 0; + options.success = true; + this.sendDOMMessage(options); + }, + /** * Query ICC facility lock. *