зеркало из https://github.com/mozilla/gecko-dev.git
Merge mozilla-central and birch
This commit is contained in:
Коммит
5c4d749c4e
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "MediaResource.h"
|
||||
#include "MediaDecoderReader.h"
|
||||
#include <ui/GraphicBuffer.h>
|
||||
|
||||
namespace android {
|
||||
class OmxDecoder;
|
||||
|
|
|
@ -14,7 +14,6 @@ const Cu = Components.utils;
|
|||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
||||
Cu.import("resource://gre/modules/ObjectWrapper.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(Services, "DOMRequest", function() {
|
||||
return Cc["@mozilla.org/dom/dom-request-service;1"].getService(Ci.nsIDOMRequestService);
|
||||
|
@ -477,34 +476,6 @@ ContactManager.prototype = {
|
|||
this._pushArray(data.cachedContacts, result);
|
||||
}
|
||||
break;
|
||||
case "Contacts:GetSimContacts:Return:OK":
|
||||
req = this.getRequest(msg.requestID);
|
||||
if (req) {
|
||||
let result = contacts.map(function(c) {
|
||||
let contact = new Contact();
|
||||
let prop = {name: [c.alphaId], tel: [ { value: c.number } ]};
|
||||
|
||||
if (c.email) {
|
||||
prop.email = [{value: c.email}];
|
||||
}
|
||||
|
||||
// ANR - Additional Number
|
||||
if (c.anr) {
|
||||
for (let i = 0; i < c.anr.length; i++) {
|
||||
prop.tel.push({value: c.anr[i]});
|
||||
}
|
||||
}
|
||||
|
||||
contact.init(prop);
|
||||
return contact;
|
||||
});
|
||||
if (DEBUG) debug("result: " + JSON.stringify(result));
|
||||
Services.DOMRequest.fireSuccess(req.request,
|
||||
ObjectWrapper.wrap(result, this._window));
|
||||
} else {
|
||||
if (DEBUG) debug("no request stored!" + msg.requestID);
|
||||
}
|
||||
break;
|
||||
case "Contact:Save:Return:OK":
|
||||
case "Contacts:Clear:Return:OK":
|
||||
case "Contact:Remove:Return:OK":
|
||||
|
@ -516,7 +487,6 @@ ContactManager.prototype = {
|
|||
case "Contact:Save:Return:KO":
|
||||
case "Contact:Remove:Return:KO":
|
||||
case "Contacts:Clear:Return:KO":
|
||||
case "Contacts:GetSimContacts:Return:KO":
|
||||
req = this.getRequest(msg.requestID);
|
||||
if (req)
|
||||
Services.DOMRequest.fireError(req.request, msg.errorMsg);
|
||||
|
@ -570,7 +540,6 @@ ContactManager.prototype = {
|
|||
access = "write";
|
||||
break;
|
||||
case "find":
|
||||
case "getSimContacts":
|
||||
case "listen":
|
||||
case "revision":
|
||||
access = "read";
|
||||
|
@ -743,25 +712,6 @@ ContactManager.prototype = {
|
|||
return request;
|
||||
},
|
||||
|
||||
getSimContacts: function(aContactType) {
|
||||
let request;
|
||||
request = this.createRequest();
|
||||
let options = {contactType: aContactType};
|
||||
|
||||
let allowCallback = function() {
|
||||
if (DEBUG) debug("getSimContacts " + aContactType);
|
||||
cpmm.sendAsyncMessage("Contacts:GetSimContacts",
|
||||
{requestID: this.getRequestId({request: request, reason: "getSimContacts"}),
|
||||
options: options});
|
||||
}.bind(this);
|
||||
|
||||
let cancelCallback = function() {
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
this.askPermission("getSimContacts", request, allowCallback, cancelCallback);
|
||||
return request;
|
||||
},
|
||||
|
||||
getRevision: function() {
|
||||
let request = this.createRequest();
|
||||
|
||||
|
@ -784,8 +734,6 @@ ContactManager.prototype = {
|
|||
"Contacts:Clear:Return:OK", "Contacts:Clear:Return:KO",
|
||||
"Contact:Save:Return:OK", "Contact:Save:Return:KO",
|
||||
"Contact:Remove:Return:OK", "Contact:Remove:Return:KO",
|
||||
"Contacts:GetSimContacts:Return:OK",
|
||||
"Contacts:GetSimContacts:Return:KO",
|
||||
"Contact:Changed",
|
||||
"PermissionPromptHelper:AskPermission:OK",
|
||||
"Contacts:GetAll:Next",
|
||||
|
|
|
@ -21,19 +21,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
|
|||
"@mozilla.org/parentprocessmessagemanager;1",
|
||||
"nsIMessageListenerManager");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "mRIL", function () {
|
||||
let telephony = Cc["@mozilla.org/ril;1"];
|
||||
if (!telephony) {
|
||||
// Return a mock RIL because B2G Desktop build does not support telephony.
|
||||
return {
|
||||
getICCContacts: function(aContactType, aCallback) {
|
||||
aCallback("!telephony", null, null);
|
||||
}
|
||||
};
|
||||
}
|
||||
return telephony.getService(Ci.nsIRadioInterfaceLayer);
|
||||
});
|
||||
|
||||
let myGlobal = this;
|
||||
|
||||
let ContactService = {
|
||||
|
@ -41,9 +28,8 @@ let ContactService = {
|
|||
if (DEBUG) debug("Init");
|
||||
this._messages = ["Contacts:Find", "Contacts:GetAll", "Contacts:GetAll:SendNow",
|
||||
"Contacts:Clear", "Contact:Save",
|
||||
"Contact:Remove", "Contacts:GetSimContacts",
|
||||
"Contacts:RegisterForMessages", "child-process-shutdown",
|
||||
"Contacts:GetRevision"];
|
||||
"Contact:Remove", "Contacts:RegisterForMessages",
|
||||
"child-process-shutdown", "Contacts:GetRevision"];
|
||||
this._children = [];
|
||||
this._messages.forEach(function(msgName) {
|
||||
ppmm.addMessageListener(msgName, this);
|
||||
|
@ -173,24 +159,6 @@ let ContactService = {
|
|||
function(aErrorMsg) { mm.sendAsyncMessage("Contacts:Clear:Return:KO", { requestID: msg.requestID, errorMsg: aErrorMsg }); }.bind(this)
|
||||
);
|
||||
break;
|
||||
case "Contacts:GetSimContacts":
|
||||
if (!this.assertPermission(aMessage, "contacts-read")) {
|
||||
return null;
|
||||
}
|
||||
mRIL.getICCContacts(
|
||||
msg.options.contactType,
|
||||
function (aErrorMsg, aType, aContacts) {
|
||||
if (aErrorMsg !== 'undefined') {
|
||||
mm.sendAsyncMessage("Contacts:GetSimContacts:Return:KO",
|
||||
{requestID: msg.requestID,
|
||||
errorMsg: aErrorMsg});
|
||||
} else {
|
||||
mm.sendAsyncMessage("Contacts:GetSimContacts:Return:OK",
|
||||
{requestID: msg.requestID,
|
||||
contacts: aContacts});
|
||||
}
|
||||
}.bind(this));
|
||||
break;
|
||||
case "Contacts:GetRevision":
|
||||
if (!this.assertPermission(aMessage, "contacts-read")) {
|
||||
return null;
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
[DEFAULT]
|
||||
b2g = true
|
||||
browser = false
|
||||
qemu = true
|
||||
|
||||
[test_sim_contacts.js]
|
|
@ -1,68 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 30000;
|
||||
|
||||
SpecialPowers.addPermission("contacts-read", true, document);
|
||||
// TODO: see bug 804623, We are preventing "read" operations
|
||||
// even if just "write" has been set to DENY_ACTION.
|
||||
// Bug 816900: Because PermissionPromptHelper.jsm will expand the
|
||||
// contacts-read to contacts-read, contacts-write, contacts-create,
|
||||
// we add the other two permissions here.
|
||||
SpecialPowers.addPermission("contacts-write", true, document);
|
||||
SpecialPowers.addPermission("contacts-create", true, document);
|
||||
|
||||
let mozContacts = window.navigator.mozContacts;
|
||||
ok(mozContacts);
|
||||
|
||||
function testImportSimContacts() {
|
||||
let request = mozContacts.getSimContacts("ADN");
|
||||
request.onsuccess = function onsuccess() {
|
||||
let simContacts = request.result;
|
||||
|
||||
is(Array.isArray(simContacts), true);
|
||||
|
||||
// These SIM contacts are harded in external/qemu/telephony/sim_card.c
|
||||
is(simContacts[0].name, "Mozilla");
|
||||
is(simContacts[0].tel[0].value, "15555218201");
|
||||
|
||||
is(simContacts[1].name, "Saßê黃");
|
||||
is(simContacts[1].tel[0].value, "15555218202");
|
||||
|
||||
is(simContacts[2].name, "Fire 火");
|
||||
is(simContacts[2].tel[0].value, "15555218203");
|
||||
|
||||
is(simContacts[3].name, "Huang 黃");
|
||||
is(simContacts[3].tel[0].value, "15555218204");
|
||||
|
||||
runNextTest();
|
||||
};
|
||||
|
||||
request.onerror = function onerror() {
|
||||
ok(false, "Cannot get Sim Contacts");
|
||||
runNextTest();
|
||||
};
|
||||
};
|
||||
|
||||
let tests = [
|
||||
testImportSimContacts,
|
||||
];
|
||||
|
||||
function runNextTest() {
|
||||
let test = tests.pop();
|
||||
if (!test) {
|
||||
cleanUp();
|
||||
return;
|
||||
}
|
||||
|
||||
test();
|
||||
}
|
||||
|
||||
function cleanUp() {
|
||||
SpecialPowers.removePermission("contacts-read", document);
|
||||
SpecialPowers.removePermission("contacts-write", document);
|
||||
SpecialPowers.removePermission("contacts-create", document);
|
||||
finish();
|
||||
}
|
||||
|
||||
runNextTest();
|
|
@ -9,7 +9,7 @@ interface nsIDOMEventListener;
|
|||
interface nsIDOMDOMRequest;
|
||||
interface nsIDOMContact;
|
||||
|
||||
[scriptable, builtinclass, uuid(9af5378e-03ce-4c5f-8ec1-50ae774b5612)]
|
||||
[scriptable, builtinclass, uuid(fcc1971a-ddb7-4b38-8474-25bef7e5bf40)]
|
||||
interface nsIDOMMozIccManager : nsIDOMEventTarget
|
||||
{
|
||||
/**
|
||||
|
@ -275,6 +275,18 @@ interface nsIDOMMozIccManager : nsIDOMEventTarget
|
|||
*/
|
||||
[implicit_jscontext] attribute jsval onstksessionend;
|
||||
|
||||
// UICC Phonebook Interfaces.
|
||||
|
||||
/**
|
||||
* Read ICC contacts.
|
||||
*
|
||||
* @param contactType
|
||||
* One of type as below,
|
||||
* - 'adn': Abbreviated Dialling Number
|
||||
* - 'fdn': Fixed Dialling Number
|
||||
*/
|
||||
nsIDOMDOMRequest readContacts(in DOMString contactType);
|
||||
|
||||
/**
|
||||
* Update ICC Phonebook contact.
|
||||
*
|
||||
|
@ -291,6 +303,8 @@ interface nsIDOMMozIccManager : nsIDOMEventTarget
|
|||
in nsIDOMContact contact,
|
||||
[optional] in DOMString pin2);
|
||||
|
||||
// End of UICC Phonebook Interfaces.
|
||||
|
||||
// UICC Secure Element Interfaces
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@ interface nsIIccListener : nsISupports
|
|||
/**
|
||||
* XPCOM component (in the content process) that provides the ICC information.
|
||||
*/
|
||||
[scriptable, uuid(c74b434a-fb2a-4e22-a6cd-1ac353e3f4ce)]
|
||||
[scriptable, uuid(041aee4f-fad0-4ed8-a11c-774b1aedd09e)]
|
||||
interface nsIIccProvider : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -29,6 +29,9 @@ interface nsIIccProvider : nsISupports
|
|||
void registerIccMsg(in nsIIccListener listener);
|
||||
void unregisterIccMsg(in nsIIccListener listener);
|
||||
|
||||
/**
|
||||
* STK interfaces.
|
||||
*/
|
||||
void sendStkResponse(in nsIDOMWindow window,
|
||||
in jsval command,
|
||||
in jsval response);
|
||||
|
@ -40,6 +43,12 @@ interface nsIIccProvider : nsISupports
|
|||
void sendStkEventDownload(in nsIDOMWindow window,
|
||||
in jsval event);
|
||||
|
||||
/**
|
||||
* Phonebook interfaces.
|
||||
*/
|
||||
nsIDOMDOMRequest readContacts(in nsIDOMWindow window,
|
||||
in DOMString contactType);
|
||||
|
||||
nsIDOMDOMRequest updateContact(in nsIDOMWindow window,
|
||||
in DOMString contactType,
|
||||
in nsIDOMContact contact,
|
||||
|
|
|
@ -157,6 +157,16 @@ IccManager::IccCloseChannel(int32_t aChannel, nsIDOMDOMRequest** aRequest)
|
|||
return mProvider->IccCloseChannel(GetOwner(), aChannel, aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IccManager::ReadContacts(const nsAString& aContactType, nsIDOMDOMRequest** aRequest)
|
||||
{
|
||||
if (!mProvider) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return mProvider->ReadContacts(GetOwner(), aContactType, aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IccManager::UpdateContact(const nsAString& aContactType,
|
||||
nsIDOMContact* aContact,
|
||||
|
|
|
@ -5,17 +5,36 @@ MARIONETTE_TIMEOUT = 30000;
|
|||
|
||||
SpecialPowers.addPermission("mobileconnection", true, document);
|
||||
|
||||
// TODO: bug 847741 move getSimContacts to IccManager
|
||||
SpecialPowers.addPermission("contacts-read", true, document);
|
||||
SpecialPowers.addPermission("contacts-write", true, document);
|
||||
SpecialPowers.addPermission("contacts-create", true, document);
|
||||
|
||||
let icc = navigator.mozMobileConnection.icc;
|
||||
ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
|
||||
|
||||
// TODO: bug 847741 move getSimContacts to IccManager
|
||||
let mozContacts = window.navigator.mozContacts;
|
||||
ok(mozContacts);
|
||||
function testImportSimContacts() {
|
||||
let request = icc.readContacts("adn");
|
||||
request.onsuccess = function onsuccess() {
|
||||
let simContacts = request.result;
|
||||
|
||||
is(Array.isArray(simContacts), true);
|
||||
|
||||
is(simContacts[0].name, "Mozilla");
|
||||
is(simContacts[0].tel[0].value, "15555218201");
|
||||
|
||||
is(simContacts[1].name, "Saßê黃");
|
||||
is(simContacts[1].tel[0].value, "15555218202");
|
||||
|
||||
is(simContacts[2].name, "Fire 火");
|
||||
is(simContacts[2].tel[0].value, "15555218203");
|
||||
|
||||
is(simContacts[3].name, "Huang 黃");
|
||||
is(simContacts[3].tel[0].value, "15555218204");
|
||||
|
||||
runNextTest();
|
||||
};
|
||||
|
||||
request.onerror = function onerror() {
|
||||
ok(false, "Cannot get Sim Contacts");
|
||||
runNextTest();
|
||||
};
|
||||
};
|
||||
|
||||
function testAddIccContact() {
|
||||
let contact = new mozContact();
|
||||
|
@ -25,15 +44,12 @@ function testAddIccContact() {
|
|||
tel: [{value: "0912345678"}]
|
||||
});
|
||||
|
||||
// TODO: 'ADN' should change to use lower case
|
||||
let updateRequest = icc.updateContact("ADN", contact);
|
||||
let updateRequest = icc.updateContact("adn", contact);
|
||||
|
||||
updateRequest.onsuccess = function onsuccess() {
|
||||
// Get ICC contact for checking new contact
|
||||
|
||||
// TODO: 1. bug 847741 move getSimContacts to IccManager
|
||||
// 2. 'ADN' should change to use lower case
|
||||
let getRequest = mozContacts.getSimContacts("ADN");
|
||||
let getRequest = icc.readContacts("adn");
|
||||
|
||||
getRequest.onsuccess = function onsuccess() {
|
||||
let simContacts = getRequest.result;
|
||||
|
@ -60,6 +76,7 @@ function testAddIccContact() {
|
|||
};
|
||||
|
||||
let tests = [
|
||||
testImportSimContacts,
|
||||
testAddIccContact,
|
||||
];
|
||||
|
||||
|
@ -75,12 +92,6 @@ function runNextTest() {
|
|||
|
||||
function cleanUp() {
|
||||
SpecialPowers.removePermission("mobileconnection", document);
|
||||
|
||||
// TODO: bug 847741 move getSimContacts to IccManager
|
||||
SpecialPowers.removePermission("contacts-read", document);
|
||||
SpecialPowers.removePermission("contacts-write", document);
|
||||
SpecialPowers.removePermission("contacts-create", document);
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ interface nsIDOMContact : nsIContactProperties
|
|||
void init(in nsIContactProperties properties); // Workaround BUG 723206
|
||||
};
|
||||
|
||||
[scriptable, uuid(7bfb6481-f946-4254-afc5-d7fe9f5c45a3)]
|
||||
[scriptable, uuid(e01ebfe7-e972-4e01-b04b-1d162dc74983)]
|
||||
interface nsIDOMContactManager : nsISupports
|
||||
{
|
||||
nsIDOMDOMRequest find(in nsIContactFindOptions options);
|
||||
|
@ -33,8 +33,6 @@ interface nsIDOMContactManager : nsISupports
|
|||
|
||||
nsIDOMDOMRequest remove(in nsIDOMContact contact);
|
||||
|
||||
nsIDOMDOMRequest getSimContacts(in DOMString type);
|
||||
|
||||
attribute nsIDOMEventListener oncontactchange;
|
||||
|
||||
nsIDOMDOMRequest getRevision();
|
||||
|
|
|
@ -17,9 +17,10 @@
|
|||
|
||||
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");
|
||||
Cu.import("resource://gre/modules/ObjectWrapper.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
var RIL = {};
|
||||
Cu.import("resource://gre/modules/ril_consts.js", RIL);
|
||||
|
@ -84,6 +85,7 @@ const RIL_IPC_MSG_NAMES = [
|
|||
"RIL:IccOpenChannel",
|
||||
"RIL:IccCloseChannel",
|
||||
"RIL:IccExchangeAPDU",
|
||||
"RIL:ReadIccContacts",
|
||||
"RIL:UpdateIccContact"
|
||||
];
|
||||
|
||||
|
@ -321,6 +323,7 @@ function RILContentHelper() {
|
|||
|
||||
this.initRequests();
|
||||
this.initMessageListener(RIL_IPC_MSG_NAMES);
|
||||
this._windowsMap = [],
|
||||
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
||||
}
|
||||
|
||||
|
@ -383,6 +386,8 @@ RILContentHelper.prototype = {
|
|||
this.updateInfo(srcNetwork, network);
|
||||
},
|
||||
|
||||
_windowsMap: null,
|
||||
|
||||
// nsIRILContentHelper
|
||||
|
||||
rilContext: null,
|
||||
|
@ -662,6 +667,21 @@ RILContentHelper.prototype = {
|
|||
return request;
|
||||
},
|
||||
|
||||
readContacts: function readContacts(window, contactType) {
|
||||
if (window == null) {
|
||||
throw Components.Exception("Can't get window object",
|
||||
Cr.NS_ERROR_UNEXPECTED);
|
||||
}
|
||||
|
||||
let request = Services.DOMRequest.createRequest(window);
|
||||
let requestId = this.getRequestId(request);
|
||||
this._windowsMap[requestId] = window;
|
||||
|
||||
cpmm.sendAsyncMessage("RIL:ReadIccContacts", {requestId: requestId,
|
||||
contactType: contactType});
|
||||
return request;
|
||||
},
|
||||
|
||||
updateContact: function updateContact(window, contactType, contact, pin2) {
|
||||
if (window == null) {
|
||||
throw Components.Exception("Can't get window object",
|
||||
|
@ -1123,6 +1143,9 @@ RILContentHelper.prototype = {
|
|||
case "RIL:IccExchangeAPDU":
|
||||
this.handleIccExchangeAPDU(msg.json);
|
||||
break;
|
||||
case "RIL:ReadIccContacts":
|
||||
this.handleReadIccContacts(msg.json);
|
||||
break;
|
||||
case "RIL:UpdateIccContact":
|
||||
this.handleUpdateIccContact(msg.json);
|
||||
break;
|
||||
|
@ -1243,6 +1266,38 @@ RILContentHelper.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
handleReadIccContacts: function handleReadIccContacts(message) {
|
||||
if (message.errorMsg) {
|
||||
this.fireRequestError(message.requestId, message.errorMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
let window = this._windowsMap[message.requestId];
|
||||
delete this._windowsMap[message.requestId];
|
||||
let contacts = message.contacts;
|
||||
let result = contacts.map(function(c) {
|
||||
let contact = Cc["@mozilla.org/contact;1"].createInstance(Ci.nsIDOMContact);
|
||||
let prop = {name: [c.alphaId], tel: [{value: c.number}]};
|
||||
|
||||
if (c.email) {
|
||||
prop.email = [{value: c.email}];
|
||||
}
|
||||
|
||||
// ANR - Additional Number
|
||||
let anrLen = c.anr ? c.anr.length : 0;
|
||||
for (let i = 0; i < anrLen; i++) {
|
||||
prop.tel.push({value: c.anr[i]});
|
||||
}
|
||||
|
||||
contact.init(prop);
|
||||
return contact;
|
||||
});
|
||||
|
||||
let request = this.getRequest(message.requestId);
|
||||
this.fireRequestSuccess(message.requestId,
|
||||
ObjectWrapper.wrap(result, window));
|
||||
},
|
||||
|
||||
handleUpdateIccContact: function handleUpdateIccContact(message) {
|
||||
if (message.errorMsg) {
|
||||
this.fireRequestError(message.requestId, message.errorMsg);
|
||||
|
|
|
@ -99,6 +99,7 @@ const RIL_IPC_MOBILECONNECTION_MSG_NAMES = [
|
|||
"RIL:IccOpenChannel",
|
||||
"RIL:IccExchangeAPDU",
|
||||
"RIL:IccCloseChannel",
|
||||
"RIL:ReadIccContacts",
|
||||
"RIL:UpdateIccContact",
|
||||
"RIL:RegisterMobileConnectionMsg",
|
||||
"RIL:RegisterIccMsg",
|
||||
|
@ -512,6 +513,10 @@ RadioInterfaceLayer.prototype = {
|
|||
this.saveRequestTarget(msg);
|
||||
this.iccExchangeAPDU(msg.json);
|
||||
break;
|
||||
case "RIL:ReadIccContacts":
|
||||
this.saveRequestTarget(msg);
|
||||
this.readIccContacts(msg.json);
|
||||
break;
|
||||
case "RIL:UpdateIccContact":
|
||||
this.saveRequestTarget(msg);
|
||||
this.updateIccContact(msg.json);
|
||||
|
@ -674,16 +679,7 @@ RadioInterfaceLayer.prototype = {
|
|||
this.handleIccCardLockResult(message);
|
||||
break;
|
||||
case "icccontacts":
|
||||
if (!this._contactsCallbacks) {
|
||||
return;
|
||||
}
|
||||
let callback = this._contactsCallbacks[message.requestId];
|
||||
if (callback) {
|
||||
delete this._contactsCallbacks[message.requestId];
|
||||
callback.receiveContactsList(message.errorMsg,
|
||||
message.contactType,
|
||||
message.contacts);
|
||||
}
|
||||
this.handleReadIccContacts(message);
|
||||
break;
|
||||
case "icccontactupdate":
|
||||
this.handleUpdateIccContact(message);
|
||||
|
@ -1376,6 +1372,11 @@ RadioInterfaceLayer.prototype = {
|
|||
this._sendRequestResults("RIL:EnumerateCalls", options);
|
||||
},
|
||||
|
||||
handleReadIccContacts: function handleReadIccContacts(message) {
|
||||
debug("handleReadIccContacts: " + JSON.stringify(message));
|
||||
this._sendRequestResults("RIL:ReadIccContacts", message);
|
||||
},
|
||||
|
||||
handleUpdateIccContact: function handleUpdateIccContact(message) {
|
||||
debug("handleUpdateIccContact: " + JSON.stringify(message));
|
||||
this._sendRequestResults("RIL:UpdateIccContact", message);
|
||||
|
@ -2881,16 +2882,9 @@ RadioInterfaceLayer.prototype = {
|
|||
this.worker.postMessage(message);
|
||||
},
|
||||
|
||||
_contactsCallbacks: null,
|
||||
getICCContacts: function getICCContacts(contactType, callback) {
|
||||
if (!this._contactsCallbacks) {
|
||||
this._contactsCallbacks = {};
|
||||
}
|
||||
let requestId = Math.floor(Math.random() * 1000);
|
||||
this._contactsCallbacks[requestId] = callback;
|
||||
this.worker.postMessage({rilMessageType: "getICCContacts",
|
||||
contactType: contactType,
|
||||
requestId: requestId});
|
||||
readIccContacts: function readIccContacts(message) {
|
||||
message.rilMessageType = "readICCContacts";
|
||||
this.worker.postMessage(message);
|
||||
},
|
||||
|
||||
updateIccContact: function updateIccContact(message) {
|
||||
|
|
|
@ -51,24 +51,6 @@ interface nsIRILDataCallback : nsISupports
|
|||
in unsigned long length);
|
||||
};
|
||||
|
||||
[scriptable, function, uuid(a94282b6-da60-4daf-95c1-82ee6889d0df)]
|
||||
interface nsIRILContactCallback : nsISupports
|
||||
{
|
||||
/**
|
||||
* Called when nsIRadioInterfaceLayer is asked to provide ICC contacts.
|
||||
*
|
||||
* @param errorMsg
|
||||
* error message from RIL.
|
||||
* @param contactType
|
||||
* Type of the dialling number, i.e. ADN, FDN.
|
||||
* @param contacts
|
||||
* Array of the ICC contacts of the specified type.
|
||||
*/
|
||||
void receiveContactsList(in DOMString errorMsg,
|
||||
in DOMString contactType,
|
||||
in jsval contacts);
|
||||
};
|
||||
|
||||
[scriptable, uuid(c0c5cb9f-6372-4b5a-b74c-baacc2da5e4f)]
|
||||
interface nsIVoicemailInfo : nsISupports
|
||||
{
|
||||
|
@ -95,7 +77,7 @@ interface nsIRilContext : nsISupports
|
|||
readonly attribute nsIDOMMozMobileConnectionInfo data;
|
||||
};
|
||||
|
||||
[scriptable, uuid(9a914550-8f7a-11e2-9e96-0800200c9a66)]
|
||||
[scriptable, uuid(c1c9d1e6-fec6-4c99-880d-7a310d736e64)]
|
||||
interface nsIRadioInterfaceLayer : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -136,19 +118,4 @@ interface nsIRadioInterfaceLayer : nsISupports
|
|||
void sendSMS(in DOMString number,
|
||||
in DOMString message,
|
||||
in nsIMobileMessageCallback request);
|
||||
|
||||
/**
|
||||
* ICC-related functionality.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get ICC Contact List.
|
||||
*
|
||||
* @param contactType One of the values below.
|
||||
* "ADN" (Abbreviated Dialling Numbers)
|
||||
* "FDN" (Fixed Dialling Numbers)
|
||||
* @param callback A nsIRILContactCallback object.
|
||||
*/
|
||||
void getICCContacts(in DOMString contactType,
|
||||
in nsIRILContactCallback callback);
|
||||
};
|
||||
|
|
|
@ -53,6 +53,8 @@ const PDU_HEX_OCTET_SIZE = 4;
|
|||
|
||||
const DEFAULT_EMERGENCY_NUMBERS = ["112", "911"];
|
||||
|
||||
const ICC_MAX_LINEAR_FIXED_RECORDS = 0xfe;
|
||||
|
||||
// MMI match groups
|
||||
const MMI_MATCH_GROUP_FULL_MMI = 1;
|
||||
const MMI_MATCH_GROUP_MMI_PROCEDURE = 2;
|
||||
|
@ -1301,14 +1303,14 @@ let RIL = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Get UICC Phonebook.
|
||||
* Read UICC Phonebook contacts.
|
||||
*
|
||||
* @param contactType
|
||||
* "ADN" or "FDN".
|
||||
* "adn" or "fdn".
|
||||
* @param requestId
|
||||
* Request id from RadioInterfaceLayer.
|
||||
*/
|
||||
getICCContacts: function getICCContacts(options) {
|
||||
readICCContacts: function readICCContacts(options) {
|
||||
if (!this.appType) {
|
||||
options.rilMessageType = "icccontacts";
|
||||
options.errorMsg = GECKO_ERROR_REQUEST_NOT_SUPPORTED;
|
||||
|
@ -1334,7 +1336,7 @@ let RIL = {
|
|||
/**
|
||||
* Update UICC Phonebook.
|
||||
*
|
||||
* @param contactType "ADN" or "FDN".
|
||||
* @param contactType "adn" or "fdn".
|
||||
* @param contact The contact will be updated.
|
||||
* @param pin2 PIN2 is required for updating FDN.
|
||||
* @param requestId Request id from RadioInterfaceLayer.
|
||||
|
@ -2939,7 +2941,7 @@ let RIL = {
|
|||
// For type SIM, we need to check EF_phase first.
|
||||
// Other types of ICC we can send Terminal_Profile immediately.
|
||||
if (this.appType == CARD_APPTYPE_SIM) {
|
||||
ICCRecordHelper.getICCPhase();
|
||||
ICCRecordHelper.readICCPhase();
|
||||
ICCRecordHelper.fetchICCRecords();
|
||||
} else if (this.appType == CARD_APPTYPE_USIM) {
|
||||
this.sendStkTerminalProfile(STK_SUPPORTED_TERMINAL_PROFILE);
|
||||
|
@ -9906,7 +9908,7 @@ let ICCIOHelper = {
|
|||
* Process a ICC_COMMAND_GET_RESPONSE type command for REQUEST_SIM_IO.
|
||||
*/
|
||||
processICCIOGetResponse: function processICCIOGetResponse(options) {
|
||||
let length = Buf.readUint32();
|
||||
let strLen = Buf.readUint32();
|
||||
|
||||
// The format is from TS 51.011, clause 9.2.1
|
||||
|
||||
|
@ -9953,7 +9955,7 @@ let ICCIOHelper = {
|
|||
Buf.seekIncoming(1 * PDU_HEX_OCTET_SIZE);
|
||||
}
|
||||
|
||||
Buf.readStringDelimiter(length);
|
||||
Buf.readStringDelimiter(strLen);
|
||||
|
||||
if (options.callback) {
|
||||
options.callback(options);
|
||||
|
@ -10029,21 +10031,21 @@ let ICCRecordHelper = {
|
|||
* Fetch ICC records.
|
||||
*/
|
||||
fetchICCRecords: function fetchICCRecords() {
|
||||
this.getICCID();
|
||||
this.readICCID();
|
||||
RIL.getIMSI();
|
||||
this.getMSISDN();
|
||||
this.getAD();
|
||||
this.getSST();
|
||||
this.getMBDN();
|
||||
this.readMSISDN();
|
||||
this.readAD();
|
||||
this.readSST();
|
||||
this.readMBDN();
|
||||
},
|
||||
|
||||
/**
|
||||
* Get EF_phase.
|
||||
* Read EF_phase.
|
||||
* This EF is only available in SIM.
|
||||
*/
|
||||
getICCPhase: function getICCPhase() {
|
||||
readICCPhase: function readICCPhase() {
|
||||
function callback() {
|
||||
let length = Buf.readUint32();
|
||||
let strLen = Buf.readUint32();
|
||||
|
||||
let phase = GsmPDUHelper.readHexOctet();
|
||||
// If EF_phase is coded '03' or greater, an ME supporting STK shall
|
||||
|
@ -10052,7 +10054,7 @@ let ICCRecordHelper = {
|
|||
RIL.sendStkTerminalProfile(STK_SUPPORTED_TERMINAL_PROFILE);
|
||||
}
|
||||
|
||||
Buf.readStringDelimiter(length);
|
||||
Buf.readStringDelimiter(strLen);
|
||||
}
|
||||
|
||||
ICCIOHelper.loadTransparentEF({fileId: ICC_EF_PHASE,
|
||||
|
@ -10062,11 +10064,12 @@ let ICCRecordHelper = {
|
|||
/**
|
||||
* Read the ICCID.
|
||||
*/
|
||||
getICCID: function getICCID() {
|
||||
readICCID: function readICCID() {
|
||||
function callback() {
|
||||
let length = Buf.readUint32();
|
||||
RIL.iccInfo.iccid = GsmPDUHelper.readSwappedNibbleBcdString(length / 2);
|
||||
Buf.readStringDelimiter(length);
|
||||
let strLen = Buf.readUint32();
|
||||
let octetLen = strLen / 2;
|
||||
RIL.iccInfo.iccid = GsmPDUHelper.readSwappedNibbleBcdString(octetLen);
|
||||
Buf.readStringDelimiter(strLen);
|
||||
|
||||
if (DEBUG) debug("ICCID: " + RIL.iccInfo.iccid);
|
||||
if (RIL.iccInfo.iccid) {
|
||||
|
@ -10081,7 +10084,7 @@ let ICCRecordHelper = {
|
|||
/**
|
||||
* Read the MSISDN from the ICC.
|
||||
*/
|
||||
getMSISDN: function getMSISDN() {
|
||||
readMSISDN: function readMSISDN() {
|
||||
function callback(options) {
|
||||
let contact = GsmPDUHelper.readAlphaIdDiallingNumber(options.recordSize);
|
||||
if (!contact || RIL.iccInfo.msisdn === contact.number) {
|
||||
|
@ -10099,13 +10102,13 @@ let ICCRecordHelper = {
|
|||
/**
|
||||
* Read the AD (Administrative Data) from the ICC.
|
||||
*/
|
||||
getAD: function getAD() {
|
||||
readAD: function readAD() {
|
||||
function callback() {
|
||||
let length = Buf.readUint32();
|
||||
let strLen = Buf.readUint32();
|
||||
// Each octet is encoded into two chars.
|
||||
let len = length / 2;
|
||||
let ad = GsmPDUHelper.readHexOctetArray(len);
|
||||
Buf.readStringDelimiter(length);
|
||||
let octetLen = strLen / 2;
|
||||
let ad = GsmPDUHelper.readHexOctetArray(octetLen);
|
||||
Buf.readStringDelimiter(strLen);
|
||||
|
||||
if (DEBUG) {
|
||||
let str = "";
|
||||
|
@ -10133,15 +10136,15 @@ let ICCRecordHelper = {
|
|||
/**
|
||||
* Read the SPN (Service Provider Name) from the ICC.
|
||||
*/
|
||||
getSPN: function getSPN() {
|
||||
readSPN: function readSPN() {
|
||||
function callback() {
|
||||
let length = Buf.readUint32();
|
||||
let strLen = Buf.readUint32();
|
||||
// Each octet is encoded into two chars.
|
||||
// Minus 1 because the first octet is used to store display condition.
|
||||
let len = (length / 2) - 1;
|
||||
let octetLen = strLen / 2;
|
||||
let spnDisplayCondition = GsmPDUHelper.readHexOctet();
|
||||
let spn = GsmPDUHelper.readAlphaIdentifier(len);
|
||||
Buf.readStringDelimiter(length);
|
||||
// Minus 1 because the first octet is used to store display condition.
|
||||
let spn = GsmPDUHelper.readAlphaIdentifier(octetLen - 1);
|
||||
Buf.readStringDelimiter(strLen);
|
||||
|
||||
if (DEBUG) {
|
||||
debug("SPN: spn = " + spn +
|
||||
|
@ -10164,13 +10167,13 @@ let ICCRecordHelper = {
|
|||
/**
|
||||
* Read the (U)SIM Service Table from the ICC.
|
||||
*/
|
||||
getSST: function getSST() {
|
||||
readSST: function readSST() {
|
||||
function callback() {
|
||||
let length = Buf.readUint32();
|
||||
let strLen = Buf.readUint32();
|
||||
// Each octet is encoded into two chars.
|
||||
let len = length / 2;
|
||||
let sst = GsmPDUHelper.readHexOctetArray(len);
|
||||
Buf.readStringDelimiter(length);
|
||||
let octetLen = strLen / 2;
|
||||
let sst = GsmPDUHelper.readHexOctetArray(octetLen);
|
||||
Buf.readStringDelimiter(strLen);
|
||||
RIL.iccInfoPrivate.sst = sst;
|
||||
if (DEBUG) {
|
||||
let str = "";
|
||||
|
@ -10183,14 +10186,14 @@ let ICCRecordHelper = {
|
|||
// Fetch SPN and PLMN list, if some of them are available.
|
||||
if (ICCUtilsHelper.isICCServiceAvailable("SPN")) {
|
||||
if (DEBUG) debug("SPN: SPN is available");
|
||||
this.getSPN();
|
||||
this.readSPN();
|
||||
} else {
|
||||
if (DEBUG) debug("SPN: SPN service is not available");
|
||||
}
|
||||
|
||||
if (ICCUtilsHelper.isICCServiceAvailable("SPDI")) {
|
||||
if (DEBUG) debug("SPDI: SPDI available.");
|
||||
this.getSPDI();
|
||||
this.readSPDI();
|
||||
} else {
|
||||
if (DEBUG) debug("SPDI: SPDI service is not available");
|
||||
}
|
||||
|
@ -10204,18 +10207,18 @@ let ICCRecordHelper = {
|
|||
|
||||
if (ICCUtilsHelper.isICCServiceAvailable("OPL")) {
|
||||
if (DEBUG) debug("OPL: OPL is available");
|
||||
this.getOPL();
|
||||
this.readOPL();
|
||||
} else {
|
||||
if (DEBUG) debug("OPL: OPL is not available");
|
||||
}
|
||||
|
||||
if (ICCUtilsHelper.isICCServiceAvailable("CBMI")) {
|
||||
this.getCBMI();
|
||||
this.readCBMI();
|
||||
} else {
|
||||
RIL.cellBroadcastConfigs.CBMI = null;
|
||||
}
|
||||
if (ICCUtilsHelper.isICCServiceAvailable("CBMIR")) {
|
||||
this.getCBMIR();
|
||||
this.readCBMIR();
|
||||
} else {
|
||||
RIL.cellBroadcastConfigs.CBMIR = null;
|
||||
}
|
||||
|
@ -10300,11 +10303,11 @@ let ICCRecordHelper = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Get ICC MBDN. (Mailbox Dialling Number)
|
||||
* Read ICC MBDN. (Mailbox Dialling Number)
|
||||
*
|
||||
* @see TS 131.102, clause 4.2.60
|
||||
*/
|
||||
getMBDN: function getMBDN() {
|
||||
readMBDN: function readMBDN() {
|
||||
function callback(options) {
|
||||
let contact = GsmPDUHelper.readAlphaIdDiallingNumber(options.recordSize);
|
||||
if (!contact || RIL.iccInfo.mbdn === contact.number){
|
||||
|
@ -10359,11 +10362,24 @@ let ICCRecordHelper = {
|
|||
}
|
||||
|
||||
let pbr = ICCUtilsHelper.parsePbrTlvs(pbrTlvs);
|
||||
if (onsuccess) {
|
||||
onsuccess(pbr);
|
||||
// EF_ADN is mandatory if and only if DF_PHONEBOOK is present.
|
||||
if (!pbr.adn) {
|
||||
let error = onerror || debug;
|
||||
error("Cannot access ADN.");
|
||||
return;
|
||||
}
|
||||
pbrs.push(pbr);
|
||||
|
||||
if (options.p1 < options.totalRecords) {
|
||||
ICCIOHelper.loadNextRecord(options);
|
||||
} else {
|
||||
if (onsuccess) {
|
||||
onsuccess(pbrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let pbrs = [];
|
||||
ICCIOHelper.loadLinearFixedEF({fileId : ICC_EF_PBR,
|
||||
callback: callback.bind(this),
|
||||
onerror: onerror});
|
||||
|
@ -10518,44 +10534,20 @@ let ICCRecordHelper = {
|
|||
onerror: onerror});
|
||||
},
|
||||
|
||||
/**
|
||||
* Read the PLMNsel (Public Land Mobile Network) from the ICC.
|
||||
*
|
||||
* See ETSI TS 100.977 section 10.3.4 EF_PLMNsel
|
||||
*/
|
||||
getPLMNSelector: function getPLMNSelector() {
|
||||
function callback() {
|
||||
if (DEBUG) debug("PLMN Selector: Process PLMN Selector");
|
||||
|
||||
let length = Buf.readUint32();
|
||||
RIL.iccInfoPrivate.PLMN = this.readPLMNEntries(length/3);
|
||||
Buf.readStringDelimiter(length);
|
||||
|
||||
if (DEBUG) debug("PLMN Selector: " + JSON.stringify(RIL.iccInfoPrivate.PLMN));
|
||||
|
||||
if (RIL.updateDisplayCondition()) {
|
||||
this.handleICCInfoChange();
|
||||
}
|
||||
}
|
||||
|
||||
// PLMN List is Service 7 in SIM, EF_PLMNsel
|
||||
ICCIOHelper.loadTransparentEF({fileId: ICC_EF_PLMNsel,
|
||||
callback: callback.bind(this)});
|
||||
},
|
||||
|
||||
/**
|
||||
* Read the SPDI (Service Provider Display Information) from the ICC.
|
||||
*
|
||||
* See TS 131.102 section 4.2.66 for USIM and TS 51.011 section 10.3.50
|
||||
* for SIM.
|
||||
*/
|
||||
getSPDI: function getSPDI() {
|
||||
readSPDI: function readSPDI() {
|
||||
function callback() {
|
||||
let length = Buf.readUint32();
|
||||
let strLen = Buf.readUint32();
|
||||
let octetLen = strLen / 2;
|
||||
let readLen = 0;
|
||||
let endLoop = false;
|
||||
RIL.iccInfoPrivate.SPDI = null;
|
||||
while ((readLen < length / 2) && !endLoop) {
|
||||
while ((readLen < octetLen) && !endLoop) {
|
||||
let tlvTag = GsmPDUHelper.readHexOctet();
|
||||
let tlvLen = GsmPDUHelper.readHexOctet();
|
||||
readLen += 2; // For tag and length fields.
|
||||
|
@ -10578,8 +10570,8 @@ let ICCRecordHelper = {
|
|||
}
|
||||
|
||||
// Consume unread octets.
|
||||
Buf.seekIncoming((length / 2 - readLen) * PDU_HEX_OCTET_SIZE);
|
||||
Buf.readStringDelimiter(length);
|
||||
Buf.seekIncoming((octetLen - readLen) * PDU_HEX_OCTET_SIZE);
|
||||
Buf.readStringDelimiter(strLen);
|
||||
|
||||
if (DEBUG) debug("SPDI: " + JSON.stringify(RIL.iccInfoPrivate.SPDI));
|
||||
if (ICCUtilsHelper.updateDisplayCondition()) {
|
||||
|
@ -10597,7 +10589,7 @@ let ICCRecordHelper = {
|
|||
*
|
||||
* @see 3GPP TS 31.102 v110.02.0 section 4.2.14 EFcbmi
|
||||
*/
|
||||
getCBMI: function getCBMI() {
|
||||
readCBMI: function readCBMI() {
|
||||
function callback() {
|
||||
let strLength = Buf.readUint32();
|
||||
|
||||
|
@ -10640,7 +10632,7 @@ let ICCRecordHelper = {
|
|||
*
|
||||
* @see 3GPP TS 31.102 v110.02.0 section 4.2.22 EFcbmir
|
||||
*/
|
||||
getCBMIR: function getCBMIR() {
|
||||
readCBMIR: function readCBMIR() {
|
||||
function callback() {
|
||||
let strLength = Buf.readUint32();
|
||||
|
||||
|
@ -10688,10 +10680,10 @@ let ICCRecordHelper = {
|
|||
* See 3GPP TS 31.102 Sec. 4.2.59 for USIM
|
||||
* 3GPP TS 51.011 Sec. 10.3.42 for SIM.
|
||||
*/
|
||||
getOPL: function getOPL() {
|
||||
readOPL: function readOPL() {
|
||||
let opl = [];
|
||||
function callback(options) {
|
||||
let len = Buf.readUint32();
|
||||
let strLen = Buf.readUint32();
|
||||
// The first 7 bytes are LAI (for UMTS) and the format of LAI is defined
|
||||
// in 3GPP TS 23.003, Sec 4.1
|
||||
// +-------------+---------+
|
||||
|
@ -10739,7 +10731,7 @@ let ICCRecordHelper = {
|
|||
} else {
|
||||
Buf.seekIncoming(5 * PDU_HEX_OCTET_SIZE);
|
||||
}
|
||||
Buf.readStringDelimiter(len);
|
||||
Buf.readStringDelimiter(strLen);
|
||||
|
||||
if (options.p1 < options.totalRecords) {
|
||||
ICCIOHelper.loadNextRecord(options);
|
||||
|
@ -10819,13 +10811,13 @@ let ICCRecordHelper = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Get free record id.
|
||||
* Find free record id.
|
||||
*
|
||||
* @param fileId EF id.
|
||||
* @param onsuccess Callback to be called when success.
|
||||
* @param onerror Callback to be called when error.
|
||||
*/
|
||||
getFreeRecordId: function getFreeRecordId(fileId, onsuccess, onerror) {
|
||||
findFreeRecordId: function findFreeRecordId(fileId, onsuccess, onerror) {
|
||||
function callback(options) {
|
||||
let strLen = Buf.readUint32();
|
||||
let octetLen = strLen / 2;
|
||||
|
@ -11302,13 +11294,13 @@ let ICCContactHelper = {
|
|||
* Helper function to read ICC contacts.
|
||||
*
|
||||
* @param appType CARD_APPTYPE_SIM or CARD_APPTYPE_USIM.
|
||||
* @param contactType "ADN" or "FDN"
|
||||
* @param contactType "adn" or "fdn".
|
||||
* @param onsuccess Callback to be called when success.
|
||||
* @param onerror Callback to be called when error.
|
||||
*/
|
||||
readICCContacts: function readICCContacts(appType, contactType, onsuccess, onerror) {
|
||||
switch (contactType) {
|
||||
case "ADN":
|
||||
case "adn":
|
||||
switch (appType) {
|
||||
case CARD_APPTYPE_SIM:
|
||||
ICCRecordHelper.readADNLike(ICC_EF_ADN, onsuccess, onerror);
|
||||
|
@ -11318,7 +11310,7 @@ let ICCContactHelper = {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case "FDN":
|
||||
case "fdn":
|
||||
ICCRecordHelper.readADNLike(ICC_EF_FDN, onsuccess, onerror);
|
||||
break;
|
||||
}
|
||||
|
@ -11328,30 +11320,28 @@ let ICCContactHelper = {
|
|||
* Helper function to find free contact record.
|
||||
*
|
||||
* @param appType CARD_APPTYPE_SIM or CARD_APPTYPE_USIM.
|
||||
* @param contactType "ADN" or "FDN".
|
||||
* @param contactType "adn" or "fdn".
|
||||
* @param onsuccess Callback to be called when success.
|
||||
* @param onerror Callback to be called when error.
|
||||
*/
|
||||
findFreeICCContact: function findFreeICCContact(appType, contactType, onsuccess, onerror) {
|
||||
switch (contactType) {
|
||||
case "ADN":
|
||||
case "adn":
|
||||
switch (appType) {
|
||||
case CARD_APPTYPE_SIM:
|
||||
ICCRecordHelper.getFreeRecordId(ICC_EF_ADN, onsuccess, onerror);
|
||||
ICCRecordHelper.findFreeRecordId(ICC_EF_ADN, onsuccess, onerror);
|
||||
break;
|
||||
case CARD_APPTYPE_USIM:
|
||||
let gotPbrCb = function gotPbrCb(pbr) {
|
||||
if (pbr.adn) {
|
||||
ICCRecordHelper.getFreeRecordId(pbr.adn.fileId, onsuccess, onerror);
|
||||
}
|
||||
let gotPbrCb = function gotPbrCb(pbrs) {
|
||||
this.findUSimFreeADNRecordId(pbrs, onsuccess, onerror);
|
||||
}.bind(this);
|
||||
|
||||
ICCRecordHelper.readPBR(gotPbrCb, onerror);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "FDN":
|
||||
ICCRecordHelper.getFreeRecordId(ICC_EF_FDN, onsuccess, onerror);
|
||||
case "fdn":
|
||||
ICCRecordHelper.findFreeRecordId(ICC_EF_FDN, onsuccess, onerror);
|
||||
break;
|
||||
default:
|
||||
if (onerror) {
|
||||
|
@ -11361,11 +11351,36 @@ let ICCContactHelper = {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Find free ADN record id in USIM.
|
||||
*
|
||||
* @param pbrs All Phonebook Reference Files read.
|
||||
* @param onsuccess Callback to be called when success.
|
||||
* @param onerror Callback to be called when error.
|
||||
*/
|
||||
findUSimFreeADNRecordId: function findUSimFreeADNRecordId(pbrs, onsuccess, onerror) {
|
||||
(function findFreeRecordId(pbrIndex) {
|
||||
if (pbrIndex >= pbrs.length) {
|
||||
let error = onerror || debug;
|
||||
error("No free record found.");
|
||||
return;
|
||||
}
|
||||
|
||||
let pbr = pbrs[pbrIndex];
|
||||
ICCRecordHelper.findFreeRecordId(
|
||||
pbr.adn.fileId,
|
||||
onsuccess,
|
||||
function (errorMsg) {
|
||||
findFreeRecordId.bind(this, pbrIndex + 1);
|
||||
}.bind(this));
|
||||
})(0);
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper function to add a new ICC contact.
|
||||
*
|
||||
* @param appType CARD_APPTYPE_SIM or CARD_APPTYPE_USIM.
|
||||
* @param contactType "ADN" or "FDN".
|
||||
* @param contactType "adn" or "fdn".
|
||||
* @param contact The contact will be added.
|
||||
* @param pin2 PIN2 is required for FDN.
|
||||
* @param onsuccess Callback to be called when success.
|
||||
|
@ -11385,7 +11400,7 @@ let ICCContactHelper = {
|
|||
* Helper function to update ICC contact.
|
||||
*
|
||||
* @param appType CARD_APPTYPE_SIM or CARD_APPTYPE_USIM.
|
||||
* @param contactType "ADN" or "FDN".
|
||||
* @param contactType "adn" or "fdn".
|
||||
* @param contact The contact will be updated.
|
||||
* @param pin2 PIN2 is required for FDN.
|
||||
* @param onsuccess Callback to be called when success.
|
||||
|
@ -11393,7 +11408,7 @@ let ICCContactHelper = {
|
|||
*/
|
||||
updateICCContact: function updateICCContact(appType, contactType, contact, pin2, onsuccess, onerror) {
|
||||
switch (contactType) {
|
||||
case "ADN":
|
||||
case "adn":
|
||||
switch (appType) {
|
||||
case CARD_APPTYPE_SIM:
|
||||
ICCRecordHelper.updateADNLike(ICC_EF_ADN, contact, null, onsuccess, onerror);
|
||||
|
@ -11403,7 +11418,7 @@ let ICCContactHelper = {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case "FDN":
|
||||
case "fdn":
|
||||
ICCRecordHelper.updateADNLike(ICC_EF_FDN, contact, pin2, onsuccess, onerror);
|
||||
break;
|
||||
default:
|
||||
|
@ -11421,23 +11436,61 @@ let ICCContactHelper = {
|
|||
* @param onerror Callback to be called when error.
|
||||
*/
|
||||
readUSimContacts: function readUSimContacts(onsuccess, onerror) {
|
||||
let gotPbrCb = function gotPbrCb(pbr) {
|
||||
if (pbr.adn) {
|
||||
let gotAdnCb = function gotAdnCb(contacts) {
|
||||
this.readSupportedPBRFields(pbr, contacts, onsuccess, onerror);
|
||||
}.bind(this);
|
||||
|
||||
let fileId = pbr.adn.fileId;
|
||||
ICCRecordHelper.readADNLike(fileId, gotAdnCb, onerror);
|
||||
} else {
|
||||
let error = onerror || debug;
|
||||
error("Cannot access ADN.");
|
||||
}
|
||||
let gotPbrCb = function gotPbrCb(pbrs) {
|
||||
this.readAllPhonebookSets(pbrs, onsuccess, onerror);
|
||||
}.bind(this);
|
||||
|
||||
ICCRecordHelper.readPBR(gotPbrCb, onerror);
|
||||
},
|
||||
|
||||
/**
|
||||
* Read all Phonebook sets.
|
||||
*
|
||||
* @param pbrs All Phonebook Reference Files read.
|
||||
* @param onsuccess Callback to be called when success.
|
||||
* @param onerror Callback to be called when error.
|
||||
*/
|
||||
readAllPhonebookSets: function readAllPhonebookSets(pbrs, onsuccess, onerror) {
|
||||
let allContacts = [], pbrIndex = 0;
|
||||
let readPhonebook = function readPhonebook(contacts) {
|
||||
if (contacts) {
|
||||
allContacts = allContacts.concat(contacts);
|
||||
}
|
||||
|
||||
let cLen = contacts ? contacts.length : 0;
|
||||
for (let i = 0; i < cLen; i++) {
|
||||
contacts[i].recordId += pbrIndex * ICC_MAX_LINEAR_FIXED_RECORDS;
|
||||
}
|
||||
|
||||
pbrIndex++;
|
||||
if (pbrIndex >= pbrs.length) {
|
||||
if (onsuccess) {
|
||||
onsuccess(allContacts);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.readPhonebookSet(pbrs[pbrIndex], readPhonebook, onerror);
|
||||
}.bind(this);
|
||||
|
||||
this.readPhonebookSet(pbrs[pbrIndex], readPhonebook, onerror);
|
||||
},
|
||||
|
||||
/**
|
||||
* Read from Phonebook Reference File.
|
||||
*
|
||||
* @param pbr Phonebook Reference File to be read.
|
||||
* @param onsuccess Callback to be called when success.
|
||||
* @param onerror Callback to be called when error.
|
||||
*/
|
||||
readPhonebookSet: function readPhonebookSet(pbr, onsuccess, onerror) {
|
||||
let gotAdnCb = function gotAdnCb(contacts) {
|
||||
this.readSupportedPBRFields(pbr, contacts, onsuccess, onerror);
|
||||
}.bind(this);
|
||||
|
||||
ICCRecordHelper.readADNLike(pbr.adn.fileId, gotAdnCb, onerror);
|
||||
},
|
||||
|
||||
/**
|
||||
* Read supported Phonebook fields.
|
||||
*
|
||||
|
@ -11449,7 +11502,7 @@ let ICCContactHelper = {
|
|||
readSupportedPBRFields: function readSupportedPBRFields(pbr, contacts, onsuccess, onerror) {
|
||||
// Current supported fields. Adding more fields to read will increasing I/O
|
||||
// time dramatically, do check the performance is acceptable when you add
|
||||
// more fileds.
|
||||
// more fields.
|
||||
const fields = ["email", "anr0"];
|
||||
|
||||
(function readField(field) {
|
||||
|
@ -11595,23 +11648,24 @@ let ICCContactHelper = {
|
|||
* @param onerror Callback to be called when error.
|
||||
*/
|
||||
updateUSimContact: function updateUSimContact(contact, onsuccess, onerror) {
|
||||
let gotPbrCb = function gotPbrCb(pbr) {
|
||||
if (pbr.adn) {
|
||||
ICCRecordHelper.updateADNLike(pbr.adn.fileId, contact, null, onsuccess, onerror);
|
||||
} else {
|
||||
if (onerror) {
|
||||
onerror("Cannot access ADN.");
|
||||
}
|
||||
}
|
||||
let gotPbrCb = function gotPbrCb(pbrs) {
|
||||
let pbrIndex = Math.floor(contact.recordId / ICC_MAX_LINEAR_FIXED_RECORDS);
|
||||
let pbr = pbrs[pbrIndex];
|
||||
this.updatePhonebookSet(pbr, contact, onsuccess, onerror);
|
||||
}.bind(this);
|
||||
|
||||
ICCRecordHelper.readPBR(gotPbrCb, onerror);
|
||||
},
|
||||
|
||||
updatePhonebookSet: function updatePhonebookSet(pbr, contact, onsuccess, onerror) {
|
||||
// TODO: Bug 859659, update EF_Email and EF_ANR.
|
||||
ICCRecordHelper.updateADNLike(pbr.adn.fileId, contact, null, onsuccess, onerror);
|
||||
}
|
||||
};
|
||||
|
||||
let RuimRecordHelper = {
|
||||
fetchRuimRecords: function fetchRuimRecords() {
|
||||
ICCRecordHelper.getICCID();
|
||||
ICCRecordHelper.readICCID();
|
||||
RIL.getIMSI();
|
||||
this.readCST();
|
||||
this.readCDMAHome();
|
||||
|
|
|
@ -1955,21 +1955,21 @@ add_test(function test_update_adn_like() {
|
|||
});
|
||||
|
||||
/**
|
||||
* Verify ICCRecordHelper.getFreeRecordId.
|
||||
* Verify ICCRecordHelper.findFreeRecordId.
|
||||
*/
|
||||
add_test(function test_get_free_record_id() {
|
||||
add_test(function test_find_free_record_id() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let record = worker.ICCRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let io = worker.ICCIOHelper;
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let recordHelper = worker.ICCRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let io = worker.ICCIOHelper;
|
||||
|
||||
function writeRecord (record) {
|
||||
// Write data size
|
||||
buf.writeUint32(record.length * 2);
|
||||
|
||||
for (let i = 0; i < record.length; i++) {
|
||||
helper.writeHexOctet(record[i]);
|
||||
pduHelper.writeHexOctet(record[i]);
|
||||
}
|
||||
|
||||
// Write string delimiter
|
||||
|
@ -1998,7 +1998,7 @@ add_test(function test_get_free_record_id() {
|
|||
};
|
||||
|
||||
let fileId = 0x0000; // Dummy.
|
||||
record.getFreeRecordId(
|
||||
recordHelper.findFreeRecordId(
|
||||
fileId,
|
||||
function (recordId) {
|
||||
do_check_eq(recordId, 2);
|
||||
|
@ -2025,7 +2025,7 @@ add_test(function test_read_icc_contacts() {
|
|||
};
|
||||
|
||||
record.readPBR = function readPBR(onsuccess, onerror) {
|
||||
onsuccess({adn:{}, email: {}, anr0: {}});
|
||||
onsuccess([{adn:{}, email: {}, anr0: {}}]);
|
||||
};
|
||||
|
||||
record.readADNLike = function readADNLike(fileId, onsuccess, onerror) {
|
||||
|
@ -2055,11 +2055,11 @@ add_test(function test_read_icc_contacts() {
|
|||
run_next_test();
|
||||
};
|
||||
|
||||
contactHelper.readICCContacts(CARD_APPTYPE_USIM, "ADN", successCb, errorCb);
|
||||
contactHelper.readICCContacts(CARD_APPTYPE_USIM, "adn", successCb, errorCb);
|
||||
});
|
||||
|
||||
/**
|
||||
* Verify ICCContactHelper.updateICCContact
|
||||
* Verify ICCContactHelper.updateICCContact with appType is CARD_APPTYPE_SIM.
|
||||
*/
|
||||
add_test(function test_update_icc_contact() {
|
||||
let worker = newUint8Worker();
|
||||
|
@ -2078,12 +2078,67 @@ add_test(function test_update_icc_contact() {
|
|||
};
|
||||
|
||||
let contact = {recordId: 1, alphaId: "test", number: "123456"};
|
||||
do_test(contact, "ADN", ICC_EF_ADN);
|
||||
do_test(contact, "FDN", ICC_EF_FDN, "1111");
|
||||
do_test(contact, "adn", ICC_EF_ADN);
|
||||
do_test(contact, "fdn", ICC_EF_FDN, "1111");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
/**
|
||||
* Verify ICCContactHelper.updateICCContact with appType is CARD_APPTYPE_USIM.
|
||||
*/
|
||||
add_test(function test_update_icc_contact() {
|
||||
let worker = newUint8Worker();
|
||||
let recordHelper = worker.ICCRecordHelper;
|
||||
let contactHelper = worker.ICCContactHelper;
|
||||
const FILE_ID = 0x4f3a;
|
||||
|
||||
recordHelper.readPBR = function (onsuccess, onerror) {
|
||||
onsuccess([{adn:{fileId: FILE_ID}}]);
|
||||
};
|
||||
|
||||
let oldContact = {recordId: 1, alphaId: "test", number: "123456"};
|
||||
recordHelper.updateADNLike = function (fileId, contact, pin2, onsuccess, onerror) {
|
||||
do_check_eq(fileId, FILE_ID);
|
||||
do_check_eq(contact.alphaId, oldContact.alphaId);
|
||||
do_check_eq(contact.number, oldContact.number);
|
||||
|
||||
run_next_test();
|
||||
};
|
||||
|
||||
contactHelper.updateICCContact(CARD_APPTYPE_USIM, "adn", oldContact);
|
||||
});
|
||||
|
||||
/**
|
||||
* Verify ICCContactHelper.findFreeICCContact
|
||||
*/
|
||||
add_test(function test_find_free_icc_contact() {
|
||||
let worker = newUint8Worker();
|
||||
let recordHelper = worker.ICCRecordHelper;
|
||||
let contactHelper = worker.ICCContactHelper;
|
||||
const RECORD_ID = 1;
|
||||
|
||||
recordHelper.readPBR = function (onsuccess, onerror) {
|
||||
onsuccess([{adn:{}, email: {}, anr0: {}}]);
|
||||
};
|
||||
|
||||
recordHelper.findFreeRecordId = function (fileId, onsuccess, onerror) {
|
||||
onsuccess(RECORD_ID);
|
||||
};
|
||||
|
||||
let successCb = function (recordId) {
|
||||
do_check_eq(recordId, RECORD_ID);
|
||||
run_next_test();
|
||||
};
|
||||
|
||||
let errorCb = function (errorMsg) {
|
||||
do_check_true(false);
|
||||
run_next_test();
|
||||
};
|
||||
|
||||
contactHelper.findFreeICCContact(CARD_APPTYPE_USIM, "adn", successCb, errorCb);
|
||||
});
|
||||
|
||||
/**
|
||||
* Verify cardState 'corporateLocked'.
|
||||
*/
|
||||
|
|
|
@ -20,10 +20,6 @@ struct ID3D10Device;
|
|||
struct ID3D10ShaderResourceView;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
# include <ui/GraphicBuffer.h>
|
||||
#endif
|
||||
|
||||
typedef void* HANDLE;
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -23,4 +23,3 @@ skip = false
|
|||
[include:../../../../../dom/system/gonk/tests/marionette/manifest.ini]
|
||||
[include:../../../../../dom/icc/tests/marionette/manifest.ini]
|
||||
[include:../../../../../dom/system/tests/marionette/manifest.ini]
|
||||
[include:../../../../../dom/contacts/tests/marionette/manifest.ini]
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
|
||||
#include "InputDispatcher.h"
|
||||
|
||||
#include <ui/PowerManager.h>
|
||||
#include "PowerManager.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _UI_POWER_MANAGER_H
|
||||
#define _UI_POWER_MANAGER_H
|
||||
|
||||
|
||||
namespace android {
|
||||
|
||||
enum {
|
||||
POWER_MANAGER_OTHER_EVENT = 0,
|
||||
POWER_MANAGER_BUTTON_EVENT = 1,
|
||||
POWER_MANAGER_TOUCH_EVENT = 2,
|
||||
|
||||
POWER_MANAGER_LAST_EVENT = POWER_MANAGER_TOUCH_EVENT, // Last valid event code.
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // _UI_POWER_MANAGER_H
|
Загрузка…
Ссылка в новой задаче