--HG--
extra : rebase_source : 31afc1b4de1d4c9d48057dbbe0d96e7c385bf2dc
This commit is contained in:
Wes Kocher 2015-03-27 17:31:19 -07:00
Родитель e9bc517fd8 e4585cf145
Коммит 18a6da0131
123 изменённых файлов: 3796 добавлений и 838 удалений

Просмотреть файл

@ -11,9 +11,9 @@ const PREF_DEBUG = "dom.payment.debug";
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "iccProvider",
"@mozilla.org/ril/content-helper;1",
"nsIIccProvider");
XPCOMUtils.defineLazyServiceGetter(this, "gIccService",
"@mozilla.org/icc/iccservice;1",
"nsIIccService");
XPCOMUtils.defineLazyServiceGetter(this, "gRil",
"@mozilla.org/ril;1",
@ -148,7 +148,8 @@ PaymentProviderStrategy.prototype = {
if (!this._iccInfo) {
this._iccInfo = [];
for (let i = 0; i < gRil.numRadioInterfaces; i++) {
let info = iccProvider.getIccInfo(i);
let icc = gIccService.getIccByServiceId(i);
let info = icc && icc.iccInfo;
if (!info) {
LOGE("Tried to get the ICC info for an invalid service ID " + i);
continue;

Просмотреть файл

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="ef937d1aca7c4cf89ecb5cc43ae8c21c2000a9db">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="9cc496cecc37d7a29f9279827cdf6e4891211f67"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="0e7c8ade48129b3e03c5de8ae0452fd1f756535c"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2aa4a75c63cd6e93870a8bddbba45f863cbfd9a3"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

Просмотреть файл

@ -19,7 +19,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="9cc496cecc37d7a29f9279827cdf6e4891211f67"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="0e7c8ade48129b3e03c5de8ae0452fd1f756535c"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2aa4a75c63cd6e93870a8bddbba45f863cbfd9a3"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="93f9ba577f68d772093987c2f1c0a4ae293e1802"/>

Просмотреть файл

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="9cc496cecc37d7a29f9279827cdf6e4891211f67"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="0e7c8ade48129b3e03c5de8ae0452fd1f756535c"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2aa4a75c63cd6e93870a8bddbba45f863cbfd9a3"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ed2cf97a6c37a4bbd0bbbbffe06ec7136d8c79ff"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f5de61a5d8fdaa2db3d4e17e0c4212ec4d54a365"/>

Просмотреть файл

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="ef937d1aca7c4cf89ecb5cc43ae8c21c2000a9db">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="9cc496cecc37d7a29f9279827cdf6e4891211f67"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="0e7c8ade48129b3e03c5de8ae0452fd1f756535c"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2aa4a75c63cd6e93870a8bddbba45f863cbfd9a3"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

Просмотреть файл

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="52775e03a2d8532429dff579cb2cd56718e488c3">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="9cc496cecc37d7a29f9279827cdf6e4891211f67"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="0e7c8ade48129b3e03c5de8ae0452fd1f756535c"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2aa4a75c63cd6e93870a8bddbba45f863cbfd9a3"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

Просмотреть файл

@ -19,7 +19,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="9cc496cecc37d7a29f9279827cdf6e4891211f67"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="0e7c8ade48129b3e03c5de8ae0452fd1f756535c"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2aa4a75c63cd6e93870a8bddbba45f863cbfd9a3"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="93f9ba577f68d772093987c2f1c0a4ae293e1802"/>

Просмотреть файл

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="ef937d1aca7c4cf89ecb5cc43ae8c21c2000a9db">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="9cc496cecc37d7a29f9279827cdf6e4891211f67"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="0e7c8ade48129b3e03c5de8ae0452fd1f756535c"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2aa4a75c63cd6e93870a8bddbba45f863cbfd9a3"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

Просмотреть файл

@ -17,7 +17,7 @@
</project>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="9cc496cecc37d7a29f9279827cdf6e4891211f67"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="0e7c8ade48129b3e03c5de8ae0452fd1f756535c"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2aa4a75c63cd6e93870a8bddbba45f863cbfd9a3"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ed2cf97a6c37a4bbd0bbbbffe06ec7136d8c79ff"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f5de61a5d8fdaa2db3d4e17e0c4212ec4d54a365"/>

Просмотреть файл

@ -1,9 +1,9 @@
{
"git": {
"git_revision": "9cc496cecc37d7a29f9279827cdf6e4891211f67",
"git_revision": "0e7c8ade48129b3e03c5de8ae0452fd1f756535c",
"remote": "https://git.mozilla.org/releases/gaia.git",
"branch": ""
},
"revision": "9e79307fd6bcade07847b92d42948a6a6a334f79",
"revision": "97a01eae94361363300254b54e53e2ac0f0b9d38",
"repo_path": "integration/gaia-central"
}

Просмотреть файл

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="9cc496cecc37d7a29f9279827cdf6e4891211f67"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="0e7c8ade48129b3e03c5de8ae0452fd1f756535c"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2aa4a75c63cd6e93870a8bddbba45f863cbfd9a3"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ed2cf97a6c37a4bbd0bbbbffe06ec7136d8c79ff"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f5de61a5d8fdaa2db3d4e17e0c4212ec4d54a365"/>

Просмотреть файл

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="52775e03a2d8532429dff579cb2cd56718e488c3">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="9cc496cecc37d7a29f9279827cdf6e4891211f67"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="0e7c8ade48129b3e03c5de8ae0452fd1f756535c"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2aa4a75c63cd6e93870a8bddbba45f863cbfd9a3"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

Просмотреть файл

@ -178,7 +178,6 @@
@RESPATH@/components/dom_system_gonk.xpt
#endif
#ifdef MOZ_B2G_RIL
@RESPATH@/components/dom_icc.xpt
@RESPATH@/components/dom_wappush.xpt
@RESPATH@/components/dom_mobileconnection.xpt
#endif
@ -218,6 +217,7 @@
@RESPATH@/components/dom_permissionsettings.xpt
@RESPATH@/components/dom_sidebar.xpt
@RESPATH@/components/dom_cellbroadcast.xpt
@RESPATH@/components/dom_icc.xpt
@RESPATH@/components/dom_mobilemessage.xpt
@RESPATH@/components/dom_storage.xpt
@RESPATH@/components/dom_stylesheets.xpt
@ -483,6 +483,8 @@
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
@RESPATH@/components/CellBroadcastService.js
@RESPATH@/components/CellBroadcastService.manifest
@BINPATH@/components/IccService.js
@BINPATH@/components/IccService.manifest
@RESPATH@/components/MmsService.js
@RESPATH@/components/MmsService.manifest
@RESPATH@/components/MobileMessageDatabaseService.js

Просмотреть файл

@ -46,6 +46,12 @@ searchbar {
-moz-binding: url("chrome://browser/content/search/search.xml#searchbar");
}
/* Prevent shrinking the page content to 0 height and width */
.browserStack > browser {
min-height: 25px;
min-width: 25px;
}
.browserStack > browser {
-moz-binding: url("chrome://browser/content/tabbrowser.xml#tabbrowser-browser");
}

Просмотреть файл

@ -32,6 +32,55 @@ function loadURI(tab, url) {
return BrowserTestUtils.browserLoaded(tab.linkedBrowser);
}
// Creates a framescript which caches the current object value from the plugin
// in the page. checkObjectValue below verifies that the framescript is still
// active for the browser and that the cached value matches that from the plugin
// in the page which tells us the plugin hasn't been reinitialized.
function cacheObjectValue(browser) {
let frame_script = function() {
let plugin = content.document.wrappedJSObject.body.firstChild;
let objectValue = plugin.getObjectValue();
addMessageListener("Test:CheckObjectValue", () => {
try {
let plugin = content.document.wrappedJSObject.body.firstChild;
sendAsyncMessage("Test:CheckObjectValue", {
result: plugin.checkObjectValue(objectValue)
});
}
catch (e) {
sendAsyncMessage("Test:CheckObjectValue", {
result: null,
exception: e.toString()
});
}
});
};
browser.messageManager.loadFrameScript("data:,(" + frame_script.toString() + ")();", false)
}
// See the notes for cacheObjectValue above.
function checkObjectValue(browser) {
let mm = browser.messageManager;
return new Promise((resolve, reject) => {
let listener = ({ data }) => {
mm.removeMessageListener("Test:CheckObjectValue", listener);
if (data.result === null) {
ok(false, "checkObjectValue threw an exception: " + data.exception);
reject(data.exception);
}
else {
resolve(data.result);
}
};
mm.addMessageListener("Test:CheckObjectValue", listener);
mm.sendAsyncMessage("Test:CheckObjectValue");
});
}
add_task(function*() {
let embed = '<embed type="application/x-test" allowscriptaccess="always" allowfullscreen="true" wmode="window" width="640" height="480"></embed>'
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED);
@ -57,15 +106,12 @@ add_task(function*() {
is(gBrowser.tabs[2], tabs[3], "tab3");
is(gBrowser.tabs[3], tabs[4], "tab4");
let plugin = tabs[4].linkedBrowser.contentDocument.wrappedJSObject.body.firstChild;
let tab4_plugin_object = plugin.getObjectValue();
cacheObjectValue(tabs[4].linkedBrowser);
swapTabsAndCloseOther(3, 2); // now: 0 1 4
gBrowser.selectedTab = gBrowser.tabs[2];
let doc = gBrowser.tabs[2].linkedBrowser.contentDocument.wrappedJSObject;
plugin = doc.body.firstChild;
ok(plugin && plugin.checkObjectValue(tab4_plugin_object), "same plugin instance");
ok((yield checkObjectValue(gBrowser.tabs[2].linkedBrowser)), "same plugin instance");
is(gBrowser.tabs[1], tabs[1], "tab1");
is(gBrowser.tabs[2], tabs[3], "tab4");
@ -77,9 +123,7 @@ add_task(function*() {
swapTabsAndCloseOther(2, 1); // now: 0 4
is(gBrowser.tabs[1], tabs[1], "tab1");
doc = gBrowser.tabs[1].linkedBrowser.contentDocument.wrappedJSObject;
plugin = doc.body.firstChild;
ok(plugin && plugin.checkObjectValue(tab4_plugin_object), "same plugin instance");
ok((yield checkObjectValue(gBrowser.tabs[1].linkedBrowser)), "same plugin instance");
yield clickTest(gBrowser.tabs[1]);

Просмотреть файл

@ -25,12 +25,12 @@ add_task(function*() {
is (nbox.clientWidth, nboxWidth, "Opening the toolbox hasn't changed the width of the nbox");
let iframe = document.getAnonymousElementByAttribute(nbox, "class", "devtools-toolbox-bottom-iframe");
is (iframe.clientHeight, nboxHeight - 10, "The iframe fits within the available space ");
is (iframe.clientHeight, nboxHeight - 25, "The iframe fits within the available space");
yield toolbox.switchHost(devtools.Toolbox.HostType.SIDE);
iframe = document.getAnonymousElementByAttribute(nbox, "class", "devtools-toolbox-side-iframe");
iframe.style.minWidth = "1px"; // Disable the min width set in css
is (iframe.clientWidth, nboxWidth - 10, "The iframe fits within the available space");
is (iframe.clientWidth, nboxWidth - 25, "The iframe fits within the available space");
yield cleanup(toolbox);
});

Просмотреть файл

@ -10,6 +10,12 @@ const {Promise: promise} = require("resource://gre/modules/Promise.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/devtools/DOMHelpers.jsm");
/* A host should always allow this much space for the page to be displayed.
* There is also a min-height on the browser, but we still don't want to set
* frame.height to be larger than that, since it can cause problems with
* resizing the toolbox and panel layout. */
const MIN_PAGE_SIZE = 25;
/**
* A toolbox host represents an object that contains a toolbox (e.g. the
* sidebar or a separate window). Any host object should implement the
@ -57,7 +63,7 @@ BottomHost.prototype = {
this.frame.className = "devtools-toolbox-bottom-iframe";
this.frame.height = Math.min(
Services.prefs.getIntPref(this.heightPref),
this._nbox.clientHeight - 10 // Always show at least some page content
this._nbox.clientHeight - MIN_PAGE_SIZE
);
this._nbox.appendChild(this._splitter);
@ -144,7 +150,7 @@ SidebarHost.prototype = {
this.frame.width = Math.min(
Services.prefs.getIntPref(this.widthPref),
this._sidebar.clientWidth - 10 // Always show at least some page content
this._sidebar.clientWidth - MIN_PAGE_SIZE
);
this._sidebar.appendChild(this._splitter);

Просмотреть файл

@ -2328,7 +2328,7 @@ function ElementEditor(aContainer, aNode) {
this.template = this.markup.template.bind(this.markup);
this.doc = this.markup.doc;
this.attrs = {};
this.attrElements = new Map();
this.animationTimers = {};
// The templates will fill the following properties
@ -2408,14 +2408,20 @@ ElementEditor.prototype = {
* Update the state of the editor from the node.
*/
update: function() {
let attrs = this.node.attributes || [];
let attrsToRemove = new Set(this.attrList.querySelectorAll(".attreditor"));
let nodeAttributes = this.node.attributes || [];
// Only loop through the current attributes on the node, anything that's
// been removed will be removed from this DOM because it will be part of
// the attrsToRemove set.
for (let attr of attrs) {
let el = this.attrs[attr.name];
// Keep the data model in sync with attributes on the node.
let currentAttributes = new Set(nodeAttributes.map(a=>a.name));
for (let name of this.attrElements.keys()) {
if (!currentAttributes.has(name)) {
this.removeAttribute(name);
}
}
// Only loop through the current attributes on the node. Missing
// attributes have already been removed at this point.
for (let attr of nodeAttributes) {
let el = this.attrElements.get(attr.name);
let valueChanged = el && el.querySelector(".attr-value").innerHTML !== attr.value;
let isEditing = el && el.querySelector(".editable").inplaceEditor;
let canSimplyShowEditor = el && (!valueChanged || isEditing);
@ -2423,7 +2429,6 @@ ElementEditor.prototype = {
if (canSimplyShowEditor) {
// Element already exists and doesn't need to be recreated.
// Just show it (it's hidden by default due to the template).
attrsToRemove.delete(el);
el.style.removeProperty("display");
} else {
// Create a new editor, because the value of an existing attribute
@ -2439,10 +2444,6 @@ ElementEditor.prototype = {
}
}
}
for (let el of attrsToRemove) {
el.remove();
}
},
_startModifyingAttributes: function() {
@ -2459,6 +2460,18 @@ ElementEditor.prototype = {
".attreditor[data-attr=" + attrName + "] .attr-value");
},
/**
* Remove an attribute from the attrElements object and the DOM
* @param string attrName The name of the attribute to remove
*/
removeAttribute: function(attrName) {
let attr = this.attrElements.get(attrName);
if (attr) {
this.attrElements.delete(attrName);
attr.remove();
}
},
_createAttribute: function(aAttr, aBefore = null) {
// Create the template editor, which will save some variables here.
let data = {
@ -2541,18 +2554,13 @@ ElementEditor.prototype = {
if (aAttr.name == "id") {
before = this.attrList.firstChild;
} else if (aAttr.name == "class") {
let idNode = this.attrs["id"];
let idNode = this.attrElements.get("id");
before = idNode ? idNode.nextSibling : this.attrList.firstChild;
}
this.attrList.insertBefore(attr, before);
// Remove the old version of this attribute from the DOM.
let oldAttr = this.attrs[aAttr.name];
if (oldAttr && oldAttr.parentNode) {
oldAttr.parentNode.removeChild(oldAttr);
}
this.attrs[aAttr.name] = attr;
this.removeAttribute(aAttr.name);
this.attrElements.set(aAttr.name, attr);
let collapsedValue;
if (aAttr.value.match(COLLAPSE_DATA_URL_REGEX)) {

Просмотреть файл

@ -140,7 +140,7 @@ function* checkData(index, editor, inspector) {
} else {
let nodeFront = yield getNodeFront("#node14", inspector);
let editor = getContainerForNodeFront(nodeFront, inspector).editor;
let attr = editor.attrs["style"].querySelector(".editable");
let attr = editor.attrElements.get("style").querySelector(".editable");
is(attr.textContent, completion, "Correct value is persisted after pressing Enter");
}
}

Просмотреть файл

@ -39,6 +39,32 @@ const TEST_DATA = [
}), "newattr attribute removed");
}
},
{
desc: "Re-adding an attribute",
test: () => {
let node1 = getNode("#node1");
node1.setAttribute("newattr", "newattrval");
},
check: function*(inspector) {
let {editor} = yield getContainerForSelector("#node1", inspector);
ok([...editor.attrList.querySelectorAll(".attreditor")].some(attr => {
return attr.textContent.trim() === "newattr=\"newattrval\"";
}), "newattr attribute found");
}
},
{
desc: "Changing an attribute",
test: () => {
let node1 = getNode("#node1");
node1.setAttribute("newattr", "newattrchanged");
},
check: function*(inspector) {
let {editor} = yield getContainerForSelector("#node1", inspector);
ok([...editor.attrList.querySelectorAll(".attreditor")].some(attr => {
return attr.textContent.trim() === "newattr=\"newattrchanged\"";
}), "newattr attribute found");
}
},
{
desc: "Updating the text-content",
test: () => {

Просмотреть файл

@ -123,7 +123,7 @@ function* assertNodeFlashing(nodeFront, inspector) {
function* assertAttributeFlashing(nodeFront, attribute, inspector) {
let container = getContainerForNodeFront(nodeFront, inspector);
ok(container, "Markup container for node found");
ok(container.editor.attrs[attribute], "Attribute exists on editor");
ok(container.editor.attrElements.get(attribute), "Attribute exists on editor");
let attributeElement = container.editor.getAttributeElement(attribute);

Просмотреть файл

@ -22,7 +22,7 @@ add_task(function*() {
info("Focus the ID attribute and change its content");
let {editor} = yield getContainerForSelector("#test-div", inspector);
let attr = editor.attrs["id"].querySelector(".editable");
let attr = editor.attrElements.get("id").querySelector(".editable");
let mutated = inspector.once("markupmutation");
setEditableFieldValue(attr,
attr.textContent + ' class="newclass" style="color:green"', inspector);

Просмотреть файл

@ -47,7 +47,7 @@ let TEST_DATA = [{
},
validate: (element, container, inspector) => {
let editor = container.editor;
let visibleAttrText = editor.attrs["style"].querySelector(".attr-value").textContent;
let visibleAttrText = editor.attrElements.get("style").querySelector(".attr-value").textContent;
is (visibleAttrText, DATA_URL_INLINE_STYLE_COLLAPSED);
}
}, {
@ -58,7 +58,7 @@ let TEST_DATA = [{
},
validate: (element, container, inspector) => {
let editor = container.editor;
let visibleAttrText = editor.attrs["data-long"].querySelector(".attr-value").textContent;
let visibleAttrText = editor.attrElements.get("data-long").querySelector(".attr-value").textContent;
is (visibleAttrText, LONG_ATTRIBUTE_COLLAPSED)
}
}, {
@ -69,7 +69,7 @@ let TEST_DATA = [{
},
validate: (element, container, inspector) => {
let editor = container.editor;
let visibleAttrText = editor.attrs["src"].querySelector(".attr-value").textContent;
let visibleAttrText = editor.attrElements.get("src").querySelector(".attr-value").textContent;
is (visibleAttrText, DATA_URL_ATTRIBUTE_COLLAPSED);
}
}];

Просмотреть файл

@ -36,7 +36,7 @@ function* testCollapsedLongAttribute(inspector) {
});
let {editor} = yield getContainerForSelector("#node24", inspector);
let attr = editor.attrs["data-long"].querySelector(".editable");
let attr = editor.attrElements.get("data-long").querySelector(".editable");
// Check to make sure it has expanded after focus
attr.focus();
@ -48,7 +48,7 @@ function* testCollapsedLongAttribute(inspector) {
setEditableFieldValue(attr, input.value + ' data-short="ABC"', inspector);
yield inspector.once("markupmutation");
let visibleAttrText = editor.attrs["data-long"].querySelector(".attr-value").textContent;
let visibleAttrText = editor.attrElements.get("data-long").querySelector(".attr-value").textContent;
is (visibleAttrText, LONG_ATTRIBUTE_COLLAPSED)
yield assertAttributes("#node24", {
@ -69,7 +69,7 @@ function* testModifyInlineStyleWithQuotes(inspector) {
let onMutated = inspector.once("markupmutation");
let {editor} = yield getContainerForSelector("#node26", inspector);
let attr = editor.attrs["style"].querySelector(".editable");
let attr = editor.attrElements.get("style").querySelector(".editable");
attr.focus();
EventUtils.sendKey("return", inspector.panelWin);
@ -105,7 +105,7 @@ function* testEditingAttributeWithMixedQuotes(inspector) {
let onMutated = inspector.once("markupmutation");
let {editor} = yield getContainerForSelector("#node27", inspector);
let attr = editor.attrs["class"].querySelector(".editable");
let attr = editor.attrElements.get("class").querySelector(".editable");
attr.focus();
EventUtils.sendKey("return", inspector.panelWin);

Просмотреть файл

@ -27,7 +27,7 @@ function* testWellformedMixedCase(inspector) {
info("Focusing the viewBox attribute editor");
let {editor} = yield getContainerForSelector("svg", inspector);
let attr = editor.attrs["viewBox"].querySelector(".editable");
let attr = editor.attrElements.get("viewBox").querySelector(".editable");
attr.focus();
EventUtils.sendKey("return", inspector.panelWin);
@ -53,7 +53,7 @@ function* testMalformedMixedCase(inspector) {
info("Focusing the viewBox attribute editor");
let {editor} = yield getContainerForSelector("svg", inspector);
let attr = editor.attrs["viewBox"].querySelector(".editable");
let attr = editor.attrElements.get("viewBox").querySelector(".editable");
attr.focus();
EventUtils.sendKey("return", inspector.panelWin);

Просмотреть файл

@ -133,7 +133,7 @@ function* runEditAttributesTest(test, inspector) {
info("Listening for the markupmutation event");
let nodeMutated = inspector.once("markupmutation");
let attr = container.editor.attrs[test.name].querySelector(".editable");
let attr = container.editor.attrElements.get(test.name).querySelector(".editable");
setEditableFieldValue(attr, test.value, inspector);
yield nodeMutated;

Просмотреть файл

@ -57,7 +57,6 @@ skip-if = e10s # Bug 1091596
[browser_net_cyrillic-02.js]
[browser_net_details-no-duplicated-content.js]
[browser_net_filter-01.js]
skip-if = e10s # Bug 1091603
[browser_net_filter-02.js]
[browser_net_filter-03.js]
[browser_net_filter-04.js]

Просмотреть файл

@ -297,8 +297,10 @@ PerformanceFront.prototype = {
return profilerStatus.currentTime;
}
// Extend the profiler options so that protocol.js doesn't modify the original.
let profilerOptions = extend({}, this._customProfilerOptions);
// If this._customProfilerOptions is defined, use those to pass in
// to the profiler actor. The profiler actor handles all the defaults
// now, so this should only be used for tests.
let profilerOptions = this._customProfilerOptions || {};
yield this._request("profiler", "startProfiler", profilerOptions);
this.emit("profiler-activated");
@ -400,19 +402,6 @@ PerformanceFront.prototype = {
deferred.resolve();
}),
/**
* Overrides the options sent to the built-in profiler module when activating,
* such as the maximum entries count, the sampling interval etc.
*
* Used in tests and for older backend implementations.
*/
_customProfilerOptions: {
entries: 1000000,
interval: 1,
features: ["js"],
threadFilters: ["GeckoMain"]
},
/**
* Returns an object indicating if mock actors are being used or not.
*/

Просмотреть файл

@ -215,6 +215,7 @@
@RESPATH@/components/dom_network.xpt
@RESPATH@/components/dom_notification.xpt
@RESPATH@/components/dom_html.xpt
@RESPATH@/components/dom_icc.xpt
@RESPATH@/components/dom_offline.xpt
@RESPATH@/components/dom_json.xpt
@RESPATH@/components/dom_power.xpt

Просмотреть файл

@ -33,9 +33,9 @@ public:
// Check whether two markers should be considered the same,
// for the purpose of pairing start and end markers. Normally
// this definition suffices.
virtual bool Equals(const TimelineMarker* aOther)
virtual bool Equals(const TimelineMarker& aOther)
{
return strcmp(mName, aOther->mName) == 0;
return strcmp(mName, aOther.mName) == 0;
}
// Add details specific to this marker type to aMarker. The

Просмотреть файл

@ -2977,10 +2977,10 @@ nsDocShell::PopProfileTimelineMarkers(
// If we see an unpaired START, we keep it around for the next call
// to PopProfileTimelineMarkers. We store the kept START objects in
// this array.
nsTArray<TimelineMarker*> keptMarkers;
nsTArray<UniquePtr<TimelineMarker>> keptMarkers;
for (uint32_t i = 0; i < mProfileTimelineMarkers.Length(); ++i) {
TimelineMarker* startPayload = mProfileTimelineMarkers[i];
UniquePtr<TimelineMarker>& startPayload = mProfileTimelineMarkers[i];
const char* startMarkerName = startPayload->GetName();
bool hasSeenPaintedLayer = false;
@ -3002,7 +3002,7 @@ nsDocShell::PopProfileTimelineMarkers(
// enough for the amount of markers to always be small enough that the
// nested for loop isn't going to be a performance problem.
for (uint32_t j = i + 1; j < mProfileTimelineMarkers.Length(); ++j) {
TimelineMarker* endPayload = mProfileTimelineMarkers[j];
UniquePtr<TimelineMarker>& endPayload = mProfileTimelineMarkers[j];
const char* endMarkerName = endPayload->GetName();
// Look for Layer markers to stream out paint markers.
@ -3011,7 +3011,7 @@ nsDocShell::PopProfileTimelineMarkers(
endPayload->AddLayerRectangles(layerRectangles);
}
if (!startPayload->Equals(endPayload)) {
if (!startPayload->Equals(*endPayload)) {
continue;
}
@ -3048,14 +3048,13 @@ nsDocShell::PopProfileTimelineMarkers(
// If we did not see the corresponding END, keep the START.
if (!hasSeenEnd) {
keptMarkers.AppendElement(mProfileTimelineMarkers[i]);
keptMarkers.AppendElement(Move(mProfileTimelineMarkers[i]));
mProfileTimelineMarkers.RemoveElementAt(i);
--i;
}
}
}
ClearProfileTimelineMarkers();
mProfileTimelineMarkers.SwapElements(keptMarkers);
if (!ToJSValue(aCx, profileTimelineMarkers, aProfileTimelineMarkers)) {
@ -3086,10 +3085,10 @@ nsDocShell::AddProfileTimelineMarker(const char* aName,
}
void
nsDocShell::AddProfileTimelineMarker(UniquePtr<TimelineMarker>& aMarker)
nsDocShell::AddProfileTimelineMarker(UniquePtr<TimelineMarker>&& aMarker)
{
if (mProfileTimelineRecording) {
mProfileTimelineMarkers.AppendElement(aMarker.release());
mProfileTimelineMarkers.AppendElement(Move(aMarker));
}
}
@ -3125,9 +3124,6 @@ nsDocShell::GetWindowDraggingAllowed(bool* aValue)
void
nsDocShell::ClearProfileTimelineMarkers()
{
for (uint32_t i = 0; i < mProfileTimelineMarkers.Length(); ++i) {
delete mProfileTimelineMarkers[i];
}
mProfileTimelineMarkers.Clear();
}

Просмотреть файл

@ -272,7 +272,7 @@ public:
// See nsIDocShell::recordProfileTimelineMarkers
void AddProfileTimelineMarker(const char* aName,
TracingMetadata aMetaData);
void AddProfileTimelineMarker(mozilla::UniquePtr<TimelineMarker>& aMarker);
void AddProfileTimelineMarker(mozilla::UniquePtr<TimelineMarker>&& aMarker);
// Global counter for how many docShells are currently recording profile
// timeline markers
@ -984,7 +984,7 @@ private:
// True if recording profiles.
bool mProfileTimelineRecording;
nsTArray<TimelineMarker*> mProfileTimelineMarkers;
nsTArray<mozilla::UniquePtr<TimelineMarker>> mProfileTimelineMarkers;
// Get rid of all the timeline markers accumulated so far
void ClearProfileTimelineMarkers();

Просмотреть файл

@ -21,9 +21,9 @@ Cu.import("resource://gre/modules/Task.jsm");
let Path = OS.Path;
#ifdef MOZ_B2G_RIL
XPCOMUtils.defineLazyServiceGetter(this, "iccProvider",
"@mozilla.org/ril/content-helper;1",
"nsIIccProvider");
XPCOMUtils.defineLazyServiceGetter(this, "gIccService",
"@mozilla.org/icc/iccservice;1",
"nsIIccService");
#endif
function debug(aMsg) {
@ -69,17 +69,18 @@ let iccListener = {
notifyIccInfoChanged: function() {
// TODO: Bug 927709 - OperatorApps for multi-sim
// In Multi-sim, there is more than one client in iccProvider. Each
// client represents a icc service. To maintain the backward compatibility
// In Multi-sim, there is more than one client in IccService. Each
// client represents a icc handle. To maintain the backward compatibility
// with single sim, we always use client 0 for now. Adding support for
// multiple sim will be addressed in bug 927709, if needed.
let clientId = 0;
let iccInfo = iccProvider.getIccInfo(clientId);
let icc = gIccService.getIccByServiceId(clientId);
let iccInfo = icc && icc.iccInfo;
if (iccInfo && iccInfo.mcc && iccInfo.mnc) {
let mcc = iccInfo.mcc;
let mnc = iccInfo.mnc;
debug("******* iccListener cardIccInfo MCC-MNC: " + mcc + "-" + mnc);
iccProvider.unregisterIccMsg(clientId, this);
icc.unregisterListener(this);
OperatorAppsRegistry._installOperatorApps(mcc, mnc);
debug("Broadcast message first-run-with-sim");
@ -105,13 +106,14 @@ this.OperatorAppsRegistry = {
try {
yield this._initializeSourceDir();
// TODO: Bug 927709 - OperatorApps for multi-sim
// In Multi-sim, there is more than one client in iccProvider. Each
// client represents a icc service. To maintain the backward
// In Multi-sim, there is more than one client in IccService. Each
// client represents a icc handle. To maintain the backward
// compatibility with single sim, we always use client 0 for now.
// Adding support for multiple sim will be addressed in bug 927709, if
// needed.
let clientId = 0;
let iccInfo = iccProvider.getIccInfo(clientId);
let icc = gIccService.getIccByServiceId(clientId);
let iccInfo = icc && icc.iccInfo;
let mcc = 0;
let mnc = 0;
if (iccInfo && iccInfo.mcc) {
@ -128,7 +130,7 @@ this.OperatorAppsRegistry = {
mnc: mnc });
} else {
iccProvider.registerIccMsg(clientId, iccListener);
icc.registerListener(iccListener);
}
} catch (e) {
debug("Error Initializing OperatorApps. " + e);

Просмотреть файл

@ -934,13 +934,13 @@ public:
}
}
virtual bool Equals(const TimelineMarker* aOther) override
virtual bool Equals(const TimelineMarker& aOther) override
{
if (!TimelineMarker::Equals(aOther)) {
return false;
}
// Console markers must have matching causes as well.
return GetCause() == aOther->GetCause();
return GetCause() == aOther.GetCause();
}
virtual void AddDetails(mozilla::dom::ProfileTimelineMarker& aMarker) override
@ -1057,7 +1057,7 @@ Console::Method(JSContext* aCx, MethodName aMethodName,
MakeUnique<ConsoleTimelineMarker>(docShell,
aMethodName == MethodTime ? TRACING_INTERVAL_START : TRACING_INTERVAL_END,
key);
docShell->AddProfileTimelineMarker(marker);
docShell->AddProfileTimelineMarker(Move(marker));
}
}
}

Просмотреть файл

@ -36,6 +36,7 @@
#include "mozilla/dom/WakeLock.h"
#include "mozilla/dom/power/PowerManagerService.h"
#include "mozilla/dom/CellBroadcast.h"
#include "mozilla/dom/IccManager.h"
#include "mozilla/dom/MobileMessageManager.h"
#include "mozilla/dom/ServiceWorkerContainer.h"
#include "mozilla/dom/Telephony.h"
@ -53,7 +54,6 @@
#include "nsIMobileIdentityService.h"
#endif
#ifdef MOZ_B2G_RIL
#include "mozilla/dom/IccManager.h"
#include "mozilla/dom/MobileConnectionArray.h"
#endif
#include "nsIIdleObserver.h"
@ -177,6 +177,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBatteryManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPowerManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCellBroadcast)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIccManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMobileMessageManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTelephony)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVoicemail)
@ -184,7 +185,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConnection)
#ifdef MOZ_B2G_RIL
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMobileConnections)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIccManager)
#endif
#ifdef MOZ_B2G_BT
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBluetooth)
@ -250,6 +250,11 @@ Navigator::Invalidate()
mCellBroadcast = nullptr;
}
if (mIccManager) {
mIccManager->Shutdown();
mIccManager = nullptr;
}
if (mMobileMessageManager) {
mMobileMessageManager->Shutdown();
mMobileMessageManager = nullptr;
@ -277,11 +282,6 @@ Navigator::Invalidate()
if (mMobileConnections) {
mMobileConnections = nullptr;
}
if (mIccManager) {
mIccManager->Shutdown();
mIccManager = nullptr;
}
#endif
#ifdef MOZ_B2G_BT
@ -1707,8 +1707,6 @@ Navigator::GetMozVoicemail(ErrorResult& aRv)
return mVoicemail;
}
#ifdef MOZ_B2G_RIL
IccManager*
Navigator::GetMozIccManager(ErrorResult& aRv)
{
@ -1724,7 +1722,6 @@ Navigator::GetMozIccManager(ErrorResult& aRv)
return mIccManager;
}
#endif // MOZ_B2G_RIL
#ifdef MOZ_GAMEPAD
void

Просмотреть файл

@ -44,10 +44,6 @@ class ServiceWorkerContainer;
}
}
#ifdef MOZ_B2G_RIL
class nsIDOMMozIccManager;
#endif // MOZ_B2G_RIL
//*****************************************************************************
// Navigator: Script "navigator" object
//*****************************************************************************
@ -88,12 +84,12 @@ class BluetoothManager;
#endif // MOZ_B2G_BT
#ifdef MOZ_B2G_RIL
class IccManager;
class MobileConnectionArray;
#endif
class PowerManager;
class CellBroadcast;
class IccManager;
class Telephony;
class Voicemail;
class TVManager;
@ -224,6 +220,7 @@ public:
ErrorResult& aRv);
DesktopNotificationCenter* GetMozNotification(ErrorResult& aRv);
CellBroadcast* GetMozCellBroadcast(ErrorResult& aRv);
IccManager* GetMozIccManager(ErrorResult& aRv);
MobileMessageManager* GetMozMobileMessage();
Telephony* GetMozTelephony(ErrorResult& aRv);
Voicemail* GetMozVoicemail(ErrorResult& aRv);
@ -243,7 +240,6 @@ public:
#endif
#ifdef MOZ_B2G_RIL
MobileConnectionArray* GetMozMobileConnections(ErrorResult& aRv);
IccManager* GetMozIccManager(ErrorResult& aRv);
#endif // MOZ_B2G_RIL
#ifdef MOZ_GAMEPAD
void GetGamepads(nsTArray<nsRefPtr<Gamepad> >& aGamepads, ErrorResult& aRv);
@ -353,6 +349,7 @@ private:
#endif
nsRefPtr<PowerManager> mPowerManager;
nsRefPtr<CellBroadcast> mCellBroadcast;
nsRefPtr<IccManager> mIccManager;
nsRefPtr<MobileMessageManager> mMobileMessageManager;
nsRefPtr<Telephony> mTelephony;
nsRefPtr<Voicemail> mVoicemail;
@ -360,7 +357,6 @@ private:
nsRefPtr<network::Connection> mConnection;
#ifdef MOZ_B2G_RIL
nsRefPtr<MobileConnectionArray> mMobileConnections;
nsRefPtr<IccManager> mIccManager;
#endif
#ifdef MOZ_B2G_BT
nsRefPtr<bluetooth::BluetoothManager> mBluetooth;

Просмотреть файл

@ -312,7 +312,6 @@ AutoJSAPI::~AutoJSAPI()
{
if (mOwnErrorReporting) {
MOZ_ASSERT(NS_IsMainThread(), "See corresponding assertion in TakeOwnershipOfErrorReporting()");
JS::ContextOptionsRef(cx()).setAutoJSAPIOwnsErrorReporting(mOldAutoJSAPIOwnsErrorReporting);
if (HasException()) {
@ -342,6 +341,13 @@ AutoJSAPI::~AutoJSAPI()
NS_WARNING("OOMed while acquiring uncaught exception from JSAPI");
}
}
// We need to do this _after_ processing the existing exception, because the
// JS engine can throw while doing that, and uses this bit to determine what
// to do in that case: squelch the exception if the bit is set, otherwise
// call the error reporter. Calling WarningOnlyErrorReporter with a
// non-warning will assert, so we need to make sure we do the former.
JS::ContextOptionsRef(cx()).setAutoJSAPIOwnsErrorReporting(mOldAutoJSAPIOwnsErrorReporting);
}
if (mOldErrorReporter.isSome()) {

Просмотреть файл

@ -7,12 +7,11 @@
#include "BluetoothRilListener.h"
#include "BluetoothHfpManager.h"
#include "nsIIccProvider.h"
#include "nsIIccService.h"
#include "nsIMobileConnectionInfo.h"
#include "nsIMobileConnectionService.h"
#include "nsITelephonyCallInfo.h"
#include "nsITelephonyService.h"
#include "nsRadioInterfaceLayer.h" // For NS_RILCONTENTHELPER_CONTRACTID.
#include "nsServiceManagerUtils.h"
#include "nsString.h"
@ -60,15 +59,19 @@ IccListener::Listen(bool aStart)
{
NS_ENSURE_TRUE(mOwner, false);
nsCOMPtr<nsIIccProvider> provider =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
NS_ENSURE_TRUE(provider, false);
nsCOMPtr<nsIIccService> service =
do_GetService(ICC_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(service, false);
nsCOMPtr<nsIIcc> icc;
service->GetIccByServiceId(mOwner->mClientId, getter_AddRefs(icc));
NS_ENSURE_TRUE(icc, false);
nsresult rv;
if (aStart) {
rv = provider->RegisterIccMsg(mOwner->mClientId, this);
rv = icc->RegisterListener(this);
} else {
rv = provider->UnregisterIccMsg(mOwner->mClientId, this);
rv = icc->UnregisterListener(this);
}
return NS_SUCCEEDED(rv);

Просмотреть файл

@ -11,7 +11,7 @@
#include "nsAutoPtr.h"
#include "nsIIccProvider.h"
#include "nsIIccService.h"
#include "nsIMobileConnectionService.h"
#include "nsITelephonyCallInfo.h"
#include "nsITelephonyService.h"

Просмотреть файл

@ -26,6 +26,8 @@ USING_BLUETOOTH_NAMESPACE
#define AVRC_ID_FAST_FOR 0x49
#define AVRC_KEY_PRESS_STATE 1
#define AVRC_KEY_RELEASE_STATE 0
// bluedroid bt_rc.h
#define AVRC_MAX_ATTR_STR_LEN 255
namespace {
StaticRefPtr<BluetoothA2dpManager> sBluetoothA2dpManager;
@ -47,12 +49,27 @@ ConvertAttributeString(BluetoothAvrcpMediaAttribute aAttrId,
switch (aAttrId) {
case AVRCP_MEDIA_ATTRIBUTE_TITLE:
a2dp->GetTitle(aAttrStr);
/*
* bluedroid can only send string length AVRC_MAX_ATTR_STR_LEN - 1
*/
if (aAttrStr.Length() >= AVRC_MAX_ATTR_STR_LEN) {
aAttrStr.Truncate(AVRC_MAX_ATTR_STR_LEN - 1);
BT_WARNING("Truncate media item attribute title, length is over 255");
}
break;
case AVRCP_MEDIA_ATTRIBUTE_ARTIST:
a2dp->GetArtist(aAttrStr);
if (aAttrStr.Length() >= AVRC_MAX_ATTR_STR_LEN) {
aAttrStr.Truncate(AVRC_MAX_ATTR_STR_LEN - 1);
BT_WARNING("Truncate media item attribute artist, length is over 255");
}
break;
case AVRCP_MEDIA_ATTRIBUTE_ALBUM:
a2dp->GetAlbum(aAttrStr);
if (aAttrStr.Length() >= AVRC_MAX_ATTR_STR_LEN) {
aAttrStr.Truncate(AVRC_MAX_ATTR_STR_LEN - 1);
BT_WARNING("Truncate media item attribute album, length is over 255");
}
break;
case AVRCP_MEDIA_ATTRIBUTE_TRACK_NUM:
aAttrStr.AppendInt(a2dp->GetMediaNumber());

Просмотреть файл

@ -17,14 +17,13 @@
#include "nsContentUtils.h"
#include "nsIAudioManager.h"
#include "nsIIccInfo.h"
#include "nsIIccProvider.h"
#include "nsIIccService.h"
#include "nsIMobileConnectionInfo.h"
#include "nsIMobileConnectionService.h"
#include "nsIMobileNetworkInfo.h"
#include "nsIObserverService.h"
#include "nsISettingsService.h"
#include "nsITelephonyService.h"
#include "nsRadioInterfaceLayer.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
#include "mozilla/dom/BindingUtils.h"
@ -726,12 +725,16 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
void
BluetoothHfpManager::HandleIccInfoChanged(uint32_t aClientId)
{
nsCOMPtr<nsIIccProvider> icc =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
nsCOMPtr<nsIIccService> service =
do_GetService(ICC_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(service);
nsCOMPtr<nsIIcc> icc;
service->GetIccByServiceId(aClientId, getter_AddRefs(icc));
NS_ENSURE_TRUE_VOID(icc);
nsCOMPtr<nsIIccInfo> iccInfo;
icc->GetIccInfo(aClientId, getter_AddRefs(iccInfo));
icc->GetIccInfo(getter_AddRefs(iccInfo));
NS_ENSURE_TRUE_VOID(iccInfo);
nsCOMPtr<nsIGsmIccInfo> gsmIccInfo = do_QueryInterface(iccInfo);

Просмотреть файл

@ -28,12 +28,11 @@
#ifdef MOZ_B2G_RIL
#include "nsIIccInfo.h"
#include "nsIIccProvider.h"
#include "nsIIccService.h"
#include "nsIMobileConnectionInfo.h"
#include "nsIMobileConnectionService.h"
#include "nsIMobileNetworkInfo.h"
#include "nsITelephonyService.h"
#include "nsRadioInterfaceLayer.h"
#endif
/**
@ -664,12 +663,16 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
void
BluetoothHfpManager::HandleIccInfoChanged(uint32_t aClientId)
{
nsCOMPtr<nsIIccProvider> icc =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
nsCOMPtr<nsIIccService> service =
do_GetService(ICC_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(service);
nsCOMPtr<nsIIcc> icc;
service->GetIccByServiceId(aClientId, getter_AddRefs(icc));
NS_ENSURE_TRUE_VOID(icc);
nsCOMPtr<nsIIccInfo> iccInfo;
icc->GetIccInfo(aClientId, getter_AddRefs(iccInfo));
icc->GetIccInfo(getter_AddRefs(iccInfo));
NS_ENSURE_TRUE_VOID(iccInfo);
nsCOMPtr<nsIGsmIccInfo> gsmIccInfo = do_QueryInterface(iccInfo);

Просмотреть файл

@ -7,11 +7,10 @@
#include "BluetoothRilListener.h"
#include "BluetoothHfpManager.h"
#include "nsIIccProvider.h"
#include "nsIIccService.h"
#include "nsIMobileConnectionInfo.h"
#include "nsIMobileConnectionService.h"
#include "nsITelephonyService.h"
#include "nsRadioInterfaceLayer.h" // For NS_RILCONTENTHELPER_CONTRACTID.
#include "nsServiceManagerUtils.h"
#include "nsString.h"
@ -59,15 +58,19 @@ IccListener::Listen(bool aStart)
{
NS_ENSURE_TRUE(mOwner, false);
nsCOMPtr<nsIIccProvider> provider =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
NS_ENSURE_TRUE(provider, false);
nsCOMPtr<nsIIccService> service =
do_GetService(ICC_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(service, false);
nsCOMPtr<nsIIcc> icc;
service->GetIccByServiceId(mOwner->mClientId, getter_AddRefs(icc));
NS_ENSURE_TRUE(icc, false);
nsresult rv;
if (aStart) {
rv = provider->RegisterIccMsg(mOwner->mClientId, this);
rv = icc->RegisterListener(this);
} else {
rv = provider->UnregisterIccMsg(mOwner->mClientId, this);
rv = icc->UnregisterListener(this);
}
return NS_SUCCEEDED(rv);

Просмотреть файл

@ -11,7 +11,7 @@
#include "nsAutoPtr.h"
#include "nsIIccProvider.h"
#include "nsIIccService.h"
#include "nsIMobileConnectionService.h"
#include "nsITelephonyCallInfo.h"
#include "nsITelephonyService.h"

Просмотреть файл

@ -17,14 +17,13 @@
#include "nsContentUtils.h"
#include "nsIAudioManager.h"
#include "nsIIccInfo.h"
#include "nsIIccProvider.h"
#include "nsIIccService.h"
#include "nsIMobileConnectionInfo.h"
#include "nsIMobileConnectionService.h"
#include "nsIMobileNetworkInfo.h"
#include "nsIObserverService.h"
#include "nsISettingsService.h"
#include "nsITelephonyService.h"
#include "nsRadioInterfaceLayer.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
#include "mozilla/dom/BindingUtils.h"
@ -710,12 +709,16 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
void
BluetoothHfpManager::HandleIccInfoChanged(uint32_t aClientId)
{
nsCOMPtr<nsIIccProvider> icc =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
nsCOMPtr<nsIIccService> service =
do_GetService(ICC_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(service);
nsCOMPtr<nsIIcc> icc;
service->GetIccByServiceId(aClientId, getter_AddRefs(icc));
NS_ENSURE_TRUE_VOID(icc);
nsCOMPtr<nsIIccInfo> iccInfo;
icc->GetIccInfo(aClientId, getter_AddRefs(iccInfo));
icc->GetIccInfo(getter_AddRefs(iccInfo));
NS_ENSURE_TRUE_VOID(iccInfo);
nsCOMPtr<nsIGsmIccInfo> gsmIccInfo = do_QueryInterface(iccInfo);

Просмотреть файл

@ -28,12 +28,11 @@
#ifdef MOZ_B2G_RIL
#include "nsIIccInfo.h"
#include "nsIIccProvider.h"
#include "nsIIccService.h"
#include "nsIMobileConnectionInfo.h"
#include "nsIMobileConnectionService.h"
#include "nsIMobileNetworkInfo.h"
#include "nsITelephonyService.h"
#include "nsRadioInterfaceLayer.h"
#endif
/**
@ -664,12 +663,16 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
void
BluetoothHfpManager::HandleIccInfoChanged(uint32_t aClientId)
{
nsCOMPtr<nsIIccProvider> icc =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
nsCOMPtr<nsIIccService> service =
do_GetService(ICC_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(service);
nsCOMPtr<nsIIcc> icc;
service->GetIccByServiceId(aClientId, getter_AddRefs(icc));
NS_ENSURE_TRUE_VOID(icc);
nsCOMPtr<nsIIccInfo> iccInfo;
icc->GetIccInfo(aClientId, getter_AddRefs(iccInfo));
icc->GetIccInfo(getter_AddRefs(iccInfo));
NS_ENSURE_TRUE_VOID(iccInfo);
nsCOMPtr<nsIGsmIccInfo> gsmIccInfo = do_QueryInterface(iccInfo);

Просмотреть файл

@ -1094,7 +1094,7 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
mozilla::UniquePtr<TimelineMarker> marker =
MakeUnique<EventTimelineMarker>(ds, TRACING_INTERVAL_START,
phase, typeStr);
ds->AddProfileTimelineMarker(marker);
ds->AddProfileTimelineMarker(Move(marker));
}
}

Просмотреть файл

@ -3,15 +3,15 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/MozIccBinding.h"
#include "nsIIccProvider.h"
#include "nsIIccService.h"
namespace mozilla {
namespace dom {
namespace icc {
#define ASSERT_EQUALITY(webidlType, webidlState, xpidlState) \
static_assert(static_cast<uint32_t>(webidlType::webidlState) == nsIIccProvider::xpidlState, \
#webidlType "::" #webidlState " should equal to nsIIccProvider::" #xpidlState)
static_assert(static_cast<uint32_t>(webidlType::webidlState) == nsIIcc::xpidlState, \
#webidlType "::" #webidlState " should equal to nsIIccService::" #xpidlState)
/**
* Enum IccCardState

Просмотреть файл

@ -4,6 +4,7 @@
#include "mozilla/dom/Icc.h"
#include "IccCallback.h"
#include "mozilla/dom/DOMRequest.h"
#include "mozilla/dom/IccInfo.h"
#include "mozilla/dom/MozStkCommandEvent.h"
@ -11,10 +12,13 @@
#include "mozilla/dom/ScriptSettings.h"
#include "nsIIccInfo.h"
#include "nsIIccProvider.h"
#include "nsIIccService.h"
#include "nsJSON.h"
#include "nsRadioInterfaceLayer.h"
#include "nsServiceManagerUtils.h"
using mozilla::dom::icc::IccCallback;
namespace mozilla {
namespace dom {
@ -50,9 +54,10 @@ NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(Icc, DOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(Icc, DOMEventTargetHelper)
Icc::Icc(nsPIDOMWindow* aWindow, long aClientId, nsIIccInfo* aIccInfo)
Icc::Icc(nsPIDOMWindow* aWindow, long aClientId, nsIIcc* aHandler, nsIIccInfo* aIccInfo)
: mLive(true)
, mClientId(aClientId)
, mHandler(aHandler)
{
BindToOwner(aWindow);
@ -79,6 +84,7 @@ Icc::Shutdown()
{
mIccInfo.SetNull();
mProvider = nullptr;
mHandler = nullptr;
mLive = false;
}
@ -170,10 +176,10 @@ Icc::GetCardState() const
{
Nullable<IccCardState> result;
uint32_t cardState = nsIIccProvider::CARD_STATE_UNDETECTED;
if (mProvider &&
NS_SUCCEEDED(mProvider->GetCardState(mClientId, &cardState)) &&
cardState != nsIIccProvider::CARD_STATE_UNDETECTED) {
uint32_t cardState = nsIIcc::CARD_STATE_UNDETECTED;
if (mHandler &&
NS_SUCCEEDED(mHandler->GetCardState(&cardState)) &&
cardState != nsIIcc::CARD_STATE_UNDETECTED) {
MOZ_ASSERT(cardState < static_cast<uint32_t>(IccCardState::EndGuard_));
result.SetValue(static_cast<IccCardState>(cardState));
}
@ -249,72 +255,78 @@ Icc::SendStkEventDownload(const JSContext* aCx, JS::Handle<JS::Value> aEvent,
already_AddRefed<DOMRequest>
Icc::GetCardLock(IccLockType aLockType, ErrorResult& aRv)
{
if (!mProvider) {
if (!mHandler) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<nsIDOMDOMRequest> request;
nsresult rv = mProvider->GetCardLockEnabled(mClientId, GetOwner(),
static_cast<uint32_t>(aLockType),
getter_AddRefs(request));
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
// TODO: Bug 1125018 - Simplify The Result of GetCardLock and
// getCardLockRetryCount in MozIcc.webidl without a wrapper object.
nsRefPtr<IccCallback> requestCallback =
new IccCallback(GetOwner(), request, true);
nsresult rv = mHandler->GetCardLockEnabled(static_cast<uint32_t>(aLockType),
requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
return request.forget().downcast<DOMRequest>();
return request.forget();
}
already_AddRefed<DOMRequest>
Icc::UnlockCardLock(const IccUnlockCardLockOptions& aOptions, ErrorResult& aRv)
{
if (!mProvider) {
if (!mHandler) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<nsIDOMDOMRequest> request;
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
nsRefPtr<IccCallback> requestCallback =
new IccCallback(GetOwner(), request);
const nsString& password = IsPukCardLockType(aOptions.mLockType)
? aOptions.mPuk : aOptions.mPin;
nsresult rv = mProvider->UnlockCardLock(mClientId, GetOwner(),
static_cast<uint32_t>(aOptions.mLockType),
password, aOptions.mNewPin,
getter_AddRefs(request));
nsresult rv =
mHandler->UnlockCardLock(static_cast<uint32_t>(aOptions.mLockType),
password, aOptions.mNewPin, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
return request.forget().downcast<DOMRequest>();
return request.forget();
}
already_AddRefed<DOMRequest>
Icc::SetCardLock(const IccSetCardLockOptions& aOptions, ErrorResult& aRv)
{
if (!mProvider) {
if (!mHandler) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsresult rv;
nsRefPtr<nsIDOMDOMRequest> request;
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
nsRefPtr<IccCallback> requestCallback =
new IccCallback(GetOwner(), request);
if (aOptions.mEnabled.WasPassed()) {
// Enable card lock.
const nsString& password = (aOptions.mLockType == IccLockType::Fdn) ?
aOptions.mPin2 : aOptions.mPin;
rv = mProvider->SetCardLockEnabled(mClientId, GetOwner(),
static_cast<uint32_t>(aOptions.mLockType),
password, aOptions.mEnabled.Value(),
getter_AddRefs(request));
rv =
mHandler->SetCardLockEnabled(static_cast<uint32_t>(aOptions.mLockType),
password, aOptions.mEnabled.Value(),
requestCallback);
} else {
// Change card lock password.
rv = mProvider->ChangeCardLockPassword(mClientId, GetOwner(),
static_cast<uint32_t>(aOptions.mLockType),
aOptions.mPin, aOptions.mNewPin,
getter_AddRefs(request));
rv =
mHandler->ChangeCardLockPassword(static_cast<uint32_t>(aOptions.mLockType),
aOptions.mPin, aOptions.mNewPin,
requestCallback);
}
if (NS_FAILED(rv)) {
@ -322,27 +334,28 @@ Icc::SetCardLock(const IccSetCardLockOptions& aOptions, ErrorResult& aRv)
return nullptr;
}
return request.forget().downcast<DOMRequest>();
return request.forget();
}
already_AddRefed<DOMRequest>
Icc::GetCardLockRetryCount(IccLockType aLockType, ErrorResult& aRv)
{
if (!mProvider) {
if (!mHandler) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<nsIDOMDOMRequest> request;
nsresult rv = mProvider->GetCardLockRetryCount(mClientId, GetOwner(),
static_cast<uint32_t>(aLockType),
getter_AddRefs(request));
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
nsRefPtr<IccCallback> requestCallback =
new IccCallback(GetOwner(), request);
nsresult rv = mHandler->GetCardLockRetryCount(static_cast<uint32_t>(aLockType),
requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
return request.forget().downcast<DOMRequest>();
return request.forget();
}
already_AddRefed<DOMRequest>
@ -392,41 +405,54 @@ already_AddRefed<DOMRequest>
Icc::MatchMvno(IccMvnoType aMvnoType, const nsAString& aMvnoData,
ErrorResult& aRv)
{
if (!mProvider) {
if (!mHandler) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<nsIDOMDOMRequest> request;
nsresult rv = mProvider->MatchMvno(mClientId, GetOwner(),
static_cast<uint32_t>(aMvnoType),
aMvnoData, getter_AddRefs(request));
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
nsRefPtr<IccCallback> requestCallback =
new IccCallback(GetOwner(), request);
nsresult rv = mHandler->MatchMvno(static_cast<uint32_t>(aMvnoType),
aMvnoData, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
return request.forget().downcast<DOMRequest>();
return request.forget();
}
already_AddRefed<Promise>
Icc::GetServiceState(IccService aService, ErrorResult& aRv)
{
if (!mProvider) {
if (!mHandler) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsCOMPtr<nsISupports> supports;
nsresult rv = mProvider->GetServiceState(mClientId, GetOwner(),
static_cast<uint32_t>(aService),
getter_AddRefs(supports));
if (NS_FAILED(rv)) {
aRv.Throw(rv);
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
if (!global) {
return nullptr;
}
nsCOMPtr<Promise> promise = do_QueryInterface(supports);
nsRefPtr<Promise> promise = Promise::Create(global, aRv);
if (aRv.Failed()) {
return nullptr;
}
nsRefPtr<IccCallback> requestCallback =
new IccCallback(GetOwner(), promise);
nsresult rv =
mHandler->GetServiceStateEnabled(static_cast<uint32_t>(aService),
requestCallback);
if (NS_FAILED(rv)) {
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
// fall-through to return promise.
}
return promise.forget();
}

Просмотреть файл

@ -8,6 +8,7 @@
#include "mozilla/dom/MozIccBinding.h"
#include "mozilla/DOMEventTargetHelper.h"
class nsIIcc;
class nsIIccInfo;
class nsIIccProvider;
@ -25,7 +26,8 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(Icc, DOMEventTargetHelper)
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
Icc(nsPIDOMWindow* aWindow, long aClientId, nsIIccInfo* aIccInfo);
Icc(nsPIDOMWindow* aWindow, long aClientId,
nsIIcc* aHandler, nsIIccInfo* aIccInfo);
void
Shutdown();
@ -111,14 +113,20 @@ public:
IMPL_EVENT_HANDLER(stksessionend)
private:
// Put definition of the destructor in Icc.cpp to ensure forward declaration
// of nsIIccProvider, nsIIcc for the auto-generated .cpp file (i.e.,
// MozIccManagerBinding.cpp) that includes this header.
~Icc();
bool mLive;
uint32_t mClientId;
nsString mIccId;
// mProvider is a xpcom service and will be released at shutdown, so it
// mProvider is a xpcom service and will be released at Shutdown(), so it
// doesn't need to be cycle collected.
nsCOMPtr<nsIIccProvider> mProvider;
// mHandler will be released at Shutdown(), so there is no need to join cycle
// collection.
nsCOMPtr<nsIIcc> mHandler;
Nullable<OwningMozIccInfoOrMozGsmIccInfoOrMozCdmaIccInfo> mIccInfo;
};

135
dom/icc/IccCallback.cpp Normal file
Просмотреть файл

@ -0,0 +1,135 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "IccCallback.h"
#include "mozilla/dom/IccCardLockError.h"
#include "mozilla/dom/MozIccBinding.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ToJSValue.h"
#include "nsJSUtils.h"
#include "nsServiceManagerUtils.h"
namespace mozilla {
namespace dom {
namespace icc {
NS_IMPL_ISUPPORTS(IccCallback, nsIIccCallback)
IccCallback::IccCallback(nsPIDOMWindow* aWindow, DOMRequest* aRequest,
bool aIsCardLockEnabled)
: mWindow(aWindow)
, mRequest(aRequest)
, mIsCardLockEnabled(aIsCardLockEnabled)
{
}
IccCallback::IccCallback(nsPIDOMWindow* aWindow, Promise* aPromise)
: mWindow(aWindow)
, mPromise(aPromise)
{
}
nsresult
IccCallback::NotifySuccess(JS::Handle<JS::Value> aResult)
{
nsCOMPtr<nsIDOMRequestService> rs =
do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
return rs->FireSuccessAsync(mRequest, aResult);
}
nsresult
IccCallback::NotifyGetCardLockEnabled(bool aResult)
{
IccCardLockStatus result;
result.mEnabled.Construct(aResult);
AutoJSAPI jsapi;
if (NS_WARN_IF(!jsapi.Init(mWindow))) {
return NS_ERROR_FAILURE;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> jsResult(cx);
if (!ToJSValue(cx, result, &jsResult)) {
JS_ClearPendingException(cx);
return NS_ERROR_TYPE_ERR;
}
return NotifySuccess(jsResult);
}
NS_IMETHODIMP
IccCallback::NotifySuccess()
{
return NotifySuccess(JS::UndefinedHandleValue);
}
NS_IMETHODIMP
IccCallback::NotifySuccessWithBoolean(bool aResult)
{
if (mPromise) {
mPromise->MaybeResolve(aResult ? JS::TrueHandleValue : JS::FalseHandleValue);
return NS_OK;
}
return mIsCardLockEnabled
? NotifyGetCardLockEnabled(aResult)
: NotifySuccess(aResult ? JS::TrueHandleValue : JS::FalseHandleValue);
}
NS_IMETHODIMP
IccCallback::NotifyGetCardLockRetryCount(int32_t aCount)
{
// TODO: Bug 1125018 - Simplify The Result of GetCardLock and
// getCardLockRetryCount in MozIcc.webidl without a wrapper object.
IccCardLockRetryCount result;
result.mRetryCount.Construct(aCount);
AutoJSAPI jsapi;
if (NS_WARN_IF(!jsapi.Init(mWindow))) {
return NS_ERROR_FAILURE;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> jsResult(cx);
if (!ToJSValue(cx, result, &jsResult)) {
JS_ClearPendingException(cx);
return NS_ERROR_TYPE_ERR;
}
return NotifySuccess(jsResult);
}
NS_IMETHODIMP
IccCallback::NotifyError(const nsAString & aErrorMsg)
{
if (mPromise) {
mPromise->MaybeRejectBrokenly(aErrorMsg);
return NS_OK;
}
nsCOMPtr<nsIDOMRequestService> rs =
do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
return rs->FireErrorAsync(mRequest, aErrorMsg);
}
NS_IMETHODIMP
IccCallback::NotifyCardLockError(const nsAString & aErrorMsg,
int32_t aRetryCount)
{
nsRefPtr<IccCardLockError> error =
new IccCardLockError(mWindow, aErrorMsg, aRetryCount);
mRequest->FireDetailedError(error);
return NS_OK;
}
} // namespace icc
} // namespace dom
} // namespace mozilla

64
dom/icc/IccCallback.h Normal file
Просмотреть файл

@ -0,0 +1,64 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_icc_IccCallback_h
#define mozilla_dom_icc_IccCallback_h
#include "nsCOMPtr.h"
#include "nsIIccService.h"
namespace mozilla {
namespace dom {
class DOMRequest;
class Promise;
namespace icc {
/**
* A callback object for handling asynchronous request/response. This object is
* created when an asynchronous request is made and should be destroyed after
* Notify*Success/Error is called.
* The modules hold the reference of IccCallback in OOP mode and non-OOP mode
* are different.
* - OOP mode: IccRequestChild
* - non-OOP mode: IccService
* The reference should be released after Notify*Success/Error is called.
*/
class IccCallback final : public nsIIccCallback
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIICCCALLBACK
// TODO: Bug 1125018 - Simplify The Result of GetCardLock and
// getCardLockRetryCount in MozIcc.webidl without a wrapper object.
IccCallback(nsPIDOMWindow* aWindow, DOMRequest* aRequest,
bool aIsCardLockEnabled = false);
IccCallback(nsPIDOMWindow* aWindow, Promise* aPromise);
private:
~IccCallback() {}
nsresult
NotifySuccess(JS::Handle<JS::Value> aResult);
// TODO: Bug 1125018 - Simplify The Result of GetCardLock and
// getCardLockRetryCount in MozIcc.webidl without a wrapper object.
nsresult
NotifyGetCardLockEnabled(bool aResult);
nsCOMPtr<nsPIDOMWindow> mWindow;
nsRefPtr<DOMRequest> mRequest;
nsRefPtr<Promise> mPromise;
// TODO: Bug 1125018 - Simplify The Result of GetCardLock and
// getCardLockRetryCount in MozIcc.webidl without a wrapper object.
bool mIsCardLockEnabled;
};
} // namespace icc
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_icc_IccCallback_h

Просмотреть файл

@ -4,6 +4,7 @@
#include "mozilla/dom/IccInfo.h"
#include "mozilla/dom/icc/PIccTypes.h"
#include "nsPIDOMWindow.h"
#define CONVERT_STRING_TO_NULLABLE_ENUM(_string, _enumType, _enum) \
@ -20,29 +21,110 @@
using namespace mozilla::dom;
using mozilla::dom::icc::IccInfoData;
// IccInfo
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(IccInfo, mWindow, mIccInfo)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(IccInfo, mWindow)
NS_IMPL_CYCLE_COLLECTING_ADDREF(IccInfo)
NS_IMPL_CYCLE_COLLECTING_RELEASE(IccInfo)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IccInfo)
NS_INTERFACE_MAP_ENTRY(nsIIccInfo)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
IccInfo::IccInfo(nsPIDOMWindow* aWindow)
: mWindow(aWindow)
{
mIccType.SetIsVoid(true);
mIccid.SetIsVoid(true);
mMcc.SetIsVoid(true);
mMnc.SetIsVoid(true);
mSpn.SetIsVoid(true);
}
IccInfo::IccInfo(const IccInfoData& aData)
{
mIccType = aData.iccType();
mIccid = aData.iccid();
mMcc = aData.mcc();
mMnc = aData.mnc();
mSpn = aData.spn();
mIsDisplayNetworkNameRequired = aData.isDisplayNetworkNameRequired();
mIsDisplaySpnRequired = aData.isDisplaySpnRequired();
}
// nsIIccInfo
NS_IMETHODIMP
IccInfo::GetIccType(nsAString & aIccType)
{
aIccType = mIccType;
return NS_OK;
}
NS_IMETHODIMP
IccInfo::GetIccid(nsAString & aIccid)
{
aIccid = mIccid;
return NS_OK;
}
NS_IMETHODIMP
IccInfo::GetMcc(nsAString & aMcc)
{
aMcc = mMcc;
return NS_OK;
}
NS_IMETHODIMP
IccInfo::GetMnc(nsAString & aMnc)
{
aMnc = mMnc;
return NS_OK;
}
NS_IMETHODIMP
IccInfo::GetSpn(nsAString & aSpn)
{
aSpn = mSpn;
return NS_OK;
}
NS_IMETHODIMP
IccInfo::GetIsDisplayNetworkNameRequired(bool *aIsDisplayNetworkNameRequired)
{
*aIsDisplayNetworkNameRequired = mIsDisplayNetworkNameRequired;
return NS_OK;
}
NS_IMETHODIMP
IccInfo::GetIsDisplaySpnRequired(bool *aIsDisplaySpnRequired)
{
*aIsDisplaySpnRequired = mIsDisplaySpnRequired;
return NS_OK;
}
void
IccInfo::Update(nsIIccInfo* aInfo)
{
mIccInfo = aInfo;
NS_ASSERTION(aInfo, "aInfo is null");
aInfo->GetIccType(mIccType);
aInfo->GetIccid(mIccid);
aInfo->GetMcc(mMcc);
aInfo->GetMnc(mMnc);
aInfo->GetSpn(mSpn);
aInfo->GetIsDisplayNetworkNameRequired(
&mIsDisplayNetworkNameRequired);
aInfo->GetIsDisplaySpnRequired(
&mIsDisplaySpnRequired);
}
// WebIDL implementation
JSObject*
IccInfo::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
@ -52,15 +134,9 @@ IccInfo::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
Nullable<IccType>
IccInfo::GetIccType() const
{
if (!mIccInfo) {
return Nullable<IccType>();
}
nsAutoString type;
Nullable<IccType> iccType;
mIccInfo->GetIccType(type);
CONVERT_STRING_TO_NULLABLE_ENUM(type, IccType, iccType);
CONVERT_STRING_TO_NULLABLE_ENUM(mIccType, IccType, iccType);
return iccType;
}
@ -68,96 +144,76 @@ IccInfo::GetIccType() const
void
IccInfo::GetIccid(nsAString& aIccId) const
{
if (!mIccInfo) {
aIccId.SetIsVoid(true);
return;
}
mIccInfo->GetIccid(aIccId);
aIccId = mIccid;
}
void
IccInfo::GetMcc(nsAString& aMcc) const
{
if (!mIccInfo) {
aMcc.SetIsVoid(true);
return;
}
mIccInfo->GetMcc(aMcc);
aMcc = mMcc;
}
void
IccInfo::GetMnc(nsAString& aMnc) const
{
if (!mIccInfo) {
aMnc.SetIsVoid(true);
return;
}
mIccInfo->GetMnc(aMnc);
aMnc = mMnc;
}
void
IccInfo::GetSpn(nsAString& aSpn) const
{
if (!mIccInfo) {
aSpn.SetIsVoid(true);
return;
}
mIccInfo->GetSpn(aSpn);
aSpn = mSpn;
}
bool
IccInfo::IsDisplayNetworkNameRequired() const
{
if (!mIccInfo) {
return false;
}
bool isDisplayNetworkNameRequired;
mIccInfo->GetIsDisplayNetworkNameRequired(&isDisplayNetworkNameRequired);
return isDisplayNetworkNameRequired;
return mIsDisplayNetworkNameRequired;
}
bool
IccInfo::IsDisplaySpnRequired() const
{
if (!mIccInfo) {
return false;
}
bool isDisplaySpnRequired;
mIccInfo->GetIsDisplaySpnRequired(&isDisplaySpnRequired);
return isDisplaySpnRequired;
return mIsDisplaySpnRequired;
}
// GsmIccInfo
NS_IMPL_CYCLE_COLLECTION_INHERITED(GsmIccInfo, IccInfo, mGsmIccInfo)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(GsmIccInfo)
NS_INTERFACE_MAP_END_INHERITING(IccInfo)
NS_IMPL_ADDREF_INHERITED(GsmIccInfo, IccInfo)
NS_IMPL_RELEASE_INHERITED(GsmIccInfo, IccInfo)
NS_IMPL_ISUPPORTS_INHERITED(GsmIccInfo, IccInfo, nsIGsmIccInfo)
GsmIccInfo::GsmIccInfo(nsPIDOMWindow* aWindow)
: IccInfo(aWindow)
{
mPhoneNumber.SetIsVoid(true);
}
GsmIccInfo::GsmIccInfo(const IccInfoData& aData)
: IccInfo(aData)
{
mPhoneNumber = aData.phoneNumber();
}
// nsIGsmIccInfo
NS_IMETHODIMP
GsmIccInfo::GetMsisdn(nsAString & aMsisdn)
{
aMsisdn = mPhoneNumber;
return NS_OK;
}
// WebIDL implementation
void
GsmIccInfo::Update(nsIGsmIccInfo* aInfo)
{
MOZ_ASSERT(aInfo);
nsCOMPtr<nsIIccInfo> iccInfo = do_QueryInterface(aInfo);
MOZ_ASSERT(iccInfo);
IccInfo::Update(iccInfo);
mGsmIccInfo = aInfo;
aInfo->GetMsisdn(mPhoneNumber);
}
JSObject*
@ -169,39 +225,57 @@ GsmIccInfo::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
void
GsmIccInfo::GetMsisdn(nsAString& aMsisdn) const
{
if (!mGsmIccInfo) {
aMsisdn.SetIsVoid(true);
return;
}
mGsmIccInfo->GetMsisdn(aMsisdn);
aMsisdn = mPhoneNumber;
}
// CdmaIccInfo
NS_IMPL_CYCLE_COLLECTION_INHERITED(CdmaIccInfo, IccInfo, mCdmaIccInfo)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(CdmaIccInfo)
NS_INTERFACE_MAP_END_INHERITING(IccInfo)
NS_IMPL_ADDREF_INHERITED(CdmaIccInfo, IccInfo)
NS_IMPL_RELEASE_INHERITED(CdmaIccInfo, IccInfo)
NS_IMPL_ISUPPORTS_INHERITED(CdmaIccInfo, IccInfo, nsICdmaIccInfo)
CdmaIccInfo::CdmaIccInfo(nsPIDOMWindow* aWindow)
: IccInfo(aWindow)
{
mPhoneNumber.SetIsVoid(true);
}
CdmaIccInfo::CdmaIccInfo(const IccInfoData& aData)
: IccInfo(aData)
{
mPhoneNumber = aData.phoneNumber();
mPrlVersion = aData.prlVersion();
}
// nsICdmaIccInfo
NS_IMETHODIMP
CdmaIccInfo::GetMdn(nsAString & aMdn)
{
aMdn = mPhoneNumber;
return NS_OK;
}
NS_IMETHODIMP
CdmaIccInfo::GetPrlVersion(int32_t *aPrlVersion)
{
*aPrlVersion = mPrlVersion;
return NS_OK;
}
void
CdmaIccInfo::Update(nsICdmaIccInfo* aInfo)
{
MOZ_ASSERT(aInfo);
nsCOMPtr<nsIIccInfo> iccInfo = do_QueryInterface(aInfo);
MOZ_ASSERT(iccInfo);
IccInfo::Update(iccInfo);
mCdmaIccInfo = aInfo;
aInfo->GetMdn(mPhoneNumber);
aInfo->GetPrlVersion(&mPrlVersion);
}
// WebIDL implementation
JSObject*
CdmaIccInfo::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
@ -211,23 +285,11 @@ CdmaIccInfo::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
void
CdmaIccInfo::GetMdn(nsAString& aMdn) const
{
if (!mCdmaIccInfo) {
aMdn.SetIsVoid(true);
return;
}
mCdmaIccInfo->GetMdn(aMdn);
aMdn = mPhoneNumber;
}
int32_t
CdmaIccInfo::PrlVersion() const
{
if (!mCdmaIccInfo) {
return 0;
}
int32_t prlVersion;
mCdmaIccInfo->GetPrlVersion(&prlVersion);
return prlVersion;
return mPrlVersion;
}

Просмотреть файл

@ -14,14 +14,20 @@ class nsPIDOMWindow;
namespace mozilla {
namespace dom {
class IccInfo : public nsISupports
namespace icc {
class IccInfoData;
} // namespace icc
class IccInfo : public nsIIccInfo
, public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IccInfo)
NS_DECL_NSIICCINFO
explicit IccInfo(nsPIDOMWindow* aWindow);
explicit IccInfo(const icc::IccInfoData& aData);
void
Update(nsIIccInfo* aInfo);
@ -61,18 +67,30 @@ public:
protected:
virtual ~IccInfo() {}
protected:
nsCOMPtr<nsPIDOMWindow> mWindow;
nsCOMPtr<nsIIccInfo> mIccInfo;
// To prevent compiling error in OS_WIN in auto-generated UnifiedBindingsXX.cpp,
// we have all data fields expended here instead of having a data member of
// |IccInfoData| defined in PIccTypes.h which indirectly includes "windows.h"
// See 925382 for the restriction of including "windows.h" in UnifiedBindings.cpp.
nsString mIccType;
nsString mIccid;
nsString mMcc;
nsString mMnc;
nsString mSpn;
bool mIsDisplayNetworkNameRequired;
bool mIsDisplaySpnRequired;
};
class GsmIccInfo final : public IccInfo
, public nsIGsmIccInfo
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(GsmIccInfo, IccInfo)
NS_FORWARD_NSIICCINFO(IccInfo::)
NS_DECL_NSIGSMICCINFO
explicit GsmIccInfo(nsPIDOMWindow* aWindow);
explicit GsmIccInfo(const icc::IccInfoData& aData);
void
Update(nsIGsmIccInfo* aInfo);
@ -88,17 +106,19 @@ public:
private:
~GsmIccInfo() {}
private:
nsCOMPtr<nsIGsmIccInfo> mGsmIccInfo;
nsString mPhoneNumber;
};
class CdmaIccInfo final : public IccInfo
, public nsICdmaIccInfo
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CdmaIccInfo, IccInfo)
NS_FORWARD_NSIICCINFO(IccInfo::)
NS_DECL_NSICDMAICCINFO
explicit CdmaIccInfo(nsPIDOMWindow* aWindow);
explicit CdmaIccInfo(const icc::IccInfoData& aData);
void
Update(nsICdmaIccInfo* aInfo);
@ -117,8 +137,8 @@ public:
private:
~CdmaIccInfo() {}
private:
nsCOMPtr<nsICdmaIccInfo> mCdmaIccInfo;
nsString mPhoneNumber;
int32_t mPrlVersion;
};
} // namespace dom

Просмотреть файл

@ -20,6 +20,8 @@ IccListener::IccListener(IccManager* aIccManager, uint32_t aClientId)
{
MOZ_ASSERT(mIccManager);
// TODO: Bug 1114938, Refactor STK in MozIcc.webidl with IPDL.
// Remove the registration to IccProvider.
mProvider = do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
if (!mProvider) {
@ -27,17 +29,34 @@ IccListener::IccListener(IccManager* aIccManager, uint32_t aClientId)
return;
}
nsCOMPtr<nsIIccService> iccService = do_GetService(ICC_SERVICE_CONTRACTID);
if (!iccService) {
NS_WARNING("Could not acquire nsIIccService!");
return;
}
iccService->GetIccByServiceId(mClientId, getter_AddRefs(mHandler));
if (!mHandler) {
NS_WARNING("Could not acquire nsIIcc!");
return;
}
nsCOMPtr<nsIIccInfo> iccInfo;
mProvider->GetIccInfo(mClientId, getter_AddRefs(iccInfo));
mHandler->GetIccInfo(getter_AddRefs(iccInfo));
if (iccInfo) {
nsString iccId;
iccInfo->GetIccid(iccId);
if (!iccId.IsEmpty()) {
mIcc = new Icc(mIccManager->GetOwner(), mClientId, iccInfo);
mIcc = new Icc(mIccManager->GetOwner(), mClientId, mHandler, iccInfo);
}
}
DebugOnly<nsresult> rv = mProvider->RegisterIccMsg(mClientId, this);
DebugOnly<nsresult> rv = mHandler->RegisterListener(this);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"Failed registering icc listener with Icc Handler");
rv = mProvider->RegisterIccMsg(mClientId, this);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"Failed registering icc messages with provider");
}
@ -50,11 +69,18 @@ IccListener::~IccListener()
void
IccListener::Shutdown()
{
// TODO: Bug 1114938, Refactor STK in MozIcc.webidl with IPDL.
// Remove the unregistration to IccProvider.
if (mProvider) {
mProvider->UnregisterIccMsg(mClientId, this);
mProvider = nullptr;
}
if (mHandler) {
mHandler->UnregisterListener(this);
mHandler = nullptr;
}
if (mIcc) {
mIcc->Shutdown();
mIcc = nullptr;
@ -98,8 +124,12 @@ IccListener::NotifyCardStateChanged()
NS_IMETHODIMP
IccListener::NotifyIccInfoChanged()
{
if (!mHandler) {
return NS_OK;
}
nsCOMPtr<nsIIccInfo> iccInfo;
mProvider->GetIccInfo(mClientId, getter_AddRefs(iccInfo));
mHandler->GetIccInfo(getter_AddRefs(iccInfo));
// Create/delete icc object based on current iccInfo.
// 1. If the mIcc is nullptr and iccInfo has valid data, create icc object and
@ -111,7 +141,7 @@ IccListener::NotifyIccInfoChanged()
nsString iccId;
iccInfo->GetIccid(iccId);
if (!iccId.IsEmpty()) {
mIcc = new Icc(mIccManager->GetOwner(), mClientId, iccInfo);
mIcc = new Icc(mIccManager->GetOwner(), mClientId, mHandler, iccInfo);
mIccManager->NotifyIccAdd(iccId);
mIcc->NotifyEvent(NS_LITERAL_STRING("iccinfochange"));
}

Просмотреть файл

@ -7,6 +7,7 @@
#include "nsAutoPtr.h"
#include "nsIIccProvider.h"
#include "nsIIccService.h"
namespace mozilla {
namespace dom {
@ -42,9 +43,12 @@ private:
// IccListener, this will release the reference and break the cycle.
nsRefPtr<Icc> mIcc;
nsRefPtr<IccManager> mIccManager;
// mProvider is a xpcom service and will be released at shutdown, so it
// mProvider is a xpcom service and will be released at Shutdown(), so it
// doesn't need to be cycle collected.
nsCOMPtr<nsIIccProvider> mProvider;
// mHandler will be released at Shutdown(), there is no need to join cycle
// collection.
nsCOMPtr<nsIIcc> mHandler;
};
} // namespace dom

Просмотреть файл

@ -10,6 +10,15 @@
#include "mozilla/dom/IccChangeEvent.h"
#include "mozilla/Preferences.h"
#include "nsIIccInfo.h"
// Service instantiation
#include "ipc/IccIPCService.h"
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
// TODO: Bug 815526, deprecate RILContentHelper.
#include "nsIRadioInterfaceLayer.h"
#include "nsRadioInterfaceLayer.h"
#include "nsIGonkIccService.h"
#endif
#include "nsXULAppAPI.h" // For XRE_GetProcessType()
using namespace mozilla::dom;
@ -129,3 +138,25 @@ IccManager::GetIccById(const nsAString& aIccId) const
}
return nullptr;
}
already_AddRefed<nsIIccService>
NS_CreateIccService()
{
nsCOMPtr<nsIIccService> service;
if (XRE_GetProcessType() == GeckoProcessType_Content) {
service = new mozilla::dom::icc::IccIPCService();
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
} else {
// TODO: Bug 815526, deprecate RILContentHelper.
nsCOMPtr <nsIRadioInterfaceLayer> ril =
do_GetService(NS_RADIOINTERFACELAYER_CONTRACTID);
nsCOMPtr <nsIRadioInterfaceLayer_new> ril_new(do_QueryInterface(ril));
service = (ril_new) ? do_GetService(GONK_ICC_SERVICE_CONTRACTID)
: do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
#endif
}
return service.forget();
}

Просмотреть файл

@ -7,7 +7,6 @@
#include "mozilla/DOMEventTargetHelper.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIIccProvider.h"
#include "nsTArrayHelpers.h"
namespace mozilla {
@ -25,7 +24,7 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IccManager, DOMEventTargetHelper)
IccManager(nsPIDOMWindow* aWindow);
explicit IccManager(nsPIDOMWindow* aWindow);
void
Shutdown();

437
dom/icc/gonk/IccService.js Normal file
Просмотреть файл

@ -0,0 +1,437 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
var RIL = {};
Cu.import("resource://gre/modules/ril_consts.js", RIL);
const GONK_ICCSERVICE_CONTRACTID = "@mozilla.org/icc/gonkiccservice;1";
const GONK_ICCSERVICE_CID = Components.ID("{df854256-9554-11e4-a16c-c39e8d106c26}");
const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown";
const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
const kPrefRilDebuggingEnabled = "ril.debugging.enabled";
const kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
XPCOMUtils.defineLazyServiceGetter(this, "gRadioInterfaceLayer",
"@mozilla.org/ril;1",
"nsIRadioInterfaceLayer");
let DEBUG = RIL.DEBUG_RIL;
function debug(s) {
dump("IccService: " + s);
}
function IccInfo() {}
IccInfo.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIIccInfo]),
// nsIIccInfo
iccType: null,
iccid: null,
mcc: null,
mnc: null,
spn: null,
isDisplayNetworkNameRequired: false,
isDisplaySpnRequired: false
};
function GsmIccInfo() {}
GsmIccInfo.prototype = {
__proto__: IccInfo.prototype,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIGsmIccInfo,
Ci.nsIIccInfo]),
// nsIGsmIccInfo
msisdn: null
};
function CdmaIccInfo() {}
CdmaIccInfo.prototype = {
__proto__: IccInfo.prototype,
QueryInterface: XPCOMUtils.generateQI([Ci.nsICdmaIccInfo,
Ci.nsIIccInfo]),
// nsICdmaIccInfo
mdn: null,
prlVersion: 0
};
function IccService() {
this._iccs = [];
let numClients = gRadioInterfaceLayer.numRadioInterfaces;
for (let i = 0; i < numClients; i++) {
this._iccs.push(new Icc(gRadioInterfaceLayer.getRadioInterface(i)));
}
this._updateDebugFlag();
Services.prefs.addObserver(kPrefRilDebuggingEnabled, this, false);
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
}
IccService.prototype = {
classID: GONK_ICCSERVICE_CID,
classInfo: XPCOMUtils.generateCI({classID: GONK_ICCSERVICE_CID,
contractID: GONK_ICCSERVICE_CONTRACTID,
classDescription: "IccService",
interfaces: [Ci.nsIIccService,
Ci.nsIGonkIccService],
flags: Ci.nsIClassInfo.SINGLETON}),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIIccService,
Ci.nsIGonkIccService,
Ci.nsIObserver]),
// An array of Icc instances.
_iccs: null,
_updateDebugFlag: function() {
try {
DEBUG = DEBUG ||
Services.prefs.getBoolPref(kPrefRilDebuggingEnabled);
} catch (e) {}
},
/**
* nsIIccService interface.
*/
getIccByServiceId: function(aServiceId) {
let icc = this._iccs[aServiceId];
if (!icc) {
throw Cr.NS_ERROR_UNEXPECTED;
}
return icc;
},
/**
* nsIGonkIccService interface.
*/
notifyCardStateChanged: function(aServiceId, aCardState) {
if (DEBUG) {
debug("notifyCardStateChanged for service Id: " + aServiceId +
", CardState: " + aCardState);
}
this.getIccByServiceId(aServiceId)._updateCardState(aCardState);
},
notifyIccInfoChanged: function(aServiceId, aIccInfo) {
if (DEBUG) {
debug("notifyIccInfoChanged for service Id: " + aServiceId +
", IccInfo: " + JSON.stringify(aIccInfo));
}
this.getIccByServiceId(aServiceId)._updateIccInfo(aIccInfo);
},
notifyImsiChanged: function(aServiceId, aImsi) {
if (DEBUG) {
debug("notifyImsiChanged for service Id: " + aServiceId +
", Imsi: " + aImsi);
}
let icc = this.getIccByServiceId(aServiceId);
icc._imsi = aImsi;
},
/**
* nsIObserver interface.
*/
observe: function(aSubject, aTopic, aData) {
switch (aTopic) {
case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
if (aData === kPrefRilDebuggingEnabled) {
this._updateDebugFlag();
}
break;
case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
Services.prefs.removeObserver(kPrefRilDebuggingEnabled, this);
Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
break;
}
}
};
function Icc(aRadioInterface) {
this._radioInterface = aRadioInterface;
this._listeners = [];
}
Icc.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIIcc]),
_radioInterface: null,
_imsi: null,
_listeners: null,
_updateCardState: function(aCardState) {
if (this.cardState != aCardState) {
this.cardState = aCardState;
}
this._deliverListenerEvent("notifyCardStateChanged");
},
// An utility function to copy objects.
_updateInfo: function(aSrcInfo, aDestInfo) {
for (let key in aSrcInfo) {
aDestInfo[key] = aSrcInfo[key];
}
},
/**
* 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.
*/
_updateIccInfo: function(aIccInfo) {
// Card is not detected, clear iccInfo to null.
if (!aIccInfo || !aIccInfo.iccid) {
if (this.iccInfo) {
if (DEBUG) {
debug("Card is not detected, clear iccInfo to null.");
}
this.iccInfo = null;
this._deliverListenerEvent("notifyIccInfoChanged");
}
return;
}
// If iccInfo is null, new corresponding object based on iccType.
if (!this.iccInfo ||
this.iccInfo.iccType != aIccInfo.iccType) {
if (aIccInfo.iccType === "ruim" || aIccInfo.iccType === "csim") {
this.iccInfo = new CdmaIccInfo();
} else if (aIccInfo.iccType === "sim" || aIccInfo.iccType === "usim") {
this.iccInfo = new GsmIccInfo();
} else {
this.iccInfo = new IccInfo();
}
}
this._updateInfo(aIccInfo, this.iccInfo);
this._deliverListenerEvent("notifyIccInfoChanged");
// Update lastKnownSimMcc.
if (aIccInfo.mcc) {
try {
Services.prefs.setCharPref("ril.lastKnownSimMcc",
aIccInfo.mcc.toString());
} catch (e) {}
}
},
_deliverListenerEvent: function(aName, aArgs) {
let listeners = this._listeners.slice();
for (let listener of listeners) {
if (this._listeners.indexOf(listener) === -1) {
continue;
}
let handler = listener[aName];
if (typeof handler != "function") {
throw new Error("No handler for " + aName);
}
try {
handler.apply(listener, aArgs);
} catch (e) {
if (DEBUG) {
debug("listener for " + aName + " threw an exception: " + e);
}
}
}
},
_modifyCardLock: function(aOperation, aOptions, aCallback) {
this._radioInterface.sendWorkerMessage(aOperation,
aOptions,
(aResponse) => {
if (aResponse.errorMsg) {
let retryCount =
(aResponse.retryCount !== undefined) ? aResponse.retryCount : -1;
aCallback.notifyCardLockError(aResponse.errorMsg, retryCount);
return;
}
aCallback.notifySuccess();
});
},
/**
* Helper to match the MVNO pattern with IMSI.
*
* Note: Characters 'x' and 'X' in MVNO are skipped and not compared.
* E.g., if the aMvnoData passed is '310260x10xxxxxx', then the
* function returns true only if imsi has the same first 6 digits, 8th
* and 9th digit.
*
* @param aMvnoData
* MVNO pattern.
* @param aImsi
* IMSI of this ICC.
*
* @return true if matched.
*/
_isImsiMatches: function(aMvnoData, aImsi) {
// This should not be an error, but a mismatch.
if (aMvnoData.length > aImsi.length) {
return false;
}
for (let i = 0; i < aMvnoData.length; i++) {
let c = aMvnoData[i];
if ((c !== 'x') && (c !== 'X') && (c !== aImsi[i])) {
return false;
}
}
return true;
},
/**
* nsIIcc interface.
*/
iccInfo: null,
cardState: Ci.nsIIcc.CARD_STATE_UNKNOWN,
registerListener: function(aListener) {
if (this._listeners.indexOf(aListener) >= 0) {
throw Cr.NS_ERROR_UNEXPECTED;
}
this._listeners.push(aListener);
},
unregisterListener: function(aListener) {
let index = this._listeners.indexOf(aListener);
if (index >= 0) {
this._listeners.splice(index, 1);
}
},
getCardLockEnabled: function(aLockType, aCallback) {
this._radioInterface.sendWorkerMessage("iccGetCardLockEnabled",
{ lockType: aLockType },
(aResponse) => {
if (aResponse.errorMsg) {
aCallback.notifyError(aResponse.errorMsg);
return;
}
aCallback.notifySuccessWithBoolean(aResponse.enabled);
});
},
unlockCardLock: function(aLockType, aPassword, aNewPin, aCallback) {
this._modifyCardLock("iccUnlockCardLock",
{ lockType: aLockType,
password: aPassword,
newPin: aNewPin },
aCallback);
},
setCardLockEnabled: function(aLockType, aPassword, aEnabled, aCallback) {
this._modifyCardLock("iccSetCardLockEnabled",
{ lockType: aLockType,
password: aPassword,
enabled: aEnabled },
aCallback);
},
changeCardLockPassword: function(aLockType, aPassword, aNewPassword, aCallback) {
this._modifyCardLock("iccChangeCardLockPassword",
{ lockType: aLockType,
password: aPassword,
newPassword: aNewPassword, },
aCallback);
},
getCardLockRetryCount: function(aLockType, aCallback) {
this._radioInterface.sendWorkerMessage("iccGetCardLockRetryCount",
{ lockType: aLockType },
(aResponse) => {
if (aResponse.errorMsg) {
aCallback.notifyError(aResponse.errorMsg);
return;
}
aCallback.notifyGetCardLockRetryCount(aResponse.retryCount);
});
},
matchMvno: function(aMvnoType, aMvnoData, aCallback) {
if (!aMvnoData) {
aCallback.notifyError(RIL.GECKO_ERROR_INVALID_PARAMETER);
return;
}
switch (aMvnoType) {
case Ci.nsIIcc.CARD_MVNO_TYPE_IMSI:
let imsi = this._imsi;
if (!imsi) {
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
break;
}
aCallback.notifySuccessWithBoolean(
this._isImsiMatches(aMvnoData, imsi));
break;
case Ci.nsIIcc.CARD_MVNO_TYPE_SPN:
let spn = this.iccInfo && this.iccInfo.spn;
if (!spn) {
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
break;
}
aCallback.notifySuccessWithBoolean(spn == aMvnoData);
break;
case Ci.nsIIcc.CARD_MVNO_TYPE_GID:
this._radioInterface.sendWorkerMessage("getGID1",
null,
(aResponse) => {
let gid = aResponse.gid1;
let mvnoDataLength = aMvnoData.length;
if (!gid) {
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
} else if (mvnoDataLength > gid.length) {
aCallback.notifySuccessWithBoolean(false);
} else {
let result =
gid.substring(0, mvnoDataLength).toLowerCase() ==
aMvnoData.toLowerCase();
aCallback.notifySuccessWithBoolean(result);
}
});
break;
default:
aCallback.notifyError(RIL.GECKO_ERROR_MODE_NOT_SUPPORTED);
break;
}
},
getServiceStateEnabled: function(aService, aCallback) {
this._radioInterface.sendWorkerMessage("getIccServiceState",
{ service: aService },
(aResponse) => {
if (aResponse.errorMsg) {
aCallback.notifyError(aResponse.errorMsg);
return;
}
aCallback.notifySuccessWithBoolean(aResponse.result);
});
}
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([IccService]);

Просмотреть файл

@ -0,0 +1,6 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
component {df854256-9554-11e4-a16c-c39e8d106c26} IccService.js
contract @mozilla.org/icc/gonkiccservice;1 {df854256-9554-11e4-a16c-c39e8d106c26}

Просмотреть файл

@ -6,11 +6,13 @@
XPIDL_SOURCES += [
'nsIIccInfo.idl',
'nsIIccProvider.idl',
'nsIIccProvider.idl', # TODO: Bug 815526, deprecate RILContentHelper.
'nsIIccService.idl',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
XPIDL_SOURCES += [
'nsIGonkIccService.idl',
'nsIIccMessenger.idl',
]

Просмотреть файл

@ -0,0 +1,21 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIIccService.idl"
%{C++
#define GONK_ICC_SERVICE_CONTRACTID \
"@mozilla.org/icc/gonkiccservice;1"
%}
[scriptable, uuid(a037b8a2-b027-11e4-9496-c3b7af59a512)]
interface nsIGonkIccService : nsIIccService
{
// TODO: Bug 1114938 - Refactor STK in MozIcc.webidl with IPDL:
// void notifyStkCommand(in unsigned long aServiceId, in jsval aStkcommand);
// void notifyStkSessionEnd(in unsigned long aServiceId);
void notifyCardStateChanged(in unsigned long aServiceId, in unsigned long aCardState);
void notifyIccInfoChanged(in unsigned long aServiceId, in jsval aIccInfo);
void notifyImsiChanged(in unsigned long aServiceId, in DOMString aImsi);
};

Просмотреть файл

@ -7,15 +7,7 @@
interface nsIDOMDOMRequest;
interface nsIDOMWindow;
interface nsIIccInfo;
[scriptable, uuid(7c0ada3d-d8d4-493e-9243-fa3df39855e4)]
interface nsIIccListener : nsISupports
{
void notifyStkCommand(in DOMString aMessage);
void notifyStkSessionEnd();
void notifyCardStateChanged();
void notifyIccInfoChanged();
};
interface nsIIccListener;
[scriptable, uuid(6136acab-b50e-494a-a86d-df392a032897)]
interface nsIIccChannelCallback : nsISupports
@ -58,83 +50,9 @@ interface nsIIccChannelCallback : nsISupports
/**
* XPCOM component (in the content process) that provides the ICC information.
*/
[scriptable, uuid(a203cd2e-2280-4d8e-a687-42b745d322c1)]
[scriptable, uuid(7dd6e186-b007-11e4-9b7e-7717d7863cb8)]
interface nsIIccProvider : nsISupports
{
// MUST match enum IccCardState in MozIcc.webidl!
const unsigned long CARD_STATE_UNKNOWN = 0;
const unsigned long CARD_STATE_READY = 1;
const unsigned long CARD_STATE_PIN_REQUIRED = 2;
const unsigned long CARD_STATE_PUK_REQUIRED = 3;
const unsigned long CARD_STATE_PERMANENT_BLOCKED = 4;
const unsigned long CARD_STATE_PERSONALIZATION_IN_PROGRESS = 5;
const unsigned long CARD_STATE_PERSONALIZATION_READY = 6;
const unsigned long CARD_STATE_NETWORK_LOCKED = 7;
const unsigned long CARD_STATE_NETWORK_SUBSET_LOCKED = 8;
const unsigned long CARD_STATE_CORPORATE_LOCKED = 9;
const unsigned long CARD_STATE_SERVICE_PROVIDER_LOCKED = 10;
const unsigned long CARD_STATE_SIM_LOCKED = 11;
const unsigned long CARD_STATE_NETWORK_PUK_REQUIRED = 12;
const unsigned long CARD_STATE_NETWORK_SUBSET_PUK_REQUIRED = 13;
const unsigned long CARD_STATE_CORPORATE_PUK_REQUIRED = 14;
const unsigned long CARD_STATE_SERVICE_PROVIDER_PUK_REQUIRED = 15;
const unsigned long CARD_STATE_SIM_PUK_REQUIRED = 16;
const unsigned long CARD_STATE_NETWORK1_LOCKED = 17;
const unsigned long CARD_STATE_NETWORK2_LOCKED = 18;
const unsigned long CARD_STATE_HRPD_NETWORK_LOCKED = 19;
const unsigned long CARD_STATE_RUIM_CORPORATE_LOCKED = 20;
const unsigned long CARD_STATE_RUIM_SERVICE_PROVIDER_LOCKED = 21;
const unsigned long CARD_STATE_RUIM_LOCKED = 22;
const unsigned long CARD_STATE_NETWORK1_PUK_REQUIRED = 23;
const unsigned long CARD_STATE_NETWORK2_PUK_REQUIRED = 24;
const unsigned long CARD_STATE_HRPD_NETWORK_PUK_REQUIRED = 25;
const unsigned long CARD_STATE_RUIM_CORPORATE_PUK_REQUIRED = 26;
const unsigned long CARD_STATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED = 27;
const unsigned long CARD_STATE_RUIM_PUK_REQUIRED = 28;
const unsigned long CARD_STATE_ILLEGAL = 29;
const unsigned long CARD_STATE_UNDETECTED = 4294967295; // UINT32_MAX
// MUST match with enum IccLockType in MozIcc.webidl
const unsigned long CARD_LOCK_TYPE_PIN = 0;
const unsigned long CARD_LOCK_TYPE_PIN2 = 1;
const unsigned long CARD_LOCK_TYPE_PUK = 2;
const unsigned long CARD_LOCK_TYPE_PUK2 = 3;
const unsigned long CARD_LOCK_TYPE_NCK = 4;
const unsigned long CARD_LOCK_TYPE_NSCK = 5;
const unsigned long CARD_LOCK_TYPE_NCK1 = 6;
const unsigned long CARD_LOCK_TYPE_NCK2 = 7;
const unsigned long CARD_LOCK_TYPE_HNCK = 8;
const unsigned long CARD_LOCK_TYPE_CCK = 9;
const unsigned long CARD_LOCK_TYPE_SPCK = 10;
const unsigned long CARD_LOCK_TYPE_PCK = 11;
const unsigned long CARD_LOCK_TYPE_RCCK = 12;
const unsigned long CARD_LOCK_TYPE_RSPCK = 13;
const unsigned long CARD_LOCK_TYPE_NCK_PUK = 14;
const unsigned long CARD_LOCK_TYPE_NSCK_PUK = 15;
const unsigned long CARD_LOCK_TYPE_NCK1_PUK = 16;
const unsigned long CARD_LOCK_TYPE_NCK2_PUK = 17;
const unsigned long CARD_LOCK_TYPE_HNCK_PUK = 18;
const unsigned long CARD_LOCK_TYPE_CCK_PUK = 19;
const unsigned long CARD_LOCK_TYPE_SPCK_PUK = 20;
const unsigned long CARD_LOCK_TYPE_PCK_PUK = 21;
const unsigned long CARD_LOCK_TYPE_RCCK_PUK = 22;
const unsigned long CARD_LOCK_TYPE_RSPCK_PUK = 23;
const unsigned long CARD_LOCK_TYPE_FDN = 24;
// MUST match with enum IccContactType in MozIcc.webidl
const unsigned long CARD_CONTACT_TYPE_ADN = 0;
const unsigned long CARD_CONTACT_TYPE_FDN = 1;
const unsigned long CARD_CONTACT_TYPE_SDN = 2;
// MUST match with enum IccMvnoType in MozIcc.webidl
const unsigned long CARD_MVNO_TYPE_IMSI = 0;
const unsigned long CARD_MVNO_TYPE_SPN = 1;
const unsigned long CARD_MVNO_TYPE_GID = 2;
// MUST match with enum IccService in MozIcc.webidl
const unsigned long CARD_SERVICE_FDN = 0;
/**
* Called when a content process registers receiving unsolicited messages from
* RadioInterfaceLayer in the chrome process. Only a content process that has
@ -143,18 +61,6 @@ interface nsIIccProvider : nsISupports
void registerIccMsg(in unsigned long clientId, in nsIIccListener listener);
void unregisterIccMsg(in unsigned long clientId, in nsIIccListener listener);
/**
* UICC Information
*/
nsIIccInfo getIccInfo(in unsigned long clientId);
/**
* Card State
*
* One of the nsIIccProvider.CARD_STATE_* values.
*/
unsigned long getCardState(in unsigned long clientId);
/**
* STK interfaces.
*/
@ -173,31 +79,6 @@ interface nsIIccProvider : nsISupports
in nsIDOMWindow window,
in jsval event);
/**
* Card lock interfaces.
*/
nsIDOMDOMRequest getCardLockEnabled(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned long lockType);
nsIDOMDOMRequest unlockCardLock(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned long lockType,
in DOMString password,
[optional] in DOMString newPin);
nsIDOMDOMRequest setCardLockEnabled(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned long lockType,
in DOMString password,
in boolean enabled);
nsIDOMDOMRequest changeCardLockPassword(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned long lockType,
in DOMString password,
in DOMString newPassword);
nsIDOMDOMRequest getCardLockRetryCount(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned long lockType);
/**
* Phonebook interfaces.
*/
@ -211,7 +92,7 @@ interface nsIIccProvider : nsISupports
in jsval contact,
in DOMString pin2);
/**
/**
* Secure Card Icc communication channel
*/
void iccOpenChannel(in unsigned long clientId,
@ -238,16 +119,4 @@ interface nsIIccProvider : nsISupports
void iccCloseChannel(in unsigned long clientId,
in long channel,
in nsIIccChannelCallback callback);
/**
* Helpers
*/
nsIDOMDOMRequest matchMvno(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned long mvnoType,
in DOMString mvnoData);
nsISupports getServiceState(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned long service);
};

Просмотреть файл

@ -0,0 +1,329 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface nsIIcc;
interface nsIIccInfo;
[scriptable, uuid(7c0ada3d-d8d4-493e-9243-fa3df39855e4)]
interface nsIIccListener : nsISupports
{
void notifyStkCommand(in DOMString aMessage);
void notifyStkSessionEnd();
void notifyCardStateChanged();
void notifyIccInfoChanged();
};
/**
* A callback interface for handling asynchronous response.
*/
[scriptable, uuid(b0e2899a-adc3-11e4-89cf-1b60eaa35b06)]
interface nsIIccCallback : nsISupports
{
/**
* The success callback with no result required:
* |unlockCardLock|, |setCardLockEnabled| and |changeCardLockPassword|.
*/
void notifySuccess();
/**
* The success callback with boolean response:
* |getCardLockEnabled|, |matchMvno|, and |getServiceStateEnabled|.
*/
void notifySuccessWithBoolean(in boolean aResult);
/**
* The success callback of |getCardLockRetryCount|.
*
* @param aCount
* The number of remaining retries. -1 if unknown.
*/
void notifyGetCardLockRetryCount(in long aCount);
/**
* The error callback of |getCardLockEnabled|, |getCardLockRetryCount|,
* |matchMvno|, and |getServiceStateEnabled|.
*
* @param aErrorMsg
* The error message.
*/
void notifyError(in DOMString aErrorMsg);
/**
* The error callback of |unlockCardLock|, |setCardLockEnabled| and
* |changeCardLockPassword|.
*
* @param aErrorMsg
* The error message.
* @param aRetryCount
* The number of remaining retries. -1 if unknown.
*/
void notifyCardLockError(in DOMString aErrorMsg, in long aRetryCount);
};
%{C++
#define ICC_SERVICE_CID \
{ 0xbab0277a, 0x900e, 0x11e4, { 0x80, 0xc7, 0xdb, 0xd7, 0xad, 0x05, 0x24, 0x01 } }
#define ICC_SERVICE_CONTRACTID \
"@mozilla.org/icc/iccservice;1"
template<typename T> struct already_AddRefed;
%}
/**
* XPCOM Service for the selection of the ICC to be accessed.
*/
[scriptable, uuid(6590a04c-9ca4-11e4-ae95-570876ecc428)]
interface nsIIccService : nsISupports
{
/**
* Get Icc instance with specified Service Id.
*
* @param aServiceId
* Started from 0 to nsIMobileConnectionService.numItems - 1;
*
* @return a nsIcc instance.
*/
nsIIcc getIccByServiceId(in unsigned long aServiceId);
};
%{C++
already_AddRefed<nsIIccService>
NS_CreateIccService();
%}
/**
* XPCOM component that provides the access to the selected ICC.
*/
[scriptable, uuid(38a5bbe2-add6-11e4-ba9e-e390d1d19195)]
interface nsIIcc : nsISupports
{
/**
* Card State Constants
*
* Note: MUST be matched with enum IccCardState in MozIcc.webidl!
*/
const unsigned long CARD_STATE_UNKNOWN = 0;
const unsigned long CARD_STATE_READY = 1;
const unsigned long CARD_STATE_PIN_REQUIRED = 2;
const unsigned long CARD_STATE_PUK_REQUIRED = 3;
const unsigned long CARD_STATE_PERMANENT_BLOCKED = 4;
const unsigned long CARD_STATE_PERSONALIZATION_IN_PROGRESS = 5;
const unsigned long CARD_STATE_PERSONALIZATION_READY = 6;
const unsigned long CARD_STATE_NETWORK_LOCKED = 7;
const unsigned long CARD_STATE_NETWORK_SUBSET_LOCKED = 8;
const unsigned long CARD_STATE_CORPORATE_LOCKED = 9;
const unsigned long CARD_STATE_SERVICE_PROVIDER_LOCKED = 10;
const unsigned long CARD_STATE_SIM_LOCKED = 11;
const unsigned long CARD_STATE_NETWORK_PUK_REQUIRED = 12;
const unsigned long CARD_STATE_NETWORK_SUBSET_PUK_REQUIRED = 13;
const unsigned long CARD_STATE_CORPORATE_PUK_REQUIRED = 14;
const unsigned long CARD_STATE_SERVICE_PROVIDER_PUK_REQUIRED = 15;
const unsigned long CARD_STATE_SIM_PUK_REQUIRED = 16;
const unsigned long CARD_STATE_NETWORK1_LOCKED = 17;
const unsigned long CARD_STATE_NETWORK2_LOCKED = 18;
const unsigned long CARD_STATE_HRPD_NETWORK_LOCKED = 19;
const unsigned long CARD_STATE_RUIM_CORPORATE_LOCKED = 20;
const unsigned long CARD_STATE_RUIM_SERVICE_PROVIDER_LOCKED = 21;
const unsigned long CARD_STATE_RUIM_LOCKED = 22;
const unsigned long CARD_STATE_NETWORK1_PUK_REQUIRED = 23;
const unsigned long CARD_STATE_NETWORK2_PUK_REQUIRED = 24;
const unsigned long CARD_STATE_HRPD_NETWORK_PUK_REQUIRED = 25;
const unsigned long CARD_STATE_RUIM_CORPORATE_PUK_REQUIRED = 26;
const unsigned long CARD_STATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED = 27;
const unsigned long CARD_STATE_RUIM_PUK_REQUIRED = 28;
const unsigned long CARD_STATE_ILLEGAL = 29;
const unsigned long CARD_STATE_UNDETECTED = 4294967295; // UINT32_MAX
/**
* Card Lock Constants
*
* Note: MUST be matched with enum IccLockType in MozIcc.webidl!
*/
const unsigned long CARD_LOCK_TYPE_PIN = 0;
const unsigned long CARD_LOCK_TYPE_PIN2 = 1;
const unsigned long CARD_LOCK_TYPE_PUK = 2;
const unsigned long CARD_LOCK_TYPE_PUK2 = 3;
const unsigned long CARD_LOCK_TYPE_NCK = 4;
const unsigned long CARD_LOCK_TYPE_NSCK = 5;
const unsigned long CARD_LOCK_TYPE_NCK1 = 6;
const unsigned long CARD_LOCK_TYPE_NCK2 = 7;
const unsigned long CARD_LOCK_TYPE_HNCK = 8;
const unsigned long CARD_LOCK_TYPE_CCK = 9;
const unsigned long CARD_LOCK_TYPE_SPCK = 10;
const unsigned long CARD_LOCK_TYPE_PCK = 11;
const unsigned long CARD_LOCK_TYPE_RCCK = 12;
const unsigned long CARD_LOCK_TYPE_RSPCK = 13;
const unsigned long CARD_LOCK_TYPE_NCK_PUK = 14;
const unsigned long CARD_LOCK_TYPE_NSCK_PUK = 15;
const unsigned long CARD_LOCK_TYPE_NCK1_PUK = 16;
const unsigned long CARD_LOCK_TYPE_NCK2_PUK = 17;
const unsigned long CARD_LOCK_TYPE_HNCK_PUK = 18;
const unsigned long CARD_LOCK_TYPE_CCK_PUK = 19;
const unsigned long CARD_LOCK_TYPE_SPCK_PUK = 20;
const unsigned long CARD_LOCK_TYPE_PCK_PUK = 21;
const unsigned long CARD_LOCK_TYPE_RCCK_PUK = 22;
const unsigned long CARD_LOCK_TYPE_RSPCK_PUK = 23;
const unsigned long CARD_LOCK_TYPE_FDN = 24;
/**
* Contact Type Constants
*
* Note: MUST be matched with enum IccContactType in MozIcc.webidl!
*/
const unsigned long CARD_CONTACT_TYPE_ADN = 0;
const unsigned long CARD_CONTACT_TYPE_FDN = 1;
const unsigned long CARD_CONTACT_TYPE_SDN = 2;
/**
* MVNO Type Constants
*
* Note: MUST be matched with enum IccMvnoType in MozIcc.webidl!
*/
const unsigned long CARD_MVNO_TYPE_IMSI = 0;
const unsigned long CARD_MVNO_TYPE_SPN = 1;
const unsigned long CARD_MVNO_TYPE_GID = 2;
/**
* Card Service Constants
*
* Note: MUST be matched with enum IccService in MozIcc.webidl!
*/
const unsigned long CARD_SERVICE_FDN = 0;
/**
* Called to register icc-related changes.
*
* 'mobileconnection' permission is required to register.
*/
void registerListener(in nsIIccListener aListener);
void unregisterListener(in nsIIccListener aListener);
/**
* Information stored in this ICC.
*/
readonly attribute nsIIccInfo iccInfo;
/**
* Indicates the state of this ICC.
*
* One of the CARD_STATE_* values.
*/
readonly attribute unsigned long cardState;
/**
* Get the status of an ICC lock (e.g. the PIN lock).
*
* @param aLockType
* One of the CARD_LOCK_TYPE_* values.
* @param aCallback
* An instance of nsIIccCallback:
* nsIIccCallback::notifySuccessWithBoolean() if success.
* nsIIccCallback::notifyError(), otherwise.
*/
void getCardLockEnabled(in unsigned long aLockType,
in nsIIccCallback aCallback);
/**
* Unlock a card lock.
*
* @param aLockType
* One of the CARD_LOCK_TYPE_* values.
* @param aPassword
* The password of this lock.
* @param aNewPin (Optional)
* The new PIN to be set after PUK/PUK2 is unlock.
* @param aCallback
* An instance of nsIIccCallback:
* nsIIccCallback::notifySuccess() if success.
* nsIIccCallback::notifyCardLockError(), otherwise.
*/
void unlockCardLock(in unsigned long aLockType,
in DOMString aPassword,
in DOMString aNewPin,
in nsIIccCallback aCallback);
/**
* Enable/Disable a card lock.
*
* @param aLockType
* One of the CARD_LOCK_TYPE_* values.
* @param aPassword
* The password of this lock.
* @param aEnabled.
* True to enable the lock. False to disable, otherwise.
* @param aCallback
* An instance of nsIIccCallback:
* nsIIccCallback::notifySuccess() if success.
* nsIIccCallback::notifyCardLockError(), otherwise.
*/
void setCardLockEnabled(in unsigned long aLockType,
in DOMString aPassword,
in boolean aEnabled,
in nsIIccCallback aCallback);
/**
* Change the password of a card lock.
*
* @param aLockType
* One of the CARD_LOCK_TYPE_* values.
* @param aPassword
* The password of this lock.
* @param aNewPassword.
* The new password of this lock.
* @param aCallback
* An instance of nsIIccCallback:
* nsIIccCallback::notifySuccess() if success.
* nsIIccCallback::notifyCardLockError(), otherwise.
*/
void changeCardLockPassword(in unsigned long aLockType,
in DOMString aPassword,
in DOMString aNewPassword,
in nsIIccCallback aCallback);
/**
* Get the number of remaining tries of a lock.
*
* @param aLockType
* One of the CARD_LOCK_TYPE_* values.
* @param aCallback
* An instance of nsIIccCallback:
* nsIIccCallback::notifyGetCardLockRetryCount() if success.
* nsIIccCallback::notifyError(), otherwise.
*/
void getCardLockRetryCount(in unsigned long aLockType,
in nsIIccCallback aCallback);
/**
* Verify whether the passed data (matchData) matches with some ICC's field
* according to the mvno type (mvnoType).
*
* @param aMvnoType
* One of CARD_MVNO_TYPE_* values.
* @param aMvnoData
* Data to be compared with ICC's field.
* @param aCallback
* An instance of nsIIccCallback:
* nsIIccCallback::notifySuccessWithBoolean() if success.
* nsIIccCallback::notifyError(), otherwise.
*/
void matchMvno(in unsigned long aMvnoType,
in DOMString aMvnoData,
in nsIIccCallback aCallback);
/**
* Retrieve the the availability of an icc service.
*
* @param aService
* One of CARD_SERVICE_* values.
* @param aCallback
* An instance of nsIIccCallback:
* nsIIccCallback::notifySuccessWithBoolean() if success.
* nsIIccCallback::notifyError(), otherwise.
*/
void getServiceStateEnabled(in unsigned long aService,
in nsIIccCallback aCallback);
};

310
dom/icc/ipc/IccChild.cpp Normal file
Просмотреть файл

@ -0,0 +1,310 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/icc/IccChild.h"
#include "IccInfo.h"
using mozilla::dom::IccInfo;
namespace mozilla {
namespace dom {
namespace icc {
/**
* PIccChild Implementation.
*/
IccChild::IccChild()
: mCardState(nsIIcc::CARD_STATE_UNKNOWN)
, mIsAlive(true)
{
MOZ_COUNT_CTOR(IccChild);
}
IccChild::~IccChild()
{
MOZ_COUNT_DTOR(IccChild);
}
void
IccChild::Init()
{
OptionalIccInfoData infoData;
bool rv = SendInit(&infoData, &mCardState);
NS_ENSURE_TRUE_VOID(rv);
UpdateIccInfo(infoData);
}
void
IccChild::Shutdown(){
if (mIsAlive) {
mIsAlive = false;
Send__delete__(this);
}
mListeners.Clear();
mIccInfo = nullptr;
mCardState = nsIIcc::CARD_STATE_UNKNOWN;
}
void
IccChild::ActorDestroy(ActorDestroyReason why)
{
mIsAlive = false;
}
bool
IccChild::RecvNotifyCardStateChanged(const uint32_t& aCardState)
{
mCardState = aCardState;
for (int32_t i = 0; i < mListeners.Count(); i++) {
mListeners[i]->NotifyCardStateChanged();
}
return true;
}
bool
IccChild::RecvNotifyIccInfoChanged(const OptionalIccInfoData& aInfoData)
{
UpdateIccInfo(aInfoData);
for (int32_t i = 0; i < mListeners.Count(); i++) {
mListeners[i]->NotifyIccInfoChanged();
}
return true;
}
PIccRequestChild*
IccChild::AllocPIccRequestChild(const IccRequest& aRequest)
{
MOZ_CRASH("Caller is supposed to manually construct a request!");
}
bool
IccChild::DeallocPIccRequestChild(PIccRequestChild* aActor)
{
delete aActor;
return true;
}
bool
IccChild::SendRequest(const IccRequest& aRequest, nsIIccCallback* aRequestReply)
{
NS_ENSURE_TRUE(mIsAlive, false);
// Deallocated in IccChild::DeallocPIccRequestChild().
IccRequestChild* actor = new IccRequestChild(aRequestReply);
SendPIccRequestConstructor(actor, aRequest);
return true;
}
void
IccChild::UpdateIccInfo(const OptionalIccInfoData& aInfoData) {
if (aInfoData.type() == OptionalIccInfoData::Tvoid_t) {
mIccInfo = nullptr;
return;
}
NS_ENSURE_TRUE_VOID(aInfoData.type() == OptionalIccInfoData::TIccInfoData);
nsRefPtr<IccInfo> iccInfo;
const IccInfoData& infoData = aInfoData.get_IccInfoData();
if (infoData.iccType().EqualsLiteral("sim")
|| infoData.iccType().EqualsLiteral("usim")) {
iccInfo = new GsmIccInfo(infoData);
} else if (infoData.iccType().EqualsLiteral("ruim")
|| infoData.iccType().EqualsLiteral("csim")){
iccInfo = new CdmaIccInfo(infoData);
} else {
iccInfo = new IccInfo(infoData);
}
// We update the orignal one instead of replacing with a new one
// if the IccType is the same.
if (mIccInfo) {
nsString oldIccType;
nsString newIccType;
mIccInfo->GetIccType(oldIccType);
iccInfo->GetIccType(newIccType);
if (oldIccType.Equals(newIccType)) {
mIccInfo->Update(iccInfo);
return;
}
}
mIccInfo = iccInfo;
}
/**
* nsIIcc Implementation.
*/
NS_IMPL_ISUPPORTS(IccChild, nsIIcc)
NS_IMETHODIMP
IccChild::RegisterListener(nsIIccListener *aListener)
{
NS_ENSURE_TRUE(!mListeners.Contains(aListener), NS_ERROR_UNEXPECTED);
mListeners.AppendObject(aListener);
return NS_OK;
}
NS_IMETHODIMP
IccChild::UnregisterListener(nsIIccListener *aListener)
{
NS_ENSURE_TRUE(mListeners.Contains(aListener), NS_ERROR_UNEXPECTED);
mListeners.RemoveObject(aListener);
return NS_OK;
}
NS_IMETHODIMP
IccChild::GetIccInfo(nsIIccInfo** aIccInfo)
{
nsCOMPtr<nsIIccInfo> info(mIccInfo);
info.forget(aIccInfo);
return NS_OK;
}
NS_IMETHODIMP
IccChild::GetCardState(uint32_t* aCardState)
{
*aCardState = mCardState;
return NS_OK;
}
NS_IMETHODIMP
IccChild::GetCardLockEnabled(uint32_t aLockType,
nsIIccCallback* aRequestReply)
{
return SendRequest(GetCardLockEnabledRequest(aLockType), aRequestReply)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
IccChild::UnlockCardLock(uint32_t aLockType,
const nsAString& aPassword,
const nsAString& aNewPin,
nsIIccCallback* aRequestReply)
{
return SendRequest(UnlockCardLockRequest(aLockType,
nsString(aPassword),
nsString(aNewPin)),
aRequestReply)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
IccChild::SetCardLockEnabled(uint32_t aLockType,
const nsAString& aPassword,
bool aEnabled,
nsIIccCallback* aRequestReply)
{
return SendRequest(SetCardLockEnabledRequest(aLockType,
nsString(aPassword),
aEnabled),
aRequestReply)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
IccChild::ChangeCardLockPassword(uint32_t aLockType,
const nsAString& aPassword,
const nsAString& aNewPassword,
nsIIccCallback* aRequestReply)
{
return SendRequest(ChangeCardLockPasswordRequest(aLockType,
nsString(aPassword),
nsString(aNewPassword)),
aRequestReply)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
IccChild::GetCardLockRetryCount(uint32_t aLockType,
nsIIccCallback* aRequestReply)
{
return SendRequest(GetCardLockRetryCountRequest(aLockType), aRequestReply)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
IccChild::MatchMvno(uint32_t aMvnoType,
const nsAString& aMvnoData,
nsIIccCallback* aRequestReply)
{
return SendRequest(MatchMvnoRequest(aMvnoType, nsString(aMvnoData)),
aRequestReply)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
IccChild::GetServiceStateEnabled(uint32_t aService,
nsIIccCallback* aRequestReply)
{
return SendRequest(GetServiceStateEnabledRequest(aService),
aRequestReply)
? NS_OK : NS_ERROR_FAILURE;
}
/**
* PIccRequestChild Implementation.
*/
IccRequestChild::IccRequestChild(nsIIccCallback* aRequestReply)
: mRequestReply(aRequestReply)
{
MOZ_COUNT_CTOR(IccRequestChild);
MOZ_ASSERT(aRequestReply);
}
bool
IccRequestChild::Recv__delete__(const IccReply& aResponse)
{
MOZ_ASSERT(mRequestReply);
switch(aResponse.type()) {
case IccReply::TIccReplySuccess:
return NS_SUCCEEDED(mRequestReply->NotifySuccess());
case IccReply::TIccReplySuccessWithBoolean: {
const IccReplySuccessWithBoolean& resultWithBoolean
= aResponse.get_IccReplySuccessWithBoolean();
return NS_SUCCEEDED(
mRequestReply->NotifySuccessWithBoolean(resultWithBoolean.result()));
}
case IccReply::TIccReplyCardLockRetryCount: {
const IccReplyCardLockRetryCount& retryCount
= aResponse.get_IccReplyCardLockRetryCount();
return NS_SUCCEEDED(
mRequestReply->NotifyGetCardLockRetryCount(retryCount.count()));
}
case IccReply::TIccReplyError: {
const IccReplyError& error = aResponse.get_IccReplyError();
return NS_SUCCEEDED(mRequestReply->NotifyError(error.message()));
}
case IccReply::TIccReplyCardLockError: {
const IccReplyCardLockError& error
= aResponse.get_IccReplyCardLockError();
return NS_SUCCEEDED(
mRequestReply->NotifyCardLockError(error.message(),
error.retryCount()));
}
default:
MOZ_CRASH("Received invalid response type!");
}
return true;
}
} // namespace icc
} // namespace dom
} // namespace mozilla

86
dom/icc/ipc/IccChild.h Normal file
Просмотреть файл

@ -0,0 +1,86 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_icc_IccChild_h
#define mozilla_dom_icc_IccChild_h
#include "mozilla/dom/icc/PIccChild.h"
#include "mozilla/dom/icc/PIccRequestChild.h"
#include "nsIIccService.h"
namespace mozilla {
namespace dom {
class IccInfo;
namespace icc {
class IccChild final : public PIccChild
, public nsIIcc
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIICC
explicit IccChild();
void
Init();
void
Shutdown();
protected:
virtual void
ActorDestroy(ActorDestroyReason why) override;
virtual PIccRequestChild*
AllocPIccRequestChild(const IccRequest& aRequest) override;
virtual bool
DeallocPIccRequestChild(PIccRequestChild* aActor) override;
virtual bool
RecvNotifyCardStateChanged(const uint32_t& aCardState) override;
virtual bool
RecvNotifyIccInfoChanged(const OptionalIccInfoData& aInfoData) override;
private:
~IccChild();
void
UpdateIccInfo(const OptionalIccInfoData& aInfoData);
bool
SendRequest(const IccRequest& aRequest, nsIIccCallback* aRequestReply);
nsCOMArray<nsIIccListener> mListeners;
nsRefPtr<IccInfo> mIccInfo;
uint32_t mCardState;
bool mIsAlive;
};
class IccRequestChild final : public PIccRequestChild
{
public:
explicit IccRequestChild(nsIIccCallback* aRequestReply);
protected:
virtual bool
Recv__delete__(const IccReply& aReply) override;
private:
virtual ~IccRequestChild() {
MOZ_COUNT_DTOR(IccRequestChild);
}
nsCOMPtr<nsIIccCallback> mRequestReply;
};
} // namespace icc
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_icc_IccChild_h

Просмотреть файл

@ -0,0 +1,56 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "IccIPCService.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/Preferences.h"
namespace mozilla {
namespace dom {
namespace icc {
NS_IMPL_ISUPPORTS(IccIPCService, nsIIccService)
IccIPCService::IccIPCService()
{
int32_t numRil = Preferences::GetInt("ril.numRadioInterfaces", 1);
mIccs.SetLength(numRil);
}
IccIPCService::~IccIPCService()
{
uint32_t count = mIccs.Length();
for (uint32_t i = 0; i < count; i++) {
if (mIccs[i]) {
mIccs[i]->Shutdown();
}
}
}
NS_IMETHODIMP
IccIPCService::GetIccByServiceId(uint32_t aServiceId, nsIIcc** aIcc)
{
NS_ENSURE_TRUE(aServiceId < mIccs.Length(), NS_ERROR_INVALID_ARG);
if (!mIccs[aServiceId]) {
nsRefPtr<IccChild> child = new IccChild();
// |SendPIccConstructor| adds another reference to the child
// actor and removes in |DeallocPIccChild|.
ContentChild::GetSingleton()->SendPIccConstructor(child, aServiceId);
child->Init();
mIccs[aServiceId] = child;
}
nsCOMPtr<nsIIcc> icc(mIccs[aServiceId]);
icc.forget(aIcc);
return NS_OK;
}
} // namespace icc
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -0,0 +1,35 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_icc_IccIPCService_h
#define mozilla_dom_icc_IccIPCService_h
#include "nsCOMPtr.h"
#include "nsIIccService.h"
namespace mozilla {
namespace dom {
namespace icc {
class IccChild;
class IccIPCService final : public nsIIccService
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIICCSERVICE
IccIPCService();
private:
~IccIPCService();
nsTArray<nsRefPtr<IccChild>> mIccs;
};
} // namespace icc
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_icc_IccIPCService_h

320
dom/icc/ipc/IccParent.cpp Normal file
Просмотреть файл

@ -0,0 +1,320 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/icc/IccParent.h"
#include "nsIIccService.h"
#include "IccInfo.h"
using mozilla::dom::IccInfo;
namespace mozilla {
namespace dom {
namespace icc {
namespace {
static void
GetIccInfoDataFromIccInfo(nsIIccInfo* aInInfo, IccInfoData& aOutData) {
aInInfo->GetIccType(aOutData.iccType());
aInInfo->GetIccid(aOutData.iccid());
aInInfo->GetMcc(aOutData.mcc());
aInInfo->GetMnc(aOutData.mnc());
aInInfo->GetSpn(aOutData.spn());
aInInfo->GetIsDisplayNetworkNameRequired(
&aOutData.isDisplayNetworkNameRequired());
aInInfo->GetIsDisplaySpnRequired(
&aOutData.isDisplaySpnRequired());
nsCOMPtr<nsIGsmIccInfo> gsmIccInfo(do_QueryInterface(aInInfo));
if (gsmIccInfo) {
gsmIccInfo->GetMsisdn(aOutData.phoneNumber());
}
nsCOMPtr<nsICdmaIccInfo> cdmaIccInfo(do_QueryInterface(aInInfo));
if (cdmaIccInfo) {
cdmaIccInfo->GetMdn(aOutData.phoneNumber());
cdmaIccInfo->GetPrlVersion(&aOutData.prlVersion());
}
}
} // anonymous namespace
/**
* PIccParent Implementation.
*/
IccParent::IccParent(uint32_t aServiceId)
{
MOZ_COUNT_CTOR(IccParent);
nsCOMPtr<nsIIccService> service =
do_GetService(ICC_SERVICE_CONTRACTID);
NS_ASSERTION(service, "Failed to get IccService!");
service->GetIccByServiceId(aServiceId, getter_AddRefs(mIcc));
NS_ASSERTION(mIcc, "Failed to get Icc with specified serviceId.");
mIcc->RegisterListener(this);
}
void
IccParent::ActorDestroy(ActorDestroyReason aWhy)
{
if (mIcc) {
mIcc->UnregisterListener(this);
mIcc = nullptr;
}
}
bool
IccParent::RecvInit(OptionalIccInfoData* aInfoData,
uint32_t* aCardState)
{
NS_ENSURE_TRUE(mIcc, false);
nsresult rv = mIcc->GetCardState(aCardState);
NS_ENSURE_SUCCESS(rv, false);
nsCOMPtr<nsIIccInfo> iccInfo;
rv = mIcc->GetIccInfo(getter_AddRefs(iccInfo));
NS_ENSURE_SUCCESS(rv, false);
if (iccInfo) {
IccInfoData data;
GetIccInfoDataFromIccInfo(iccInfo, data);
*aInfoData = OptionalIccInfoData(data);
return true;
}
*aInfoData = OptionalIccInfoData(void_t());
return true;
}
PIccRequestParent*
IccParent::AllocPIccRequestParent(const IccRequest& aRequest)
{
NS_ASSERTION(mIcc, "AllocPIccRequestParent after actor was destroyed!");
IccRequestParent* actor = new IccRequestParent(mIcc);
// Add an extra ref for IPDL. Will be released in
// IccParent::DeallocPIccRequestParent().
actor->AddRef();
return actor;
}
bool
IccParent::DeallocPIccRequestParent(PIccRequestParent* aActor)
{
// IccRequestParent is refcounted, must not be freed manually.
static_cast<IccRequestParent*>(aActor)->Release();
return true;
}
bool
IccParent::RecvPIccRequestConstructor(PIccRequestParent* aActor,
const IccRequest& aRequest)
{
NS_ASSERTION(mIcc, "RecvPIccRequestConstructor after actor was destroyed!");
IccRequestParent* actor = static_cast<IccRequestParent*>(aActor);
switch (aRequest.type()) {
case IccRequest::TGetCardLockEnabledRequest:
return actor->DoRequest(aRequest.get_GetCardLockEnabledRequest());
case IccRequest::TUnlockCardLockRequest:
return actor->DoRequest(aRequest.get_UnlockCardLockRequest());
case IccRequest::TSetCardLockEnabledRequest:
return actor->DoRequest(aRequest.get_SetCardLockEnabledRequest());
case IccRequest::TChangeCardLockPasswordRequest:
return actor->DoRequest(aRequest.get_ChangeCardLockPasswordRequest());
case IccRequest::TGetCardLockRetryCountRequest:
return actor->DoRequest(aRequest.get_GetCardLockRetryCountRequest());
case IccRequest::TMatchMvnoRequest:
return actor->DoRequest(aRequest.get_MatchMvnoRequest());
case IccRequest::TGetServiceStateEnabledRequest:
return actor->DoRequest(aRequest.get_GetServiceStateEnabledRequest());
default:
MOZ_CRASH("Received invalid request type!");
}
return true;
}
/**
* nsIIccListener Implementation.
*/
NS_IMPL_ISUPPORTS(IccParent, nsIIccListener)
NS_IMETHODIMP
IccParent::NotifyStkCommand(const nsAString & aMessage)
{
// Bug 1114938 - [B2G][ICC] Refactor STK in MozIcc.webidl with IPDL.
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
IccParent::NotifyStkSessionEnd()
{
// Bug 1114938 - [B2G][ICC] Refactor STK in MozIcc.webidl with IPDL.
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
IccParent::NotifyCardStateChanged()
{
NS_ENSURE_TRUE(mIcc, NS_ERROR_FAILURE);
uint32_t cardState;
nsresult rv = mIcc->GetCardState(&cardState);
NS_ENSURE_SUCCESS(rv, rv);
return SendNotifyCardStateChanged(cardState) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
IccParent::NotifyIccInfoChanged()
{
NS_ENSURE_TRUE(mIcc, NS_ERROR_FAILURE);
nsCOMPtr<nsIIccInfo> iccInfo;
nsresult rv = mIcc->GetIccInfo(getter_AddRefs(iccInfo));
NS_ENSURE_SUCCESS(rv, rv);
if (!iccInfo) {
return SendNotifyIccInfoChanged(OptionalIccInfoData(void_t()))
? NS_OK : NS_ERROR_FAILURE;
}
IccInfoData data;
GetIccInfoDataFromIccInfo(iccInfo, data);
return SendNotifyIccInfoChanged(OptionalIccInfoData(data))
? NS_OK : NS_ERROR_FAILURE;
}
/**
* PIccRequestParent Implementation.
*/
IccRequestParent::IccRequestParent(nsIIcc* aIcc)
: mIcc(aIcc)
{
MOZ_COUNT_CTOR(IccRequestParent);
}
void
IccRequestParent::ActorDestroy(ActorDestroyReason aWhy)
{
mIcc = nullptr;
}
bool
IccRequestParent::DoRequest(const GetCardLockEnabledRequest& aRequest)
{
return NS_SUCCEEDED(mIcc->GetCardLockEnabled(aRequest.lockType(),
this));
}
bool
IccRequestParent::DoRequest(const UnlockCardLockRequest& aRequest)
{
return NS_SUCCEEDED(mIcc->UnlockCardLock(aRequest.lockType(),
aRequest.password(),
aRequest.newPin(),
this));
}
bool
IccRequestParent::DoRequest(const SetCardLockEnabledRequest& aRequest)
{
return NS_SUCCEEDED(mIcc->SetCardLockEnabled(aRequest.lockType(),
aRequest.password(),
aRequest.enabled(),
this));
}
bool
IccRequestParent::DoRequest(const ChangeCardLockPasswordRequest& aRequest)
{
return NS_SUCCEEDED(mIcc->ChangeCardLockPassword(aRequest.lockType(),
aRequest.password(),
aRequest.newPassword(),
this));
}
bool
IccRequestParent::DoRequest(const GetCardLockRetryCountRequest& aRequest)
{
return NS_SUCCEEDED(mIcc->GetCardLockRetryCount(aRequest.lockType(),
this));
}
bool
IccRequestParent::DoRequest(const MatchMvnoRequest& aRequest)
{
return NS_SUCCEEDED(mIcc->MatchMvno(aRequest.mvnoType(),
aRequest.mvnoData(),
this));
}
bool
IccRequestParent::DoRequest(const GetServiceStateEnabledRequest& aRequest)
{
return NS_SUCCEEDED(mIcc->GetServiceStateEnabled(aRequest.service(),
this));
}
nsresult
IccRequestParent::SendReply(const IccReply& aReply)
{
NS_ENSURE_TRUE(mIcc, NS_ERROR_FAILURE);
return Send__delete__(this, aReply) ? NS_OK : NS_ERROR_FAILURE;
}
/**
* nsIIccCallback Implementation.
*/
NS_IMPL_ISUPPORTS(IccRequestParent, nsIIccCallback)
NS_IMETHODIMP
IccRequestParent::NotifySuccess()
{
return SendReply(IccReplySuccess());
}
NS_IMETHODIMP
IccRequestParent::NotifySuccessWithBoolean(bool aResult)
{
return SendReply(IccReplySuccessWithBoolean(aResult));
}
NS_IMETHODIMP
IccRequestParent::NotifyGetCardLockRetryCount(int32_t aCount)
{
return SendReply(IccReplyCardLockRetryCount(aCount));
}
NS_IMETHODIMP
IccRequestParent::NotifyError(const nsAString & aErrorMsg)
{
return SendReply(IccReplyError(nsString(aErrorMsg)));
}
NS_IMETHODIMP
IccRequestParent::NotifyCardLockError(const nsAString & aErrorMsg,
int32_t aRetryCount)
{
return SendReply(IccReplyCardLockError(aRetryCount, nsString(aErrorMsg)));
}
} // namespace icc
} // namespace dom
} // namespace mozilla

107
dom/icc/ipc/IccParent.h Normal file
Просмотреть файл

@ -0,0 +1,107 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_icc_IccParent_h
#define mozilla_dom_icc_IccParent_h
#include "mozilla/dom/icc/PIccParent.h"
#include "mozilla/dom/icc/PIccRequestParent.h"
#include "nsIIccService.h"
namespace mozilla {
namespace dom {
namespace icc {
class IccParent final : public PIccParent
, public nsIIccListener
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIICCLISTENER
explicit IccParent(uint32_t aServiceId);
protected:
virtual
~IccParent()
{
MOZ_COUNT_DTOR(IccParent);
}
virtual void
ActorDestroy(ActorDestroyReason aWhy) override;
virtual bool
RecvInit(
OptionalIccInfoData* aInfoData,
uint32_t* aCardState) override;
virtual PIccRequestParent*
AllocPIccRequestParent(const IccRequest& aRequest) override;
virtual bool
DeallocPIccRequestParent(PIccRequestParent* aActor) override;
virtual bool
RecvPIccRequestConstructor(PIccRequestParent* aActor,
const IccRequest& aRequest) override;
private:
IccParent();
nsCOMPtr<nsIIcc> mIcc;
};
class IccRequestParent final : public PIccRequestParent
, public nsIIccCallback
{
friend class IccParent;
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIICCCALLBACK
explicit IccRequestParent(nsIIcc* icc);
protected:
virtual void
ActorDestroy(ActorDestroyReason why) override;
private:
~IccRequestParent()
{
MOZ_COUNT_DTOR(IccRequestParent);
}
bool
DoRequest(const GetCardLockEnabledRequest& aRequest);
bool
DoRequest(const UnlockCardLockRequest& aRequest);
bool
DoRequest(const SetCardLockEnabledRequest& aRequest);
bool
DoRequest(const ChangeCardLockPasswordRequest& aRequest);
bool
DoRequest(const GetCardLockRetryCountRequest& aRequest);
bool
DoRequest(const MatchMvnoRequest& aRequest);
bool
DoRequest(const GetServiceStateEnabledRequest& aRequest);
nsresult
SendReply(const IccReply& aReply);
nsCOMPtr<nsIIcc> mIcc;
};
} // namespace icc
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_icc_IccParent_h

111
dom/icc/ipc/PIcc.ipdl Normal file
Просмотреть файл

@ -0,0 +1,111 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PContent;
include protocol PIccRequest;
include PIccTypes;
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
namespace mozilla {
namespace dom {
namespace icc {
union OptionalIccInfoData
{
void_t;
IccInfoData;
};
struct GetCardLockEnabledRequest
{
uint32_t lockType;
};
struct UnlockCardLockRequest
{
uint32_t lockType;
nsString password;
nsString newPin;
};
struct SetCardLockEnabledRequest
{
uint32_t lockType;
nsString password;
bool enabled;
};
struct ChangeCardLockPasswordRequest
{
uint32_t lockType;
nsString password;
nsString newPassword;
};
struct GetCardLockRetryCountRequest
{
uint32_t lockType;
};
struct MatchMvnoRequest
{
uint32_t mvnoType;
nsString mvnoData;
};
struct GetServiceStateEnabledRequest
{
uint32_t service;
};
union IccRequest
{
GetCardLockEnabledRequest;
UnlockCardLockRequest;
SetCardLockEnabledRequest;
ChangeCardLockPasswordRequest;
GetCardLockRetryCountRequest;
MatchMvnoRequest;
GetServiceStateEnabledRequest;
};
sync protocol PIcc
{
manager PContent;
manages PIccRequest;
child:
/**
* Notify CardStateChanged with updated CardState.
*/
NotifyCardStateChanged(uint32_t aCardState);
/**
* Notify IccInfoChanged with updated IccInfo.
*/
NotifyIccInfoChanged(OptionalIccInfoData aInfoData);
parent:
/**
* Sent when the child no longer needs to use PIcc.
*/
__delete__();
/**
* Sent when the child makes an asynchronous request to the parent.
*/
PIccRequest(IccRequest aRequest);
/**
* Sync call to initialize the updated IccInfo/CardState.
*/
sync Init()
returns (OptionalIccInfoData aInfoData, uint32_t aCardState);
};
} // namespace icc
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -0,0 +1,61 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PIcc;
include PIccTypes;
namespace mozilla {
namespace dom {
namespace icc {
struct IccReplySuccess
{
};
struct IccReplySuccessWithBoolean
{
bool result;
};
struct IccReplyCardLockRetryCount
{
int32_t count;
};
struct IccReplyError
{
nsString message;
};
struct IccReplyCardLockError
{
int32_t retryCount;
nsString message;
};
union IccReply
{
// Success
IccReplySuccess;
IccReplySuccessWithBoolean;
IccReplyCardLockRetryCount;
// Error
IccReplyError;
IccReplyCardLockError;
};
protocol PIccRequest
{
manager PIcc;
child:
/**
* Sent when the asynchronous request has completed.
*/
__delete__(IccReply response);
};
} // namespace icc
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -0,0 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
namespace mozilla {
namespace dom {
namespace icc {
struct IccInfoData
{
nsString iccType;
nsString iccid;
nsString mcc;
nsString mnc;
nsString spn;
bool isDisplayNetworkNameRequired;
bool isDisplaySpnRequired;
nsString phoneNumber;
int32_t prlVersion;
};
} // namespace icc
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -13,19 +13,38 @@ EXPORTS.mozilla.dom += [
'IccManager.h',
]
EXPORTS.mozilla.dom.icc += [
'ipc/IccChild.h',
'ipc/IccParent.h',
]
UNIFIED_SOURCES += [
'Assertions.cpp',
'Icc.cpp',
'IccCallback.cpp',
'IccCardLockError.cpp',
"IccInfo.cpp",
'IccListener.cpp',
'IccManager.cpp',
'ipc/IccChild.cpp',
'ipc/IccIPCService.cpp',
'ipc/IccParent.cpp',
]
IPDL_SOURCES += [
'ipc/PIcc.ipdl',
'ipc/PIccRequest.ipdl',
'ipc/PIccTypes.ipdlh',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
EXTRA_JS_MODULES += [
'gonk/StkProactiveCmdFactory.jsm',
]
EXTRA_COMPONENTS += [
'gonk/IccService.js',
'gonk/IccService.manifest',
]
FAIL_ON_WARNINGS = True

Просмотреть файл

@ -150,6 +150,7 @@
#include "mozilla/dom/File.h"
#include "mozilla/dom/cellbroadcast/CellBroadcastIPCService.h"
#include "mozilla/dom/icc/IccChild.h"
#include "mozilla/dom/mobileconnection/MobileConnectionChild.h"
#include "mozilla/dom/mobilemessage/SmsChild.h"
#include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
@ -183,6 +184,7 @@ using namespace mozilla::docshell;
using namespace mozilla::dom::bluetooth;
using namespace mozilla::dom::cellbroadcast;
using namespace mozilla::dom::devicestorage;
using namespace mozilla::dom::icc;
using namespace mozilla::dom::ipc;
using namespace mozilla::dom::mobileconnection;
using namespace mozilla::dom::mobilemessage;
@ -1467,6 +1469,31 @@ ContentChild::DeallocPHalChild(PHalChild* aHal)
return true;
}
PIccChild*
ContentChild::SendPIccConstructor(PIccChild* aActor,
const uint32_t& aServiceId)
{
// Add an extra ref for IPDL. Will be released in
// ContentChild::DeallocPIccChild().
static_cast<IccChild*>(aActor)->AddRef();
return PContentChild::SendPIccConstructor(aActor, aServiceId);
}
PIccChild*
ContentChild::AllocPIccChild(const uint32_t& aServiceId)
{
NS_NOTREACHED("No one should be allocating PIccChild actors");
return nullptr;
}
bool
ContentChild::DeallocPIccChild(PIccChild* aActor)
{
// IccChild is refcounted, must not be freed manually.
static_cast<IccChild*>(aActor)->Release();
return true;
}
asmjscache::PAsmJSCacheEntryChild*
ContentChild::AllocPAsmJSCacheEntryChild(
const asmjscache::OpenMode& aOpenMode,

Просмотреть файл

@ -173,6 +173,13 @@ public:
virtual PHalChild* AllocPHalChild() override;
virtual bool DeallocPHalChild(PHalChild*) override;
PIccChild*
SendPIccConstructor(PIccChild* aActor, const uint32_t& aServiceId);
virtual PIccChild*
AllocPIccChild(const uint32_t& aClientId) override;
virtual bool
DeallocPIccChild(PIccChild* aActor) override;
virtual PMemoryReportRequestChild*
AllocPMemoryReportRequestChild(const uint32_t& aGeneration,
const bool& aAnonymize,

Просмотреть файл

@ -51,6 +51,7 @@
#include "mozilla/dom/bluetooth/PBluetoothParent.h"
#include "mozilla/dom/cellbroadcast/CellBroadcastParent.h"
#include "mozilla/dom/devicestorage/DeviceStorageRequestParent.h"
#include "mozilla/dom/icc/IccParent.h"
#include "mozilla/dom/mobileconnection/MobileConnectionParent.h"
#include "mozilla/dom/mobilemessage/SmsParent.h"
#include "mozilla/dom/power/PowerManagerService.h"
@ -224,6 +225,7 @@ using namespace CrashReporter;
using namespace mozilla::dom::bluetooth;
using namespace mozilla::dom::cellbroadcast;
using namespace mozilla::dom::devicestorage;
using namespace mozilla::dom::icc;
using namespace mozilla::dom::indexedDB;
using namespace mozilla::dom::power;
using namespace mozilla::dom::mobileconnection;
@ -3387,6 +3389,27 @@ ContentParent::DeallocPHalParent(hal_sandbox::PHalParent* aHal)
return true;
}
PIccParent*
ContentParent::AllocPIccParent(const uint32_t& aServiceId)
{
if (!AssertAppProcessPermission(this, "mobileconnection")) {
return nullptr;
}
IccParent* parent = new IccParent(aServiceId);
// We release this ref in DeallocPIccParent().
parent->AddRef();
return parent;
}
bool
ContentParent::DeallocPIccParent(PIccParent* aActor)
{
// IccParent is refcounted, must not be freed manually.
static_cast<IccParent*>(aActor)->Release();
return true;
}
PMemoryReportRequestParent*
ContentParent::AllocPMemoryReportRequestParent(const uint32_t& aGeneration,
const bool &aAnonymize,

Просмотреть файл

@ -550,6 +550,9 @@ private:
virtual bool DeallocPHalParent(PHalParent*) override;
virtual PIccParent* AllocPIccParent(const uint32_t& aServiceId) override;
virtual bool DeallocPIccParent(PIccParent* aActor) override;
virtual PMemoryReportRequestParent*
AllocPMemoryReportRequestParent(const uint32_t& aGeneration,
const bool &aAnonymize,
@ -743,7 +746,7 @@ private:
OptionalURIParams* aURI) override;
virtual bool RecvNotifyKeywordSearchLoading(const nsString &aProvider,
const nsString &aKeyword) override;
const nsString &aKeyword) override;
virtual void ProcessingError(Result aCode, const char* aMsgName) override;

Просмотреть файл

@ -21,6 +21,7 @@ include protocol PFileDescriptorSet;
include protocol PFMRadio;
include protocol PFileSystemRequest;
include protocol PHal;
include protocol PIcc;
include protocol PProcessHangMonitor;
include protocol PImageBridge;
include protocol PMemoryReportRequest;
@ -379,6 +380,7 @@ prio(normal upto urgent) sync protocol PContent
manages PFileDescriptorSet;
manages PFMRadio;
manages PHal;
manages PIcc;
manages PMemoryReportRequest;
manages PMobileConnection;
manages PNecko;
@ -655,6 +657,8 @@ parent:
PHal();
PIcc(uint32_t serviceId);
PMobileConnection(uint32_t clientId);
PNecko();

Просмотреть файл

@ -15,6 +15,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "nsIDOMDOMRequest.h"
#include "nsIIccInfo.h"
#include "nsIPermissionManager.h"
#include "nsIVariant.h"
#include "nsJSON.h"
@ -22,10 +23,6 @@
#include "nsRadioInterfaceLayer.h"
#include "nsServiceManagerUtils.h"
#ifdef MOZ_B2G_RIL
#include "nsIIccInfo.h"
#endif // MOZ_B2G_RIL
#define MOBILECONN_ERROR_INVALID_PARAMETER NS_LITERAL_STRING("InvalidParameter")
#define MOBILECONN_ERROR_INVALID_PASSWORD NS_LITERAL_STRING("InvalidPassword")
@ -49,18 +46,14 @@ using namespace mozilla::dom;
using namespace mozilla::dom::mobileconnection;
class MobileConnection::Listener final : public nsIMobileConnectionListener
#ifdef MOZ_B2G_RIL
, public nsIIccListener
#endif // MOZ_B2G_RIL
{
MobileConnection* mMobileConnection;
public:
NS_DECL_ISUPPORTS
NS_FORWARD_SAFE_NSIMOBILECONNECTIONLISTENER(mMobileConnection)
#ifdef MOZ_B2G_RIL
NS_FORWARD_SAFE_NSIICCLISTENER(mMobileConnection)
#endif // MOZ_B2G_RIL
explicit Listener(MobileConnection* aMobileConnection)
: mMobileConnection(aMobileConnection)
@ -81,12 +74,8 @@ private:
}
};
#ifdef MOZ_B2G_RIL
NS_IMPL_ISUPPORTS(MobileConnection::Listener, nsIMobileConnectionListener,
nsIIccListener)
#else
NS_IMPL_ISUPPORTS(MobileConnection::Listener, nsIMobileConnectionListener)
#endif // MOZ_B2G_RIL
NS_IMPL_CYCLE_COLLECTION_CLASS(MobileConnection)
@ -98,6 +87,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MobileConnection,
// down.
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVoice)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mData)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIccHandler)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MobileConnection,
@ -105,6 +95,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MobileConnection,
tmp->Shutdown();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mVoice)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mData)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mIccHandler)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MobileConnection)
@ -136,15 +127,9 @@ MobileConnection::MobileConnection(nsPIDOMWindow* aWindow, uint32_t aClientId)
nsresult rv = service->GetItemByServiceId(mClientId,
getter_AddRefs(mMobileConnection));
#ifdef MOZ_B2G_RIL
mIcc = do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
if (NS_FAILED(rv) || !mMobileConnection || !mIcc) {
NS_WARNING("Could not acquire nsIMobileConnection or nsIIccProvider!");
#else
if (NS_FAILED(rv) || !mMobileConnection) {
NS_WARNING("Could not acquire nsIMobileConnection!");
#endif // MOZ_B2G_RIL
return;
}
@ -159,12 +144,21 @@ MobileConnection::MobileConnection(nsPIDOMWindow* aWindow, uint32_t aClientId)
UpdateVoice();
UpdateData();
#ifdef MOZ_B2G_RIL
rv = mIcc->RegisterIccMsg(mClientId, mListener);
nsCOMPtr<nsIIccService> iccService = do_GetService(ICC_SERVICE_CONTRACTID);
if (iccService) {
iccService->GetIccByServiceId(mClientId, getter_AddRefs(mIccHandler));
}
if (!mIccHandler) {
NS_WARNING("Could not acquire nsIMobileConnection or nsIIcc!");
return;
}
rv = mIccHandler->RegisterListener(mListener);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"Failed registering icc messages with service");
UpdateIccId();
#endif // MOZ_B2G_RIL
}
}
@ -176,11 +170,9 @@ MobileConnection::Shutdown()
mMobileConnection->UnregisterListener(mListener);
}
#ifdef MOZ_B2G_RIL
if (mIcc) {
mIcc->UnregisterIccMsg(mClientId, mListener);
if (mIccHandler) {
mIccHandler->UnregisterListener(mListener);
}
#endif // MOZ_B2G_RIL
mListener->Disconnect();
mListener = nullptr;
@ -246,11 +238,10 @@ MobileConnection::UpdateData()
bool
MobileConnection::UpdateIccId()
{
#ifdef MOZ_B2G_RIL
nsAutoString iccId;
nsCOMPtr<nsIIccInfo> iccInfo;
if (mIcc &&
NS_SUCCEEDED(mIcc->GetIccInfo(mClientId, getter_AddRefs(iccInfo))) &&
if (mIccHandler &&
NS_SUCCEEDED(mIccHandler->GetIccInfo(getter_AddRefs(iccInfo))) &&
iccInfo) {
iccInfo->GetIccid(iccId);
} else {
@ -261,7 +252,6 @@ MobileConnection::UpdateIccId()
mIccId = iccId;
return true;
}
#endif // MOZ_B2G_RIL
return false;
}
@ -1134,7 +1124,6 @@ MobileConnection::NotifyNetworkSelectionModeChanged()
return NS_OK;
}
#ifdef MOZ_B2G_RIL
// nsIIccListener
NS_IMETHODIMP
@ -1171,4 +1160,3 @@ MobileConnection::NotifyIccInfoChanged()
return asyncDispatcher->PostDOMEvent();
}
#endif // MOZ_B2G_RIL

Просмотреть файл

@ -11,21 +11,16 @@
#include "mozilla/dom/MobileNetworkInfo.h"
#include "mozilla/dom/MozMobileConnectionBinding.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIIccService.h"
#include "nsIMobileConnectionService.h"
#include "nsWeakPtr.h"
#ifdef MOZ_B2G_RIL
#include "nsIIccProvider.h"
#endif // MOZ_B2G_RIL
namespace mozilla {
namespace dom {
class MobileConnection final : public DOMEventTargetHelper
, private nsIMobileConnectionListener
#ifdef MOZ_B2G_RIL
, private nsIIccListener
#endif // MOZ_B2G_RIL
{
/**
* Class MobileConnection doesn't actually expose
@ -40,9 +35,7 @@ class MobileConnection final : public DOMEventTargetHelper
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIMOBILECONNECTIONLISTENER
#ifdef MOZ_B2G_RIL
NS_DECL_NSIICCLISTENER
#endif // MOZ_B2G_RIL
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MobileConnection,
DOMEventTargetHelper)
@ -169,9 +162,7 @@ private:
uint32_t mClientId;
nsString mIccId;
nsCOMPtr<nsIMobileConnection> mMobileConnection;
#ifdef MOZ_B2G_RIL
nsCOMPtr<nsIIccProvider> mIcc;
#endif // MOZ_B2G_RIL
nsCOMPtr<nsIIcc> mIccHandler;
nsRefPtr<Listener> mListener;
nsRefPtr<MobileConnectionInfo> mVoice;
nsRefPtr<MobileConnectionInfo> mData;

Просмотреть файл

@ -406,7 +406,7 @@ MmsConnection.prototype = {
if (DEBUG) debug("Error! Radio is disabled when sending MMS.");
errorStatus = _HTTP_STATUS_RADIO_DISABLED;
} else if (this.radioInterface.rilContext.cardState !=
Ci.nsIIccProvider.CARD_STATE_READY) {
Ci.nsIIcc.CARD_STATE_READY) {
if (DEBUG) debug("Error! SIM card is not ready when sending MMS.");
errorStatus = _HTTP_STATUS_NO_SIM_CARD;
}

Просмотреть файл

@ -886,7 +886,7 @@ SmsService.prototype = {
if (DEBUG) debug("Error! Radio is disabled when sending SMS.");
errorCode = Ci.nsIMobileMessageCallback.RADIO_DISABLED_ERROR;
} else if (gRadioInterfaces[aServiceId].rilContext.cardState !=
Ci.nsIIccProvider.CARD_STATE_READY) {
Ci.nsIIcc.CARD_STATE_READY) {
if (DEBUG) debug("Error! SIM card is not ready when sending SMS.");
errorCode = Ci.nsIMobileMessageCallback.NO_SIM_CARD_ERROR;
}

Просмотреть файл

@ -64,6 +64,7 @@ DIRS += [
'fmradio',
'geolocation',
'html',
'icc',
'json',
'jsurl',
'asmjscache',
@ -122,7 +123,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
if CONFIG['MOZ_B2G_RIL']:
DIRS += [
'icc',
'wappush',
]

Просмотреть файл

@ -23,9 +23,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "MCC_ISO3166_TABLE",
XPCOMUtils.defineLazyServiceGetter(this, "mobileConnection",
"@mozilla.org/mobileconnection/mobileconnectionservice;1",
"nsIMobileConnectionService");
XPCOMUtils.defineLazyServiceGetter(this, "icc",
"@mozilla.org/ril/content-helper;1",
"nsIIccProvider");
XPCOMUtils.defineLazyServiceGetter(this, "gIccService",
"@mozilla.org/icc/iccservice;1",
"nsIIccService");
#endif
this.PhoneNumberUtils = {
@ -46,8 +46,8 @@ this.PhoneNumberUtils = {
#ifdef MOZ_B2G_RIL
// TODO: Bug 926740 - PhoneNumberUtils for multisim
// In Multi-sim, there is more than one client in
// iccProvider/mobileConnectionProvider. Each client represents a
// In Multi-sim, there is more than one client in
// iccService/mobileConnectionService. Each client represents a
// icc/mobileConnection service. To maintain the backward compatibility with
// single sim, we always use client 0 for now. Adding support for multiple
// sim will be addressed in bug 926740, if needed.
@ -61,7 +61,8 @@ this.PhoneNumberUtils = {
}
// Get SIM mcc
let iccInfo = icc.getIccInfo(clientId);
let icc = gIccService.getIccByServiceId(clientId);
let iccInfo = icc && icc.iccInfo;
if (!mcc && iccInfo && iccInfo.mcc) {
mcc = iccInfo.mcc;
}

Просмотреть файл

@ -1815,7 +1815,7 @@ _popupcontextmenu(NPP instance, NPMenu* menu)
if (success) {
return mozilla::plugins::PluginUtilsOSX::ShowCocoaContextMenu(menu,
screenX, screenY,
PluginModuleChild::GetChrome(),
InstCast(instance)->Manager(),
ProcessBrowserEvents);
} else {
NS_WARNING("Convertpoint failed, could not created contextmenu.");

Просмотреть файл

@ -1775,14 +1775,15 @@ this.PushService = {
let nm = Cc["@mozilla.org/network/manager;1"].getService(Ci.nsINetworkManager);
if (nm.active && nm.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
let icc = Cc["@mozilla.org/ril/content-helper;1"].getService(Ci.nsIIccProvider);
let iccService = Cc["@mozilla.org/icc/iccservice;1"].getService(Ci.nsIIccService);
// TODO: Bug 927721 - PushService for multi-sim
// In Multi-sim, there is more than one client in iccProvider. Each
// client represents a icc service. To maintain backward compatibility
// In Multi-sim, there is more than one client in iccService. Each
// client represents a icc handle. To maintain backward compatibility
// with single sim, we always use client 0 for now. Adding support
// for multiple sim will be addressed in bug 927721, if needed.
let clientId = 0;
let iccInfo = icc.getIccInfo(clientId);
let icc = iccService.getIccByServiceId(clientId);
let iccInfo = icc && icc.iccInfo;
if (iccInfo) {
debug("Running on mobile data");

Просмотреть файл

@ -98,8 +98,8 @@ IccInfo.prototype = {
mcc: null,
mnc: null,
spn: null,
isDisplayNetworkNameRequired: null,
isDisplaySpnRequired: null
isDisplayNetworkNameRequired: false,
isDisplaySpnRequired: false
};
function GsmIccInfo() {}
@ -131,16 +131,19 @@ function RILContentHelper() {
this.numClients = gNumRadioInterfaces;
if (DEBUG) debug("Number of clients: " + this.numClients);
this._iccs = [];
this.rilContexts = [];
for (let clientId = 0; clientId < this.numClients; clientId++) {
this._iccs.push(new Icc(this, clientId));
this.rilContexts[clientId] = {
cardState: Ci.nsIIccProvider.CARD_STATE_UNKNOWN,
cardState: Ci.nsIIcc.CARD_STATE_UNKNOWN,
iccInfo: null
};
}
this.initDOMRequestHelper(/* aWindow */ null, RIL_IPC_MSG_NAMES);
this._windowsMap = [];
this._requestMap = [];
this._iccListeners = [];
this._iccChannelCallback = [];
@ -153,12 +156,14 @@ RILContentHelper.prototype = {
__proto__: DOMRequestIpcHelper.prototype,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIIccProvider,
Ci.nsIIccService,
Ci.nsIObserver,
Ci.nsISupportsWeakReference]),
classID: RILCONTENTHELPER_CID,
classInfo: XPCOMUtils.generateCI({classID: RILCONTENTHELPER_CID,
classDescription: "RILContentHelper",
interfaces: [Ci.nsIIccProvider]}),
interfaces: [Ci.nsIIccProvider,
Ci.nsIIccService]}),
updateDebugFlag: function() {
try {
@ -206,6 +211,8 @@ RILContentHelper.prototype = {
_windowsMap: null,
_requestMap: null,
rilContexts: null,
getRilContext: function(clientId) {
@ -234,142 +241,6 @@ RILContentHelper.prototype = {
* nsIIccProvider
*/
getIccInfo: function(clientId) {
let context = this.getRilContext(clientId);
return context && context.iccInfo;
},
getCardState: function(clientId) {
let context = this.getRilContext(clientId);
return context && context.cardState;
},
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;
},
getCardLockEnabled: function(clientId, 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);
this._windowsMap[requestId] = window;
cpmm.sendAsyncMessage("RIL:GetCardLockEnabled", {
clientId: clientId,
data: {
lockType: lockType,
requestId: requestId
}
});
return request;
},
unlockCardLock: function(clientId, window, lockType, password, newPin) {
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:UnlockCardLock", {
clientId: clientId,
data: {
lockType: lockType,
password: password,
newPin: newPin,
requestId: requestId
}
});
return request;
},
setCardLockEnabled: function(clientId, window, lockType, password, enabled) {
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:SetCardLockEnabled", {
clientId: clientId,
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
}
});
return request;
},
getCardLockRetryCount: function(clientId, 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);
this._windowsMap[requestId] = window;
cpmm.sendAsyncMessage("RIL:GetCardLockRetryCount", {
clientId: clientId,
data: {
lockType: lockType,
requestId: requestId
}
});
return request;
},
sendStkResponse: function(clientId, window, command, response) {
if (window == null) {
throw Components.Exception("Can't get window object",
@ -545,27 +416,6 @@ RILContentHelper.prototype = {
return request;
},
getServiceState: function(clientId, window, service) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
}
return new window.Promise((resolve, reject) => {
let requestId =
this.getPromiseResolverId({resolve: resolve, reject: reject});
this._windowsMap[requestId] = window;
cpmm.sendAsyncMessage("RIL:GetServiceState", {
clientId: clientId,
data: {
requestId: requestId,
service: service
}
});
});
},
_iccListeners: null,
registerListener: function(listenerType, clientId, listener) {
@ -721,62 +571,56 @@ RILContentHelper.prototype = {
case "RIL:CardStateChanged":
if (this.rilContexts[clientId].cardState != data.cardState) {
this.rilContexts[clientId].cardState = data.cardState;
this._deliverEvent(clientId,
"_iccListeners",
"notifyCardStateChanged",
null);
this._deliverIccEvent(clientId,
"notifyCardStateChanged",
null);
}
break;
case "RIL:IccInfoChanged":
this.updateIccInfo(clientId, data);
this._deliverEvent(clientId,
"_iccListeners",
"notifyIccInfoChanged",
null);
this._deliverIccEvent(clientId,
"notifyIccInfoChanged",
null);
break;
case "RIL:GetCardLockResult": {
let requestId = data.requestId;
let requestWindow = this._windowsMap[requestId];
delete this._windowsMap[requestId];
let callback = this._requestMap[requestId];
delete this._requestMap[requestId];
if (data.errorMsg) {
this.fireRequestError(requestId, data.errorMsg);
callback.notifyError(data.errorMsg);
break;
}
this.fireRequestSuccess(requestId,
Cu.cloneInto({ enabled: data.enabled },
requestWindow));
callback.notifySuccessWithBoolean(data.enabled);
break;
}
case "RIL:SetUnlockCardLockResult": {
let requestId = data.requestId;
let requestWindow = this._windowsMap[requestId];
delete this._windowsMap[requestId];
let callback = this._requestMap[requestId];
delete this._requestMap[requestId];
if (data.errorMsg) {
let cardLockError = new requestWindow.IccCardLockError(data.errorMsg,
data.retryCount);
this.fireRequestDetailedError(requestId, cardLockError);
let retryCount =
(data.retryCount !== undefined) ? data.retryCount : -1;
callback.notifyCardLockError(data.errorMsg, retryCount);
break;
}
this.fireRequestSuccess(requestId, null);
callback.notifySuccess();
break;
}
case "RIL:CardLockRetryCount": {
let requestId = data.requestId;
let requestWindow = this._windowsMap[requestId];
delete this._windowsMap[requestId];
let callback = this._requestMap[requestId];
delete this._requestMap[requestId];
if (data.errorMsg) {
this.fireRequestError(data.requestId, data.errorMsg);
callback.notifyError(data.errorMsg);
break;
}
this.fireRequestSuccess(data.requestId,
Cu.cloneInto({ retryCount: data.retryCount },
requestWindow));
callback.notifyGetCardLockRetryCount(data.retryCount);
break;
}
case "RIL:StkCommand":
@ -801,12 +645,30 @@ RILContentHelper.prototype = {
case "RIL:UpdateIccContact":
this.handleUpdateIccContact(data);
break;
case "RIL:MatchMvno":
this.handleSimpleRequest(data.requestId, data.errorMsg, data.result);
case "RIL:MatchMvno": {
let requestId = data.requestId;
let callback = this._requestMap[requestId];
delete this._requestMap[requestId];
if (data.errorMsg) {
callback.notifyError(data.errorMsg);
break;
}
callback.notifySuccessWithBoolean(data.result);
break;
case "RIL:GetServiceState":
this.handleGetServiceState(data);
}
case "RIL:GetServiceState": {
let requestId = data.requestId;
let callback = this._requestMap[requestId];
delete this._requestMap[requestId];
if (data.errorMsg) {
callback.notifyError(data.errorMsg);
break;
}
callback.notifySuccessWithBoolean(data.result);
break;
}
}
},
@ -909,20 +771,6 @@ RILContentHelper.prototype = {
this.fireRequestSuccess(message.requestId, contact);
},
handleGetServiceState: function(message) {
let requestId = message.requestId;
let requestWindow = this._windowsMap[requestId];
delete this._windowsMap[requestId];
let resolver = this.takePromiseResolver(requestId);
if (message.errorMsg) {
resolver.reject(new requestWindow.DOMError(message.errorMsg));
return;
}
resolver.resolve(message.result);
},
_deliverEvent: function(clientId, listenerType, name, args) {
if (!this[listenerType]) {
return;
@ -947,6 +795,235 @@ RILContentHelper.prototype = {
if (DEBUG) debug("listener for " + name + " threw an exception: " + e);
}
}
},
/**
* nsIIccService interface.
*/
_iccs: null, // An array of Icc instances.
getIccByServiceId: function(serviceId) {
let icc = this._iccs[serviceId];
if (!icc) {
throw Cr.NS_ERROR_UNEXPECTED;
}
return icc;
},
/**
* Bridge APIs from nsIIccService to nsIIccProvider
*/
_deliverIccEvent: function(clientId, name, args) {
let icc = this._iccs[clientId];
if (!icc) {
if (DEBUG) debug("_deliverIccEvent: Invalid clientId: " + clientId);
return;
}
icc.deliverListenerEvent(name, args);
},
getIccInfo: function(clientId) {
let context = this.getRilContext(clientId);
return context && context.iccInfo;
},
getCardState: function(clientId) {
let context = this.getRilContext(clientId);
return context && context.cardState;
},
matchMvno: function(clientId, mvnoType, mvnoData, callback) {
let requestId = UUIDGenerator.generateUUID().toString();
this._requestMap[requestId] = callback;
cpmm.sendAsyncMessage("RIL:MatchMvno", {
clientId: clientId,
data: {
requestId: requestId,
mvnoType: mvnoType,
mvnoData: mvnoData
}
});
},
getCardLockEnabled: function(clientId, lockType, callback) {
let requestId = UUIDGenerator.generateUUID().toString();
this._requestMap[requestId] = callback;
cpmm.sendAsyncMessage("RIL:GetCardLockEnabled", {
clientId: clientId,
data: {
lockType: lockType,
requestId: requestId
}
});
},
unlockCardLock: function(clientId, lockType, password, newPin, callback) {
let requestId = UUIDGenerator.generateUUID().toString();
this._requestMap[requestId] = callback;
cpmm.sendAsyncMessage("RIL:UnlockCardLock", {
clientId: clientId,
data: {
lockType: lockType,
password: password,
newPin: newPin,
requestId: requestId
}
});
},
setCardLockEnabled: function(clientId, lockType, password, enabled, callback) {
let requestId = UUIDGenerator.generateUUID().toString();
this._requestMap[requestId] = callback;
cpmm.sendAsyncMessage("RIL:SetCardLockEnabled", {
clientId: clientId,
data: {
lockType: lockType,
password: password,
enabled: enabled,
requestId: requestId
}
});
},
changeCardLockPassword: function(clientId, lockType, password, newPassword,
callback) {
let requestId = UUIDGenerator.generateUUID().toString();
this._requestMap[requestId] = callback;
cpmm.sendAsyncMessage("RIL:ChangeCardLockPassword", {
clientId: clientId,
data: {
lockType: lockType,
password: password,
newPassword: newPassword,
requestId: requestId
}
});
},
getCardLockRetryCount: function(clientId, lockType, callback) {
let requestId = UUIDGenerator.generateUUID().toString();
this._requestMap[requestId] = callback;
cpmm.sendAsyncMessage("RIL:GetCardLockRetryCount", {
clientId: clientId,
data: {
lockType: lockType,
requestId: requestId
}
});
},
getServiceStateEnabled: function(clientId, service, callback) {
let requestId = UUIDGenerator.generateUUID().toString();
this._requestMap[requestId] = callback;
cpmm.sendAsyncMessage("RIL:GetServiceState", {
clientId: clientId,
data: {
requestId: requestId,
service: service
}
});
}
};
function Icc(aIccProvider, aClientId) {
this._iccProvider = aIccProvider;
this._clientId = aClientId;
this._listeners = [];
}
Icc.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIIcc]),
_iccProvider: null,
_clientId: -1,
_listeners: null,
deliverListenerEvent: function(aName, aArgs) {
let listeners = this._listeners.slice();
for (let listener of listeners) {
if (this._listeners.indexOf(listener) === -1) {
continue;
}
let handler = listener[aName];
if (typeof handler != "function") {
throw new Error("No handler for " + aName);
}
try {
handler.apply(listener, aArgs);
} catch (e) {
if (DEBUG) {
debug("listener for " + aName + " threw an exception: " + e);
}
}
}
},
/**
* nsIIcc interface.
*/
registerListener: function(aListener) {
if (this._listeners.indexOf(aListener) >= 0) {
throw Cr.NS_ERROR_UNEXPECTED;
}
this._listeners.push(aListener);
cpmm.sendAsyncMessage("RIL:RegisterIccMsg");
},
unregisterListener: function(aListener) {
let index = this._listeners.indexOf(aListener);
if (index >= 0) {
this._listeners.splice(index, 1);
}
},
get iccInfo() {
return this._iccProvider.getIccInfo(this._clientId);
},
get cardState() {
return this._iccProvider.getCardState(this._clientId);
},
getCardLockEnabled: function(aLockType, aCallback) {
this._iccProvider.getCardLockEnabled(this._clientId, aLockType, aCallback);
},
unlockCardLock: function(aLockType, aPassword, aNewPin, aCallback) {
this._iccProvider.unlockCardLock(this._clientId, aLockType,
aPassword, aNewPin, aCallback);
},
setCardLockEnabled: function(aLockType, aPassword, aEnabled, aCallback) {
this._iccProvider.setCardLockEnabled(this._clientId, aLockType,
aPassword, aEnabled, aCallback);
},
changeCardLockPassword: function(aLockType, aPassword, aNewPassword, aCallback) {
this._iccProvider.changeCardLockPassword(this._clientId, aLockType,
aPassword, aNewPassword, aCallback);
},
getCardLockRetryCount: function(aLockType, aCallback) {
this._iccProvider.getCardLockRetryCount(this._clientId, aLockType, aCallback);
},
matchMvno: function(aMvnoType, aMvnoData, aCallback) {
this._iccProvider.matchMvno(this._clientId, aMvnoType, aMvnoData, aCallback);
},
getServiceStateEnabled: function(aService, aCallback) {
this._iccProvider.getServiceStateEnabled(this._clientId, aService, aCallback);
}
};

Просмотреть файл

@ -13,6 +13,8 @@
# limitations under the License.
# RILContentHelper.js
# TODO: Bug 815526, deprecate RILContentHelper:
# To be removed from b2g/installer/package-manifest.in as well.
component {472816e1-1fd6-4405-996c-806f9ea68174} RILContentHelper.js
contract @mozilla.org/ril/content-helper;1 {472816e1-1fd6-4405-996c-806f9ea68174}
category profile-after-change RILContentHelper @mozilla.org/ril/content-helper;1

Просмотреть файл

@ -87,6 +87,7 @@ const NETWORK_TYPE_MOBILE_SUPL = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL
const NETWORK_TYPE_MOBILE_IMS = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_IMS;
const NETWORK_TYPE_MOBILE_DUN = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN;
// TODO: Bug 815526, deprecate RILContentHelper.
const RIL_IPC_ICCMANAGER_MSG_NAMES = [
"RIL:GetRilContext",
"RIL:SendStkResponse",
@ -127,6 +128,10 @@ function debug(s) {
dump("-*- RadioInterfaceLayer: " + s + "\n");
}
XPCOMUtils.defineLazyServiceGetter(this, "gIccService",
"@mozilla.org/icc/gonkiccservice;1",
"nsIGonkIccService");
XPCOMUtils.defineLazyServiceGetter(this, "gMobileMessageService",
"@mozilla.org/mobilemessage/mobilemessageservice;1",
"nsIMobileMessageService");
@ -177,6 +182,7 @@ XPCOMUtils.defineLazyGetter(this, "gStkCmdFactory", function() {
return stk.StkProactiveCmdFactory;
});
// TODO: Bug 815526, deprecate RILContentHelper.
XPCOMUtils.defineLazyGetter(this, "gMessageManager", function() {
return {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMessageListener,
@ -886,8 +892,8 @@ IccInfo.prototype = {
mcc: null,
mnc: null,
spn: null,
isDisplayNetworkNameRequired: null,
isDisplaySpnRequired: null
isDisplayNetworkNameRequired: false,
isDisplaySpnRequired: false
};
function GsmIccInfo() {}
@ -1423,7 +1429,7 @@ function RadioInterfaceLayer() {
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
Services.prefs.addObserver(kPrefRilDebuggingEnabled, this, false);
gMessageManager.init(this);
gMessageManager.init(this); // TODO: Bug 815526, deprecate RILContentHelper.
gRadioEnabledController.init(this);
gDataConnectionManager.init(this);
}
@ -1435,6 +1441,7 @@ RadioInterfaceLayer.prototype = {
interfaces: [Ci.nsIRadioInterfaceLayer]}),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIRadioInterfaceLayer,
Ci.nsIRadioInterfaceLayer_new, // TODO: Bug 815526, deprecate RILContentHelper.
Ci.nsIObserver]),
/**
@ -1676,13 +1683,14 @@ function RadioInterface(aClientId, aWorkerMessenger) {
this.clientId = aClientId;
this.workerMessenger = {
send: aWorkerMessenger.send.bind(aWorkerMessenger, aClientId),
// TODO: Bug 815526, deprecate RILContentHelper.
sendWithIPCMessage:
aWorkerMessenger.sendWithIPCMessage.bind(aWorkerMessenger, aClientId),
};
aWorkerMessenger.registerClient(aClientId, this);
this.rilContext = {
cardState: Ci.nsIIccProvider.CARD_STATE_UNKNOWN,
cardState: Ci.nsIIcc.CARD_STATE_UNKNOWN,
iccInfo: null,
imsi: null
};
@ -1780,12 +1788,14 @@ RadioInterface.prototype = {
isCardPresent: function() {
let cardState = this.rilContext.cardState;
return cardState !== Ci.nsIIccProvider.CARD_STATE_UNDETECTED &&
cardState !== Ci.nsIIccProvider.CARD_STATE_UNKNOWN;
return cardState !== Ci.nsIIcc.CARD_STATE_UNDETECTED &&
cardState !== Ci.nsIIcc.CARD_STATE_UNKNOWN;
},
/**
* Process a message from the content process.
*
* TODO: Bug 815526, deprecate RILContentHelper
*/
receiveMessage: function(msg) {
switch (msg.name) {
@ -1916,6 +1926,9 @@ RadioInterface.prototype = {
case "cardstatechange":
this.rilContext.cardState = message.cardState;
gRadioEnabledController.receiveCardState(this.clientId);
gIccService.notifyCardStateChanged(this.clientId,
this.rilContext.cardState);
// TODO: Bug 815526, deprecate RILContentHelper.
gMessageManager.sendIccMessage("RIL:CardStateChanged",
this.clientId, message);
break;
@ -1933,6 +1946,7 @@ RadioInterface.prototype = {
break;
case "iccimsi":
this.rilContext.imsi = message.imsi;
gIccService.notifyImsiChanged(this.clientId, this.rilContext.imsi);
break;
case "iccmbdn":
this.handleIccMbdn(message);
@ -1944,6 +1958,7 @@ RadioInterface.prototype = {
this.handleStkProactiveCommand(message);
break;
case "stksessionend":
// TODO: Bug 815526, deprecate RILContentHelper.
gMessageManager.sendIccMessage("RIL:StkSessionEnd", this.clientId, null);
break;
case "cdma-info-rec-received":
@ -1959,6 +1974,7 @@ RadioInterface.prototype = {
// and not compared. E.g., if the mvnoData passed is '310260x10xxxxxx',
// then the function returns true only if imsi has the same first 6 digits,
// 8th and 9th digit.
// TODO: Bug 815526, deprecate RILContentHelper.
isImsiMatches: function(mvnoData) {
let imsi = this.rilContext.imsi;
@ -1976,6 +1992,7 @@ RadioInterface.prototype = {
return true;
},
// TODO: Bug 815526, deprecate RILContentHelper.
matchMvno: function(target, message) {
if (DEBUG) this.debug("matchMvno: " + JSON.stringify(message));
@ -2213,6 +2230,8 @@ RadioInterface.prototype = {
handleIccInfoChange: function(message) {
let oldSpn = this.rilContext.iccInfo ? this.rilContext.iccInfo.spn : null;
// TODO: Bug 815526, deprecate RILContentHelper:
// Move the logic of updating iccInfo to IccService.js.
if (!message || !message.iccid) {
// If iccInfo is already `null`, don't have to clear it and send
// RIL:IccInfoChanged.
@ -2242,17 +2261,11 @@ RadioInterface.prototype = {
// RIL:IccInfoChanged corresponds to a DOM event that gets fired only
// when iccInfo has changed.
// TODO: Bug 815526, deprecate RILContentHelper.
gMessageManager.sendIccMessage("RIL:IccInfoChanged",
this.clientId,
message.iccid ? message : null);
// Update lastKnownSimMcc.
if (message.mcc) {
try {
Services.prefs.setCharPref("ril.lastKnownSimMcc",
message.mcc.toString());
} catch (e) {}
}
gIccService.notifyIccInfoChanged(this.clientId, this.rilContext.iccInfo);
// Update lastKnownHomeNetwork.
if (message.mcc && message.mnc) {
@ -2280,6 +2293,7 @@ RadioInterface.prototype = {
.notifyStkProactiveCommand(iccId,
gStkCmdFactory.createCommand(message));
}
// TODO: Bug 815526, deprecate RILContentHelper.
gMessageManager.sendIccMessage("RIL:StkCommand", this.clientId, message);
},

Просмотреть файл

@ -89,8 +89,8 @@ if CONFIG['MOZ_B2G_RIL']:
'nsIRadioInterfaceLayer.idl',
]
EXTRA_COMPONENTS += [
'RILContentHelper.js',
'RILContentHelper.manifest',
'RILContentHelper.js', # TODO: Bug 815526, deprecate RILContentHelper.
'RILContentHelper.manifest', # TODO: Bug 815526, deprecate RILContentHelper.
'RILSystemMessengerHelper.js',
'RILSystemMessengerHelper.manifest',
]

Просмотреть файл

@ -25,7 +25,7 @@ interface nsIRilNetworkInterface : nsINetworkInterface
interface nsIRilContext : nsISupports
{
/**
* One of the nsIIccProvider.CARD_STATE_* values.
* One of the nsIIcc.CARD_STATE_* values.
*/
readonly attribute unsigned long cardState;
@ -79,3 +79,13 @@ interface nsIRadioInterfaceLayer : nsISupports
void setMicrophoneMuted(in boolean muted);
};
/**
* Helper Interface to define new APIs of nsIRadioInterfaceLayer during
* ril-interfaces frozen phase.
*/
[scriptable, uuid(f8ec63da-c22e-11e4-89f3-b767dae42a13)]
interface nsIRadioInterfaceLayer_new : nsIRadioInterfaceLayer
{
};

Просмотреть файл

@ -2577,7 +2577,7 @@ this.GECKO_RADIOSTATE_DISABLED = 1;
// Only used in ril_worker.js
this.GECKO_CARDSTATE_UNINITIALIZED = 4294967294; // UINT32_MAX - 1
// See nsIIccProvider::CARD_STATE_*
// See nsIIcc::CARD_STATE_*
this.GECKO_CARDSTATE_UNDETECTED = 4294967295; // UINT32_MAX
this.GECKO_CARDSTATE_UNKNOWN = 0;
this.GECKO_CARDSTATE_READY = 1;
@ -2610,7 +2610,7 @@ this.GECKO_CARDSTATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED = 27;
this.GECKO_CARDSTATE_RUIM_PUK_REQUIRED = 28;
this.GECKO_CARDSTATE_ILLEGAL = 29;
// See nsIIccProvider::CARD_LOCK_TYPE_*
// See nsIIcc::CARD_LOCK_TYPE_*
this.GECKO_CARDLOCK_PIN = 0;
this.GECKO_CARDLOCK_PIN2 = 1;
this.GECKO_CARDLOCK_PUK = 2;
@ -2653,17 +2653,17 @@ GECKO_CARDLOCK_TO_SEL_CODE[GECKO_CARDLOCK_SPCK] = ICC_SEL_CODE_PH_SP_PIN;
// TODO: Bug 1116072: identify the mapping between RIL_PERSOSUBSTATE_SIM_SIM @
// ril.h and TS 27.007, clause 8.65 for GECKO_CARDLOCK_PCK.
// See nsIIccProvider::CARD_CONTACT_TYPE_*
// See nsIIcc::CARD_CONTACT_TYPE_*
this.GECKO_CARDCONTACT_TYPE_ADN = 0;
this.GECKO_CARDCONTACT_TYPE_FDN = 1;
this.GECKO_CARDCONTACT_TYPE_SDN = 2;
// See nsIIccProvider::CARD_MVNO_TYPE_*
// See nsIIcc::CARD_MVNO_TYPE_*
this.GECKO_CARDMVNO_TYPE_IMSI = 0;
this.GECKO_CARDMVNO_TYPE_SPN = 1;
this.GECKO_CARDMVNO_TYPE_GID = 2;
// See nsIIccProvider::CARD_MVNO_TYPE_*
// See nsIIcc::CARD_SERVICE_*
this.GECKO_CARDSERVICE_FDN = 0;
// See ril.h RIL_PersoSubstate

Просмотреть файл

@ -2,7 +2,7 @@
The test performs the static code analysis check by JSHint.
Target js files:
- RILContentHelper.js
- RILContentHelper.js TODO: Bug 815526, deprecate RILContentHelper.
- RadioInterfaceLayer.js
- ril_worker.js
- ril_consts.js
@ -100,7 +100,7 @@ class ResourceUriFileReader:
URI_PREFIX = 'resource://gre/'
URI_PATH = {
'RILContentHelper.js': 'components/RILContentHelper.js',
'RILContentHelper.js': 'components/RILContentHelper.js', #TODO: Bug 815526, deprecate RILContentHelper.
'RadioInterfaceLayer.js': 'components/RadioInterfaceLayer.js',
'ril_worker.js': 'modules/ril_worker.js',
'ril_consts.js': 'modules/ril_consts.js',
@ -354,6 +354,7 @@ class TestRILCodeQuality(MarionetteTestCase):
def tearDown(self):
MarionetteTestCase.tearDown(self)
# TODO: Bug 815526, deprecate RILContentHelper.
def test_RILContentHelper(self):
self._check('RILContentHelper.js')

Просмотреть файл

@ -33,65 +33,65 @@ add_test(function test_personalization_state() {
// Test GSM personalization state.
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_NETWORK,
Ci.nsIIccProvider.CARD_STATE_NETWORK_LOCKED);
Ci.nsIIcc.CARD_STATE_NETWORK_LOCKED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_NETWORK_SUBSET,
Ci.nsIIccProvider.CARD_STATE_NETWORK_SUBSET_LOCKED);
Ci.nsIIcc.CARD_STATE_NETWORK_SUBSET_LOCKED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_CORPORATE,
Ci.nsIIccProvider.CARD_STATE_CORPORATE_LOCKED);
Ci.nsIIcc.CARD_STATE_CORPORATE_LOCKED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER,
Ci.nsIIccProvider.CARD_STATE_SERVICE_PROVIDER_LOCKED);
Ci.nsIIcc.CARD_STATE_SERVICE_PROVIDER_LOCKED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_SIM,
Ci.nsIIccProvider.CARD_STATE_SIM_LOCKED);
Ci.nsIIcc.CARD_STATE_SIM_LOCKED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_NETWORK_PUK,
Ci.nsIIccProvider.CARD_STATE_NETWORK_PUK_REQUIRED);
Ci.nsIIcc.CARD_STATE_NETWORK_PUK_REQUIRED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK,
Ci.nsIIccProvider.CARD_STATE_NETWORK_SUBSET_PUK_REQUIRED);
Ci.nsIIcc.CARD_STATE_NETWORK_SUBSET_PUK_REQUIRED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_CORPORATE_PUK,
Ci.nsIIccProvider.CARD_STATE_CORPORATE_PUK_REQUIRED);
Ci.nsIIcc.CARD_STATE_CORPORATE_PUK_REQUIRED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK,
Ci.nsIIccProvider.CARD_STATE_SERVICE_PROVIDER_PUK_REQUIRED);
Ci.nsIIcc.CARD_STATE_SERVICE_PROVIDER_PUK_REQUIRED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_SIM_PUK,
Ci.nsIIccProvider.CARD_STATE_SIM_PUK_REQUIRED);
Ci.nsIIcc.CARD_STATE_SIM_PUK_REQUIRED);
testPersonalization(false, CARD_PERSOSUBSTATE_UNKNOWN,
Ci.nsIIccProvider.CARD_STATE_UNKNOWN);
Ci.nsIIcc.CARD_STATE_UNKNOWN);
testPersonalization(false, CARD_PERSOSUBSTATE_IN_PROGRESS,
Ci.nsIIccProvider.CARD_STATE_PERSONALIZATION_IN_PROGRESS);
Ci.nsIIcc.CARD_STATE_PERSONALIZATION_IN_PROGRESS);
testPersonalization(false, CARD_PERSOSUBSTATE_READY,
Ci.nsIIccProvider.CARD_STATE_PERSONALIZATION_READY);
Ci.nsIIcc.CARD_STATE_PERSONALIZATION_READY);
// Test CDMA personalization state.
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_NETWORK1,
Ci.nsIIccProvider.CARD_STATE_NETWORK1_LOCKED);
Ci.nsIIcc.CARD_STATE_NETWORK1_LOCKED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_NETWORK2,
Ci.nsIIccProvider.CARD_STATE_NETWORK2_LOCKED);
Ci.nsIIcc.CARD_STATE_NETWORK2_LOCKED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_HRPD,
Ci.nsIIccProvider.CARD_STATE_HRPD_NETWORK_LOCKED);
Ci.nsIIcc.CARD_STATE_HRPD_NETWORK_LOCKED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_CORPORATE,
Ci.nsIIccProvider.CARD_STATE_RUIM_CORPORATE_LOCKED);
Ci.nsIIcc.CARD_STATE_RUIM_CORPORATE_LOCKED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER,
Ci.nsIIccProvider.CARD_STATE_RUIM_SERVICE_PROVIDER_LOCKED);
Ci.nsIIcc.CARD_STATE_RUIM_SERVICE_PROVIDER_LOCKED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_RUIM,
Ci.nsIIccProvider.CARD_STATE_RUIM_LOCKED);
Ci.nsIIcc.CARD_STATE_RUIM_LOCKED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_NETWORK1_PUK,
Ci.nsIIccProvider.CARD_STATE_NETWORK1_PUK_REQUIRED);
Ci.nsIIcc.CARD_STATE_NETWORK1_PUK_REQUIRED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_NETWORK2_PUK,
Ci.nsIIccProvider.CARD_STATE_NETWORK2_PUK_REQUIRED);
Ci.nsIIcc.CARD_STATE_NETWORK2_PUK_REQUIRED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_HRPD_PUK,
Ci.nsIIccProvider.CARD_STATE_HRPD_NETWORK_PUK_REQUIRED);
Ci.nsIIcc.CARD_STATE_HRPD_NETWORK_PUK_REQUIRED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_CORPORATE_PUK,
Ci.nsIIccProvider.CARD_STATE_RUIM_CORPORATE_PUK_REQUIRED);
Ci.nsIIcc.CARD_STATE_RUIM_CORPORATE_PUK_REQUIRED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK,
Ci.nsIIccProvider.CARD_STATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED);
Ci.nsIIcc.CARD_STATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_RUIM_PUK,
Ci.nsIIccProvider.CARD_STATE_RUIM_PUK_REQUIRED);
Ci.nsIIcc.CARD_STATE_RUIM_PUK_REQUIRED);
testPersonalization(true, CARD_PERSOSUBSTATE_UNKNOWN,
Ci.nsIIccProvider.CARD_STATE_UNKNOWN);
Ci.nsIIcc.CARD_STATE_UNKNOWN);
testPersonalization(true, CARD_PERSOSUBSTATE_IN_PROGRESS,
Ci.nsIIccProvider.CARD_STATE_PERSONALIZATION_IN_PROGRESS);
Ci.nsIIcc.CARD_STATE_PERSONALIZATION_IN_PROGRESS);
testPersonalization(true, CARD_PERSOSUBSTATE_READY,
Ci.nsIIccProvider.CARD_STATE_PERSONALIZATION_READY);
Ci.nsIIcc.CARD_STATE_PERSONALIZATION_READY);
run_next_test();
});
@ -121,17 +121,17 @@ add_test(function test_card_app_state() {
}
testCardAppState(CARD_APPSTATE_ILLEGAL,
Ci.nsIIccProvider.CARD_STATE_ILLEGAL);
Ci.nsIIcc.CARD_STATE_ILLEGAL);
testCardAppState(CARD_APPSTATE_PIN,
Ci.nsIIccProvider.CARD_STATE_PIN_REQUIRED);
Ci.nsIIcc.CARD_STATE_PIN_REQUIRED);
testCardAppState(CARD_APPSTATE_PUK,
Ci.nsIIccProvider.CARD_STATE_PUK_REQUIRED);
Ci.nsIIcc.CARD_STATE_PUK_REQUIRED);
testCardAppState(CARD_APPSTATE_READY,
Ci.nsIIccProvider.CARD_STATE_READY);
Ci.nsIIcc.CARD_STATE_READY);
testCardAppState(CARD_APPSTATE_UNKNOWN,
Ci.nsIIccProvider.CARD_STATE_UNKNOWN);
Ci.nsIIcc.CARD_STATE_UNKNOWN);
testCardAppState(CARD_APPSTATE_DETECTED,
Ci.nsIIccProvider.CARD_STATE_UNKNOWN);
Ci.nsIIcc.CARD_STATE_UNKNOWN);
run_next_test();
});
@ -159,7 +159,7 @@ add_test(function test_icc_permanent_blocked() {
};
ril._processICCStatus(iccStatus);
equal(ril.cardState, Ci.nsIIccProvider.CARD_STATE_PERMANENT_BLOCKED);
equal(ril.cardState, Ci.nsIIcc.CARD_STATE_PERMANENT_BLOCKED);
}
testPermanentBlocked(1,

Просмотреть файл

@ -129,6 +129,16 @@ dictionary IccSetCardLockOptions
// Necessary for lock types: "pin", "fdn"
};
dictionary IccCardLockStatus
{
boolean enabled; // True when CardLock is enabled.
};
dictionary IccCardLockRetryCount
{
long retryCount; // The number of remaining retries. -1 if unkown.
};
[Pref="dom.icc.enabled",
CheckPermissions="mobileconnection",
AvailableIn="CertifiedApps"]
@ -247,6 +257,7 @@ interface MozIcc : EventTarget
* The request's result will be an object containing
* information about the specified lock's status.
* e.g. {enabled: true}.
* @see IccCardLockStatus.
*/
[Throws]
DOMRequest getCardLock(IccLockType lockType);
@ -289,8 +300,8 @@ interface MozIcc : EventTarget
*
* @return a DOMRequest.
* The request's result will be an object containing the number of
* remaining retries.
* e.g. {retryCount: 3}.
* remaining retries. e.g. {retryCount: 3}.
* @see IccCardLockRetryCount.
*/
[Throws]
DOMRequest getCardLockRetryCount(IccLockType lockType);

Просмотреть файл

@ -229,6 +229,7 @@ WEBIDL_FILES = [
'HTMLTrackElement.webidl',
'HTMLUListElement.webidl',
'HTMLVideoElement.webidl',
'IccCardLockError.webidl',
'IDBCursor.webidl',
'IDBDatabase.webidl',
'IDBEnvironment.webidl',
@ -287,6 +288,9 @@ WEBIDL_FILES = [
'MozActivity.webidl',
'MozCellBroadcast.webidl',
'MozCellBroadcastMessage.webidl',
'MozIcc.webidl',
'MozIccInfo.webidl',
'MozIccManager.webidl',
'MozMmsMessage.webidl',
'MozMobileCellInfo.webidl',
'MozMobileConnection.webidl',
@ -651,14 +655,6 @@ if CONFIG['MOZ_B2G_BT']:
'BluetoothManager.webidl',
]
if CONFIG['MOZ_B2G_RIL']:
WEBIDL_FILES += [
'IccCardLockError.webidl',
'MozIcc.webidl',
'MozIccInfo.webidl',
'MozIccManager.webidl',
]
if CONFIG['MOZ_NFC']:
WEBIDL_FILES += [
'MozIsoDepTech.webidl',

Просмотреть файл

@ -850,6 +850,16 @@ var WifiManager = (function() {
if (eventData.indexOf("CTRL-EVENT-EAP") === 0) {
return handleWpaEapEvents(event);
}
if (eventData.indexOf("CTRL-EVENT-ASSOC-REJECT") === 0) {
debug("CTRL-EVENT-ASSOC-REJECT: network error");
notify("passwordmaybeincorrect");
if (manager.authenticationFailuresCount > MAX_RETRIES_ON_AUTHENTICATION_FAILURE) {
manager.authenticationFailuresCount = 0;
debug("CTRL-EVENT-ASSOC-REJECT: disconnect network");
notify("disconnected", {connectionInfo: manager.connectionInfo});
}
return true;
}
if (eventData.indexOf("WPS-TIMEOUT") === 0) {
notifyStateChange({ state: "WPS_TIMEOUT", BSSID: null, id: -1 });
return true;
@ -2162,7 +2172,10 @@ function WifiWorker() {
ssid: quote(WifiManager.connectionInfo.ssid),
mode: MODE_ESS,
frequency: 0};
self._fireEvent("onconnecting", { network: netToDOM(self.currentNetwork) });
WifiManager.getNetworkConfiguration(self.currentNetwork, function (){
// Notify again because we get complete network information.
self._fireEvent("onconnecting", { network: netToDOM(self.currentNetwork) });
});
break;
case "ASSOCIATED":
// set to full power mode when ready to do 4 way handsharke.

Просмотреть файл

@ -229,6 +229,13 @@ ReportError(JSContext *cx, const char *message, JSErrorReport *reportp,
if (cx->options().autoJSAPIOwnsErrorReporting() || JS_IsRunning(cx)) {
if (ErrorToException(cx, message, reportp, callback, userRef))
return;
/*
* The AutoJSAPI error reporter only allows warnings to be reported so
* just ignore this error rather than try to report it.
*/
if (cx->options().autoJSAPIOwnsErrorReporting())
return;
}
/*

Просмотреть файл

@ -577,6 +577,12 @@ js::ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp,
static bool
IsDuckTypedErrorObject(JSContext *cx, HandleObject exnObject, const char **filename_strp)
{
/*
* This function is called from ErrorReport::init and so should not generate
* any new exceptions.
*/
AutoClearPendingException acpe(cx);
bool found;
if (!JS_HasProperty(cx, exnObject, js_message_str, &found) || !found)
return false;

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше