mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 731786 - B2G RIL: Support SIM cards that require PIN codes. r=philikon sr=sicking
This commit is contained in:
parent
d59c316057
commit
c2ae70983d
@ -57,27 +57,40 @@ DOMRequestIpcHelper.prototype = {
|
||||
Services.obs.removeObserver(this, "inner-window-destroyed");
|
||||
this._requests = [];
|
||||
this._window = null;
|
||||
this._messages.forEach((function(msgName) {
|
||||
cpmm.removeMessageListener(msgName, this);
|
||||
}).bind(this));
|
||||
this.removeMessageListener();
|
||||
if(this.uninit)
|
||||
this.uninit();
|
||||
}
|
||||
},
|
||||
|
||||
initHelper: function(aWindow, aMessages) {
|
||||
this._messages = aMessages;
|
||||
initRequests: function initRequests() {
|
||||
this._requests = [];
|
||||
this._window = aWindow;
|
||||
let util = this._window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
|
||||
this.innerWindowID = util.currentInnerWindowID;
|
||||
this._id = this._getRandomId();
|
||||
Services.obs.addObserver(this, "inner-window-destroyed", false);
|
||||
},
|
||||
|
||||
initMessageListener: function initMessageListener(aMessages) {
|
||||
this._messages = aMessages;
|
||||
this._messages.forEach((function(msgName) {
|
||||
cpmm.addMessageListener(msgName, this);
|
||||
}).bind(this));
|
||||
},
|
||||
|
||||
initHelper: function(aWindow, aMessages) {
|
||||
this.initMessageListener(aMessages);
|
||||
this.initRequests();
|
||||
this._id = this._getRandomId();
|
||||
Services.obs.addObserver(this, "inner-window-destroyed", false);
|
||||
this._window = aWindow;
|
||||
let util = this._window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
|
||||
this.innerWindowID = util.currentInnerWindowID;
|
||||
},
|
||||
|
||||
removeMessageListener: function removeMessageListener() {
|
||||
this._messages.forEach((function(msgName) {
|
||||
cpmm.removeMessageListener(msgName, this);
|
||||
}).bind(this));
|
||||
this._messages = null;
|
||||
},
|
||||
|
||||
createRequest: function() {
|
||||
return Services.DOMRequest.createRequest(this._window);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ interface nsIDOMEventListener;
|
||||
interface nsIDOMDOMRequest;
|
||||
interface nsIDOMMozMobileConnectionInfo;
|
||||
|
||||
[scriptable, uuid(ba2be619-fed6-4652-865a-c61f88ffeaa8)]
|
||||
[scriptable, uuid(962298cd-3443-423e-9e47-f22e24ad850b)]
|
||||
interface nsIDOMMozMobileConnection : nsIDOMEventTarget
|
||||
{
|
||||
/**
|
||||
@ -54,6 +54,111 @@ interface nsIDOMMozMobileConnection : nsIDOMEventTarget
|
||||
*/
|
||||
attribute nsIDOMEventListener ondatachange;
|
||||
|
||||
/**
|
||||
* Find out about the status of an ICC lock (e.g. the PIN lock).
|
||||
*
|
||||
* @param lockType
|
||||
* Identifies the lock type, e.g. "pin" for the PIN lock.
|
||||
*
|
||||
* @return a DOM Request.
|
||||
* The request's result will be an object containing
|
||||
* information about the specified lock's status,
|
||||
* e.g. {lockType: "pin", enabled: true}.
|
||||
*/
|
||||
nsIDOMDOMRequest getCardLock(in DOMString lockType);
|
||||
|
||||
/**
|
||||
* Unlock a card lock.
|
||||
*
|
||||
* @param info
|
||||
* An object containing the information necessary to unlock
|
||||
* the given lock. At a minimum, this object must have a
|
||||
* "lockType" attribute which specifies the type of lock, e.g.
|
||||
* "pin" for the PIN lock. Other attributes are dependent on
|
||||
* the lock type.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* (1) Unlocking the PIN:
|
||||
*
|
||||
* unlockCardLock({lockType: "pin",
|
||||
* pin: "..."});
|
||||
*
|
||||
* (2) Unlocking the PUK and supplying a new PIN:
|
||||
*
|
||||
* unlockCardLock({lockType: "puk",
|
||||
* puk: "...",
|
||||
* newPin: "..."});
|
||||
*
|
||||
* @return a nsIDOMDOMRequest.
|
||||
* The request's result will be an object containing
|
||||
* information about the unlock operation.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* (1) Unlocking failed:
|
||||
*
|
||||
* {
|
||||
* lockType: "pin",
|
||||
* result: false,
|
||||
* retryCount: 2
|
||||
* }
|
||||
*
|
||||
* (2) Unlocking succeeded:
|
||||
*
|
||||
* {
|
||||
* lockType: "pin",
|
||||
* result: true
|
||||
* }
|
||||
*/
|
||||
nsIDOMDOMRequest unlockCardLock(in jsval info);
|
||||
|
||||
/**
|
||||
* Modify the state of a card lock.
|
||||
*
|
||||
* @param info
|
||||
* An object containing information about the lock and
|
||||
* how to modify its state. At a minimum, this object
|
||||
* must have a "lockType" attribute which specifies the
|
||||
* type of lock, e.g. "pin" for the PIN lock. Other
|
||||
* attributes are dependent on the lock type.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* (1) Disabling the PIN lock:
|
||||
*
|
||||
* setCardLock({lockType: "pin",
|
||||
* pin: "...",
|
||||
* enabled: false});
|
||||
*
|
||||
* (2) Changing the PIN:
|
||||
*
|
||||
* setCardLock({lockType: "pin",
|
||||
* pin: "...",
|
||||
* newPin: "..."});
|
||||
*
|
||||
* @return a nsIDOMDOMRequest.
|
||||
* The request's result will be an object containing
|
||||
* information about the operation.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* (1) Enabling/Disabling card lock failed or change card lock failed.
|
||||
*
|
||||
* {
|
||||
* lockType: "pin",
|
||||
* result: false,
|
||||
* retryCount: 2
|
||||
* }
|
||||
*
|
||||
* (2) Enabling/Disabling card lock succeed or change card lock succeed.
|
||||
*
|
||||
* {
|
||||
* lockType: "pin",
|
||||
* result: true
|
||||
* }
|
||||
*/
|
||||
nsIDOMDOMRequest setCardLock(in jsval info);
|
||||
};
|
||||
|
||||
[scriptable, uuid(f3bb0611-5e4a-46f1-a8f5-cf592b37596e)]
|
||||
|
@ -12,7 +12,7 @@ interface nsIDOMWindow;
|
||||
* XPCOM component (in the content process) that provides the mobile
|
||||
* network information.
|
||||
*/
|
||||
[scriptable, uuid(1ecd19eb-15d4-47c0-a2cf-80cfa3b94eeb)]
|
||||
[scriptable, uuid(93202514-9ae9-482e-95bc-9c6ed62aea99)]
|
||||
interface nsIMobileConnectionProvider : nsISupports
|
||||
{
|
||||
readonly attribute DOMString cardState;
|
||||
@ -20,4 +20,7 @@ interface nsIMobileConnectionProvider : nsISupports
|
||||
readonly attribute nsIDOMMozMobileConnectionInfo dataConnectionInfo;
|
||||
|
||||
nsIDOMDOMRequest getNetworks(in nsIDOMWindow window);
|
||||
nsIDOMDOMRequest getCardLock(in nsIDOMWindow window, in DOMString lockType);
|
||||
nsIDOMDOMRequest unlockCardLock(in nsIDOMWindow window, in jsval info);
|
||||
nsIDOMDOMRequest setCardLock(in nsIDOMWindow window, in jsval info);
|
||||
};
|
||||
|
@ -162,6 +162,42 @@ MobileConnection::GetNetworks(nsIDOMDOMRequest** request)
|
||||
return mProvider->GetNetworks(GetOwner(), request);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnection::GetCardLock(const nsAString& aLockType, nsIDOMDOMRequest** aDomRequest)
|
||||
{
|
||||
*aDomRequest = nsnull;
|
||||
|
||||
if (!mProvider) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return mProvider->GetCardLock(GetOwner(), aLockType, aDomRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnection::UnlockCardLock(const jsval& aInfo, nsIDOMDOMRequest** aDomRequest)
|
||||
{
|
||||
*aDomRequest = nsnull;
|
||||
|
||||
if (!mProvider) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return mProvider->UnlockCardLock(GetOwner(), aInfo, aDomRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnection::SetCardLock(const jsval& aInfo, nsIDOMDOMRequest** aDomRequest)
|
||||
{
|
||||
*aDomRequest = nsnull;
|
||||
|
||||
if (!mProvider) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return mProvider->SetCardLock(GetOwner(), aInfo, aDomRequest);
|
||||
}
|
||||
|
||||
nsresult
|
||||
MobileConnection::InternalDispatchEvent(const nsAString& aType)
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
||||
|
||||
var RIL = {};
|
||||
Cu.import("resource://gre/modules/ril_consts.js", RIL);
|
||||
@ -26,6 +27,12 @@ const RIL_IPC_MSG_NAMES = [
|
||||
"RIL:EnumerateCalls",
|
||||
"RIL:CallStateChanged",
|
||||
"RIL:CallError",
|
||||
"RIL:GetCardLock:Return:OK",
|
||||
"RIL:GetCardLock:Return:KO",
|
||||
"RIL:SetCardLock:Return:OK",
|
||||
"RIL:SetCardLock:Return:KO",
|
||||
"RIL:UnlockCardLock:Return:OK",
|
||||
"RIL:UnlockCardLock:Return:KO",
|
||||
];
|
||||
|
||||
const kVoiceChangedTopic = "mobile-connection-voice-changed";
|
||||
@ -63,9 +70,8 @@ function RILContentHelper() {
|
||||
this.voiceConnectionInfo = new MobileConnectionInfo();
|
||||
this.dataConnectionInfo = new MobileConnectionInfo();
|
||||
|
||||
for each (let msgname in RIL_IPC_MSG_NAMES) {
|
||||
cpmm.addMessageListener(msgname, this);
|
||||
}
|
||||
this.initRequests();
|
||||
this.initMessageListener(RIL_IPC_MSG_NAMES);
|
||||
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
||||
|
||||
// Request initial state.
|
||||
@ -84,6 +90,8 @@ function RILContentHelper() {
|
||||
}
|
||||
}
|
||||
RILContentHelper.prototype = {
|
||||
__proto__: DOMRequestIpcHelper.prototype,
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionProvider,
|
||||
Ci.nsIRILContentHelper,
|
||||
Ci.nsIObserver]),
|
||||
@ -104,6 +112,39 @@ RILContentHelper.prototype = {
|
||||
throw Components.Exception("Not implemented", Cr.NS_ERROR_NOT_IMPLEMENTED);
|
||||
},
|
||||
|
||||
getCardLock: function getCardLock(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:GetCardLock", {lockType: lockType, requestId: requestId});
|
||||
return request;
|
||||
},
|
||||
|
||||
unlockCardLock: function unlockCardLock(window, info) {
|
||||
if (window == null) {
|
||||
throw Components.Exception("Can't get window object",
|
||||
Cr.NS_ERROR_UNEXPECTED);
|
||||
}
|
||||
let request = Services.DOMRequest.createRequest(window);
|
||||
info.requestId = this.getRequestId(request);
|
||||
cpmm.sendAsyncMessage("RIL:UnlockCardLock", info);
|
||||
return request;
|
||||
},
|
||||
|
||||
setCardLock: function setCardLock(window, info) {
|
||||
if (window == null) {
|
||||
throw Components.Exception("Can't get window object",
|
||||
Cr.NS_ERROR_UNEXPECTED);
|
||||
}
|
||||
let request = Services.DOMRequest.createRequest(window);
|
||||
info.requestId = this.getRequestId(request);
|
||||
cpmm.sendAsyncMessage("RIL:SetCardLock", info);
|
||||
return request;
|
||||
},
|
||||
|
||||
_telephonyCallbacks: null,
|
||||
_enumerationTelephonyCallbacks: null,
|
||||
|
||||
@ -195,9 +236,7 @@ RILContentHelper.prototype = {
|
||||
|
||||
observe: function observe(subject, topic, data) {
|
||||
if (topic == "xpcom-shutdown") {
|
||||
for each (let msgname in RIL_IPC_MSG_NAMES) {
|
||||
cpmm.removeMessageListener(msgname, this);
|
||||
}
|
||||
this.removeMessageListener();
|
||||
Services.obs.removeObserver(this, "xpcom-shutdown");
|
||||
cpmm = null;
|
||||
}
|
||||
@ -206,6 +245,7 @@ RILContentHelper.prototype = {
|
||||
// nsIFrameMessageListener
|
||||
|
||||
receiveMessage: function receiveMessage(msg) {
|
||||
let request;
|
||||
debug("Received message '" + msg.name + "': " + JSON.stringify(msg.json));
|
||||
switch (msg.name) {
|
||||
case "RIL:CardStateChanged":
|
||||
@ -239,6 +279,22 @@ RILContentHelper.prototype = {
|
||||
[msg.json.callIndex,
|
||||
msg.json.error]);
|
||||
break;
|
||||
case "RIL:GetCardLock:Return:OK":
|
||||
case "RIL:SetCardLock:Return:OK":
|
||||
case "RIL:UnlockCardLock:Return:OK":
|
||||
request = this.getRequest(msg.json.requestId);
|
||||
if (request) {
|
||||
Services.DOMRequest.fireSuccess(request, msg.json);
|
||||
}
|
||||
break;
|
||||
case "RIL:GetCardLock:Return:KO":
|
||||
case "RIL:SetCardLock:Return:KO":
|
||||
case "RIL:UnlockCardLock:Return:KO":
|
||||
request = this.getRequest(msg.json.requestId);
|
||||
if (request) {
|
||||
Services.DOMRequest.fireError(request, msg.json.errorMsg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@ -284,7 +340,6 @@ RILContentHelper.prototype = {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
const NSGetFactory = XPCOMUtils.generateNSGetFactory([RILContentHelper]);
|
||||
|
@ -44,6 +44,9 @@ const RIL_IPC_MSG_NAMES = [
|
||||
"RIL:RejectCall",
|
||||
"RIL:HoldCall",
|
||||
"RIL:ResumeCall",
|
||||
"RIL:GetCardLock",
|
||||
"RIL:UnlockCardLock",
|
||||
"RIL:SetCardLock"
|
||||
];
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gSmsService",
|
||||
@ -221,6 +224,15 @@ RadioInterfaceLayer.prototype = {
|
||||
case "RIL:ResumeCall":
|
||||
this.resumeCall(msg.json);
|
||||
break;
|
||||
case "RIL:GetCardLock":
|
||||
this.getCardLock(msg.json);
|
||||
break;
|
||||
case "RIL:UnlockCardLock":
|
||||
this.unlockCardLock(msg.json);
|
||||
break;
|
||||
case "RIL:SetCardLock":
|
||||
this.setCardLock(msg.json);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@ -309,6 +321,15 @@ RadioInterfaceLayer.prototype = {
|
||||
case "iccinfochange":
|
||||
this.radioState.icc = message;
|
||||
break;
|
||||
case "iccgetcardlock":
|
||||
this.handleICCGetCardLock(message);
|
||||
break;
|
||||
case "iccsetcardlock":
|
||||
this.handleICCSetCardLock(message);
|
||||
break;
|
||||
case "iccunlockcardlock":
|
||||
this.handleICCUnlockCardLock(message);
|
||||
break;
|
||||
default:
|
||||
throw new Error("Don't know about this message type: " + message.type);
|
||||
}
|
||||
@ -634,6 +655,18 @@ RadioInterfaceLayer.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
handleICCGetCardLock: function handleICCGetCardLock(message) {
|
||||
ppmm.sendAsyncMessage("RIL:GetCardLock:Return:OK", message);
|
||||
},
|
||||
|
||||
handleICCSetCardLock: function handleICCSetCardLock(message) {
|
||||
ppmm.sendAsyncMessage("RIL:SetCardLock:Return:OK", message);
|
||||
},
|
||||
|
||||
handleICCUnlockCardLock: function handleICCUnlockCardLock(message) {
|
||||
ppmm.sendAsyncMessage("RIL:UnlockCardLock:Return:OK", message);
|
||||
},
|
||||
|
||||
// nsIObserver
|
||||
|
||||
observe: function observe(subject, topic, data) {
|
||||
@ -1196,8 +1229,71 @@ RadioInterfaceLayer.prototype = {
|
||||
this.worker.postMessage({type: "getDataCallList"});
|
||||
},
|
||||
|
||||
};
|
||||
getCardLock: function getCardLock(message) {
|
||||
// Currently only support pin.
|
||||
switch (message.lockType) {
|
||||
case "pin" :
|
||||
message.type = "getICCPinLock";
|
||||
break;
|
||||
default:
|
||||
ppmm.sendAsyncMessage("RIL:GetCardLock:Return:KO",
|
||||
{errorMsg: "Unsupported Card Lock.",
|
||||
requestId: message.requestId});
|
||||
return;
|
||||
}
|
||||
this.worker.postMessage(message);
|
||||
},
|
||||
|
||||
unlockCardLock: function unlockCardLock(message) {
|
||||
switch (message.lockType) {
|
||||
case "pin":
|
||||
message.type = "enterICCPIN";
|
||||
break;
|
||||
case "pin2":
|
||||
message.type = "enterICCPIN2";
|
||||
break;
|
||||
case "puk":
|
||||
message.type = "enterICCPUK";
|
||||
break;
|
||||
case "puk2":
|
||||
message.type = "enterICCPUK2";
|
||||
break;
|
||||
default:
|
||||
ppmm.sendAsyncMessage("RIL:UnlockCardLock:Return:KO",
|
||||
{errorMsg: "Unsupported Card Lock.",
|
||||
requestId: message.requestId});
|
||||
return;
|
||||
}
|
||||
this.worker.postMessage(message);
|
||||
},
|
||||
|
||||
setCardLock: function setCardLock(message) {
|
||||
// Change pin.
|
||||
if (message.newPin !== undefined) {
|
||||
switch (message.lockType) {
|
||||
case "pin":
|
||||
message.type = "changeICCPIN";
|
||||
break;
|
||||
case "pin2":
|
||||
message.type = "changeICCPIN2";
|
||||
break;
|
||||
default:
|
||||
ppmm.sendAsyncMessage("RIL:SetCardLock:Return:KO",
|
||||
{errorMsg: "Unsupported Card Lock.",
|
||||
requestId: message.requestId});
|
||||
return;
|
||||
}
|
||||
} else { // Enable/Disable pin lock.
|
||||
if (message.lockType != "pin") {
|
||||
ppmm.sendAsyncMessage("RIL:SetCardLock:Return:KO",
|
||||
{errorMsg: "Unsupported Card Lock.",
|
||||
requestId: message.requestId});
|
||||
}
|
||||
message.type = "setICCPinLock";
|
||||
}
|
||||
this.worker.postMessage(message);
|
||||
}
|
||||
};
|
||||
|
||||
let RILNetworkInterface = {
|
||||
|
||||
|
@ -423,6 +423,23 @@ const ICC_STATUS_ERROR_WRONG_LENGTH = 0x67;
|
||||
const ICC_STATUS_ERROR_COMMAND_NOT_ALLOWED = 0x69;
|
||||
const ICC_STATUS_ERROR_WRONG_PARAMETERS = 0x6a;
|
||||
|
||||
// ICC call barring facility.
|
||||
// TS 27.007, clause 7.4, +CLCK
|
||||
const ICC_CB_FACILITY_SIM = "SC";
|
||||
|
||||
// ICC service class
|
||||
// TS 27.007, clause 7.4, +CLCK
|
||||
const ICC_SERVICE_CLASS_NONE = 0; // no user input
|
||||
const ICC_SERVICE_CLASS_VOICE = (1 << 0);
|
||||
const ICC_SERVICE_CLASS_DATA = (1 << 1);
|
||||
const ICC_SERVICE_CLASS_FAX = (1 << 2);
|
||||
const ICC_SERVICE_CLASS_SMS = (1 << 3);
|
||||
const ICC_SERVICE_CLASS_DATA_SYNC = (1 << 4);
|
||||
const ICC_SERVICE_CLASS_DATA_ASYNC = (1 << 5);
|
||||
const ICC_SERVICE_CLASS_PACKET = (1 << 6);
|
||||
const ICC_SERVICE_CLASS_PAD = (1 << 7);
|
||||
const ICC_SERVICE_CLASS_MAX = (1 << 7); // Max ICC_SERVICE_CLASS value
|
||||
|
||||
/**
|
||||
* GSM PDU constants
|
||||
*/
|
||||
|
@ -762,30 +762,58 @@ let RIL = {
|
||||
* String containing the PIN.
|
||||
*/
|
||||
enterICCPIN: function enterICCPIN(options) {
|
||||
Buf.newParcel(REQUEST_ENTER_SIM_PIN);
|
||||
Buf.newParcel(REQUEST_ENTER_SIM_PIN, options);
|
||||
Buf.writeUint32(1);
|
||||
Buf.writeString(options.pin);
|
||||
Buf.sendParcel();
|
||||
},
|
||||
|
||||
/**
|
||||
* Change the current ICC PIN number
|
||||
* Enter a PIN2 to unlock the ICC.
|
||||
*
|
||||
* @param oldPin
|
||||
* @param pin
|
||||
* String containing the PIN2.
|
||||
*/
|
||||
enterICCPIN2: function enterICCPIN2(options) {
|
||||
Buf.newParcel(REQUEST_ENTER_SIM_PIN2, options);
|
||||
Buf.writeUint32(1);
|
||||
Buf.writeString(options.pin);
|
||||
Buf.sendParcel();
|
||||
},
|
||||
|
||||
/**
|
||||
* Change the current ICC PIN number.
|
||||
*
|
||||
* @param pin
|
||||
* String containing the old PIN value
|
||||
* @param newPin
|
||||
* String containing the new PIN value
|
||||
*/
|
||||
changeICCPIN: function changeICCPIN(options) {
|
||||
Buf.newParcel(REQUEST_CHANGE_SIM_PIN);
|
||||
Buf.newParcel(REQUEST_CHANGE_SIM_PIN, options);
|
||||
Buf.writeUint32(2);
|
||||
Buf.writeString(options.oldPin);
|
||||
Buf.writeString(options.pin);
|
||||
Buf.writeString(options.newPin);
|
||||
Buf.sendParcel();
|
||||
},
|
||||
|
||||
/**
|
||||
* Supplies SIM PUK and a new PIN to unlock the ICC
|
||||
* Change the current ICC PIN2 number.
|
||||
*
|
||||
* @param pin
|
||||
* String containing the old PIN2 value
|
||||
* @param newPin
|
||||
* String containing the new PIN2 value
|
||||
*/
|
||||
changeICCPIN2: function changeICCPIN2(options) {
|
||||
Buf.newParcel(REQUEST_CHANGE_SIM_PIN2, options);
|
||||
Buf.writeUint32(2);
|
||||
Buf.writeString(options.pin);
|
||||
Buf.writeString(options.newPin);
|
||||
Buf.sendParcel();
|
||||
},
|
||||
/**
|
||||
* Supplies ICC PUK and a new PIN to unlock the ICC.
|
||||
*
|
||||
* @param puk
|
||||
* String containing the PUK value.
|
||||
@ -794,13 +822,106 @@ let RIL = {
|
||||
*
|
||||
*/
|
||||
enterICCPUK: function enterICCPUK(options) {
|
||||
Buf.newParcel(REQUEST_ENTER_SIM_PUK);
|
||||
Buf.newParcel(REQUEST_ENTER_SIM_PUK, options);
|
||||
Buf.writeUint32(2);
|
||||
Buf.writeString(options.puk);
|
||||
Buf.writeString(options.newPin);
|
||||
Buf.sendParcel();
|
||||
},
|
||||
|
||||
/**
|
||||
* Supplies ICC PUK2 and a new PIN2 to unlock the ICC.
|
||||
*
|
||||
* @param puk
|
||||
* String containing the PUK2 value.
|
||||
* @param newPin
|
||||
* String containing the new PIN2 value.
|
||||
*
|
||||
*/
|
||||
enterICCPUK2: function enterICCPUK2(options) {
|
||||
Buf.newParcel(REQUEST_ENTER_SIM_PUK2, options);
|
||||
Buf.writeUint32(2);
|
||||
Buf.writeString(options.puk);
|
||||
Buf.writeString(options.newPin);
|
||||
Buf.sendParcel();
|
||||
},
|
||||
|
||||
/**
|
||||
* Get ICC Pin lock. A wrapper call to queryICCFacilityLock.
|
||||
*
|
||||
* @param requestId
|
||||
* Request Id from RadioInterfaceLayer.
|
||||
*/
|
||||
getICCPinLock: function getICCPinLock(options) {
|
||||
options.facility = ICC_CB_FACILITY_SIM;
|
||||
options.password = ""; // For query no need to provide pin.
|
||||
options.serviceClass = ICC_SERVICE_CLASS_VOICE |
|
||||
ICC_SERVICE_CLASS_DATA |
|
||||
ICC_SERVICE_CLASS_FAX,
|
||||
this.queryICCFacilityLock(options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Query ICC facility lock.
|
||||
*
|
||||
* @param facility
|
||||
* One of ICC_CB_FACILITY_*.
|
||||
* @param password
|
||||
* Password for the facility, or "" if not required.
|
||||
* @param serviceClass
|
||||
* One of ICC_SERVICE_CLASS_*.
|
||||
*/
|
||||
queryICCFacilityLock: function queryICCFacilityLock(options) {
|
||||
Buf.newParcel(REQUEST_QUERY_FACILITY_LOCK, options);
|
||||
Buf.writeUint32(3);
|
||||
Buf.writeString(options.facility);
|
||||
Buf.writeString(options.password);
|
||||
Buf.writeString(options.serviceClass.toString());
|
||||
Buf.sendParcel();
|
||||
},
|
||||
|
||||
/**
|
||||
* Set ICC Pin lock. A wrapper call to setICCFacilityLock.
|
||||
*
|
||||
* @param enabled
|
||||
* true to enable, false to disable.
|
||||
* @param pin
|
||||
* Pin code.
|
||||
* @param requestId
|
||||
* Request Id from RadioInterfaceLayer.
|
||||
*/
|
||||
setICCPinLock: function setICCPinLock(options) {
|
||||
options.facility = ICC_CB_FACILITY_SIM;
|
||||
options.enabled = options.enabled;
|
||||
options.password = options.pin;
|
||||
options.serviceClass = ICC_SERVICE_CLASS_VOICE |
|
||||
ICC_SERVICE_CLASS_DATA |
|
||||
ICC_SERVICE_CLASS_FAX,
|
||||
this.setICCFacilityLock(options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Set ICC facility lock.
|
||||
*
|
||||
* @param facility
|
||||
* One of ICC_CB_FACILITY_*.
|
||||
* @param enabled
|
||||
* true to enable, false to disable.
|
||||
* @param password
|
||||
* Password for the facility, or "" if not required.
|
||||
* @param serviceClass
|
||||
* One of ICC_SERVICE_CLASS_*.
|
||||
*/
|
||||
setICCFacilityLock: function setICCFacilityLock(options) {
|
||||
Buf.newParcel(REQUEST_SET_FACILITY_LOCK, options);
|
||||
Buf.writeUint32(4);
|
||||
Buf.writeString(options.facility);
|
||||
Buf.writeString(options.enabled ? "1" : "0");
|
||||
Buf.writeString(options.password);
|
||||
Buf.writeString(options.serviceClass.toString());
|
||||
Buf.sendParcel();
|
||||
},
|
||||
|
||||
/**
|
||||
* Request an ICC I/O operation.
|
||||
*
|
||||
@ -2154,25 +2275,47 @@ RIL[REQUEST_GET_SIM_STATUS] = function REQUEST_GET_SIM_STATUS(length, options) {
|
||||
this._processICCStatus(iccStatus);
|
||||
};
|
||||
RIL[REQUEST_ENTER_SIM_PIN] = function REQUEST_ENTER_SIM_PIN(length, options) {
|
||||
if (options.rilRequestError) {
|
||||
return;
|
||||
}
|
||||
|
||||
let response = Buf.readUint32List();
|
||||
if (DEBUG) debug("REQUEST_ENTER_SIM_PIN returned " + response);
|
||||
this.sendDOMMessage({type: "iccunlockcardlock",
|
||||
lockType: "pin",
|
||||
result: options.rilRequestError == 0 ? true : false,
|
||||
retryCount: length ? Buf.readUint32List()[0] : -1,
|
||||
requestId: options.requestId});
|
||||
};
|
||||
RIL[REQUEST_ENTER_SIM_PUK] = function REQUEST_ENTER_SIM_PUK(length, options) {
|
||||
if (options.rilRequestError) {
|
||||
return;
|
||||
}
|
||||
|
||||
let response = Buf.readUint32List();
|
||||
if (DEBUG) debug("REQUEST_ENTER_SIM_PUK returned " + response);
|
||||
this.sendDOMMessage({type: "iccunlockcardlock",
|
||||
lockType: "puk",
|
||||
result: options.rilRequestError == 0 ? true : false,
|
||||
retryCount: length ? Buf.readUint32List()[0] : -1,
|
||||
requestId: options.requestId});
|
||||
};
|
||||
RIL[REQUEST_ENTER_SIM_PIN2] = function REQUEST_ENTER_SIM_PIN2(length, options) {
|
||||
this.sendDOMMessage({type: "iccunlockcardlock",
|
||||
lockType: "pin2",
|
||||
result: options.rilRequestError == 0 ? true : false,
|
||||
retryCount: length ? Buf.readUint32List()[0] : -1,
|
||||
requestId: options.requestId});
|
||||
};
|
||||
RIL[REQUEST_ENTER_SIM_PUK2] = function REQUEST_ENTER_SIM_PUK(length, options) {
|
||||
this.sendDOMMessage({type: "iccunlockcardlock",
|
||||
lockType: "puk2",
|
||||
result: options.rilRequestError == 0 ? true : false,
|
||||
retryCount: length ? Buf.readUint32List()[0] : -1,
|
||||
requestId: options.requestId});
|
||||
};
|
||||
RIL[REQUEST_CHANGE_SIM_PIN] = function REQUEST_CHANGE_SIM_PIN(length, options) {
|
||||
this.sendDOMMessage({type: "iccsetcardlock",
|
||||
lockType: "pin",
|
||||
result: options.rilRequestError == 0 ? true : false,
|
||||
retryCount: length ? Buf.readUint32List()[0] : -1,
|
||||
requestId: options.requestId});
|
||||
};
|
||||
RIL[REQUEST_CHANGE_SIM_PIN2] = function REQUEST_CHANGE_SIM_PIN2(length, options) {
|
||||
this.sendDOMMessage({type: "iccsetcardlock",
|
||||
lockType: "pin2",
|
||||
result: options.rilRequestError == 0 ? true : false,
|
||||
retryCount: length ? Buf.readUint32List()[0] : -1,
|
||||
requestId: options.requestId});
|
||||
};
|
||||
RIL[REQUEST_ENTER_SIM_PIN2] = null;
|
||||
RIL[REQUEST_ENTER_SIM_PUK2] = null;
|
||||
RIL[REQUEST_CHANGE_SIM_PIN] = null;
|
||||
RIL[REQUEST_CHANGE_SIM_PIN2] = null;
|
||||
RIL[REQUEST_ENTER_NETWORK_DEPERSONALIZATION] = null;
|
||||
RIL[REQUEST_GET_CURRENT_CALLS] = function REQUEST_GET_CURRENT_CALLS(length, options) {
|
||||
if (options.rilRequestError) {
|
||||
@ -2534,8 +2677,24 @@ RIL[REQUEST_DEACTIVATE_DATA_CALL] = function REQUEST_DEACTIVATE_DATA_CALL(length
|
||||
this.sendDOMMessage({type: "datacallstatechange",
|
||||
datacall: datacall});
|
||||
};
|
||||
RIL[REQUEST_QUERY_FACILITY_LOCK] = null;
|
||||
RIL[REQUEST_SET_FACILITY_LOCK] = null;
|
||||
RIL[REQUEST_QUERY_FACILITY_LOCK] = function REQUEST_QUERY_FACILITY_LOCK(length, options) {
|
||||
if (options.rilRequestError) {
|
||||
return;
|
||||
}
|
||||
|
||||
let response = Buf.readUint32List()[0];
|
||||
this.sendDOMMessage({type: "iccgetcardlock",
|
||||
lockType: "pin",
|
||||
enabled: response == 0 ? false : true,
|
||||
requestId: options.requestId});
|
||||
};
|
||||
RIL[REQUEST_SET_FACILITY_LOCK] = function REQUEST_SET_FACILITY_LOCK(length, options) {
|
||||
this.sendDOMMessage({type: "iccsetcardlock",
|
||||
lockType: "pin",
|
||||
result: options.rilRequestError == 0 ? true : false,
|
||||
retryCount: length ? Buf.readUint32List()[0] : -1,
|
||||
requestId: options.requestId});
|
||||
};
|
||||
RIL[REQUEST_CHANGE_BARRING_PASSWORD] = null;
|
||||
RIL[REQUEST_QUERY_NETWORK_SELECTION_MODE] = function REQUEST_QUERY_NETWORK_SELECTION_MODE(length, options) {
|
||||
if (options.rilRequestError) {
|
||||
|
Loading…
Reference in New Issue
Block a user