зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1114937 - Part 6: Deprecate RILContentHelper. r=echen
This commit is contained in:
Родитель
fdf011b4c8
Коммит
ddd1dd8283
|
@ -516,8 +516,6 @@
|
|||
#endif
|
||||
@RESPATH@/components/StkCmdFactory.js
|
||||
@RESPATH@/components/StkCmdFactory.manifest
|
||||
@RESPATH@/components/RILContentHelper.js
|
||||
@RESPATH@/components/RILContentHelper.manifest
|
||||
@RESPATH@/components/RILSystemMessengerHelper.js
|
||||
@RESPATH@/components/RILSystemMessengerHelper.manifest
|
||||
@RESPATH@/components/TelephonyAudioService.js
|
||||
|
|
|
@ -15,11 +15,9 @@
|
|||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "nsIIccInfo.h"
|
||||
#include "nsIIccProvider.h"
|
||||
#include "nsIIccService.h"
|
||||
#include "nsIStkCmdFactory.h"
|
||||
#include "nsIStkProactiveCmd.h"
|
||||
#include "nsRadioInterfaceLayer.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
using mozilla::dom::icc::IccCallback;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "IccManager.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsIIccInfo.h"
|
||||
#include "nsRadioInterfaceLayer.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#define mozilla_dom_IccListener_h
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIIccProvider.h"
|
||||
#include "nsIIccService.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
XPIDL_SOURCES += [
|
||||
'nsIIccContact.idl',
|
||||
'nsIIccInfo.idl',
|
||||
'nsIIccProvider.idl', # TODO: Bug 815526, deprecate RILContentHelper.
|
||||
'nsIIccService.idl',
|
||||
'nsIStkCmdFactory.idl',
|
||||
'nsIStkProactiveCmd.idl',
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/* 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 nsIDOMDOMRequest;
|
||||
interface nsIDOMWindow;
|
||||
|
||||
/**
|
||||
* XPCOM component (in the content process) that provides the ICC information.
|
||||
*/
|
||||
[scriptable, uuid(09f29ef0-006f-11e5-a0e1-fbef06958398)]
|
||||
interface nsIIccProvider : nsISupports
|
||||
{
|
||||
/**
|
||||
* Phonebook interfaces.
|
||||
*/
|
||||
nsIDOMDOMRequest readContacts(in unsigned long clientId,
|
||||
in nsIDOMWindow window,
|
||||
in unsigned long contactType);
|
||||
|
||||
nsIDOMDOMRequest updateContact(in unsigned long clientId,
|
||||
in nsIDOMWindow window,
|
||||
in unsigned long contactType,
|
||||
in jsval contact,
|
||||
in DOMString pin2);
|
||||
};
|
|
@ -22,7 +22,6 @@
|
|||
#include "nsIVariant.h"
|
||||
#include "nsJSON.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsRadioInterfaceLayer.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
#define MOBILECONN_ERROR_INVALID_PARAMETER NS_LITERAL_STRING("InvalidParameter")
|
||||
|
|
|
@ -1,340 +0,0 @@
|
|||
/* Copyright 2012 Mozilla Foundation and Mozilla contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
/* global RIL */
|
||||
XPCOMUtils.defineLazyGetter(this, "RIL", function () {
|
||||
let obj = {};
|
||||
Cu.import("resource://gre/modules/ril_consts.js", obj);
|
||||
return obj;
|
||||
});
|
||||
|
||||
const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown";
|
||||
|
||||
const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
|
||||
|
||||
const kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
|
||||
const kPrefRilDebuggingEnabled = "ril.debugging.enabled";
|
||||
|
||||
let DEBUG;
|
||||
function debug(s) {
|
||||
dump("-*- RILContentHelper: " + s + "\n");
|
||||
}
|
||||
|
||||
const RILCONTENTHELPER_CID =
|
||||
Components.ID("{472816e1-1fd6-4405-996c-806f9ea68174}");
|
||||
|
||||
const RIL_IPC_MSG_NAMES = [
|
||||
"RIL:ReadIccContacts",
|
||||
"RIL:UpdateIccContact",
|
||||
];
|
||||
|
||||
/* global cpmm */
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
"nsISyncMessageSender");
|
||||
|
||||
/* global UUIDGenerator */
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "UUIDGenerator",
|
||||
"@mozilla.org/uuid-generator;1",
|
||||
"nsIUUIDGenerator");
|
||||
|
||||
/* global gNumRadioInterfaces */
|
||||
XPCOMUtils.defineLazyGetter(this, "gNumRadioInterfaces", function() {
|
||||
let appInfo = Cc["@mozilla.org/xre/app-info;1"];
|
||||
let isParentProcess = !appInfo || appInfo.getService(Ci.nsIXULRuntime)
|
||||
.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
|
||||
if (isParentProcess) {
|
||||
let ril = { numRadioInterfaces: 0 };
|
||||
try {
|
||||
ril = Cc["@mozilla.org/ril;1"].getService(Ci.nsIRadioInterfaceLayer);
|
||||
} catch(e) {}
|
||||
return ril.numRadioInterfaces;
|
||||
}
|
||||
|
||||
return Services.prefs.getIntPref(kPrefRilNumRadioInterfaces);
|
||||
});
|
||||
|
||||
function RILContentHelper() {
|
||||
this.updateDebugFlag();
|
||||
|
||||
this.numClients = gNumRadioInterfaces;
|
||||
if (DEBUG) debug("Number of clients: " + this.numClients);
|
||||
|
||||
this.initDOMRequestHelper(/* aWindow */ null, RIL_IPC_MSG_NAMES);
|
||||
this._windowsMap = [];
|
||||
|
||||
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
|
||||
Services.prefs.addObserver(kPrefRilDebuggingEnabled, this, false);
|
||||
}
|
||||
|
||||
RILContentHelper.prototype = {
|
||||
__proto__: DOMRequestIpcHelper.prototype,
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIIccProvider,
|
||||
Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference]),
|
||||
classID: RILCONTENTHELPER_CID,
|
||||
classInfo: XPCOMUtils.generateCI({classID: RILCONTENTHELPER_CID,
|
||||
classDescription: "RILContentHelper",
|
||||
interfaces: [Ci.nsIIccProvider]}),
|
||||
|
||||
updateDebugFlag: function() {
|
||||
try {
|
||||
DEBUG = RIL.DEBUG_CONTENT_HELPER ||
|
||||
Services.prefs.getBoolPref(kPrefRilDebuggingEnabled);
|
||||
} catch (e) {}
|
||||
},
|
||||
|
||||
_windowsMap: null,
|
||||
|
||||
/**
|
||||
* nsIIccProvider
|
||||
*/
|
||||
|
||||
readContacts: function(clientId, window, contactType) {
|
||||
if (window == null) {
|
||||
throw Components.Exception("Can't get window object",
|
||||
Cr.NS_ERROR_UNEXPECTED);
|
||||
}
|
||||
|
||||
let request = Services.DOMRequest.createRequest(window);
|
||||
let requestId = this.getRequestId(request);
|
||||
this._windowsMap[requestId] = window;
|
||||
|
||||
cpmm.sendAsyncMessage("RIL:ReadIccContacts", {
|
||||
clientId: clientId,
|
||||
data: {
|
||||
requestId: requestId,
|
||||
contactType: contactType
|
||||
}
|
||||
});
|
||||
return request;
|
||||
},
|
||||
|
||||
updateContact: function(clientId, window, contactType, contact, pin2) {
|
||||
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;
|
||||
|
||||
// Parsing nsDOMContact to Icc Contact format
|
||||
let iccContact = {};
|
||||
|
||||
if (Array.isArray(contact.name) && contact.name[0]) {
|
||||
iccContact.alphaId = contact.name[0];
|
||||
}
|
||||
|
||||
if (Array.isArray(contact.tel)) {
|
||||
iccContact.number = contact.tel[0] && contact.tel[0].value;
|
||||
let telArray = contact.tel.slice(1);
|
||||
let length = telArray.length;
|
||||
if (length > 0) {
|
||||
iccContact.anr = [];
|
||||
}
|
||||
for (let i = 0; i < telArray.length; i++) {
|
||||
iccContact.anr.push(telArray[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(contact.email) && contact.email[0]) {
|
||||
iccContact.email = contact.email[0].value;
|
||||
}
|
||||
|
||||
iccContact.contactId = contact.id;
|
||||
|
||||
cpmm.sendAsyncMessage("RIL:UpdateIccContact", {
|
||||
clientId: clientId,
|
||||
data: {
|
||||
requestId: requestId,
|
||||
contactType: contactType,
|
||||
contact: iccContact,
|
||||
pin2: pin2
|
||||
}
|
||||
});
|
||||
|
||||
return request;
|
||||
},
|
||||
|
||||
// nsIObserver
|
||||
|
||||
observe: function(subject, topic, data) {
|
||||
switch (topic) {
|
||||
case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
|
||||
if (data == kPrefRilDebuggingEnabled) {
|
||||
this.updateDebugFlag();
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
|
||||
this.destroyDOMRequestHelper();
|
||||
Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
// nsIMessageListener
|
||||
|
||||
fireRequestSuccess: function(requestId, result) {
|
||||
let request = this.takeRequest(requestId);
|
||||
if (!request) {
|
||||
if (DEBUG) {
|
||||
debug("not firing success for id: " + requestId +
|
||||
", result: " + JSON.stringify(result));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
debug("fire request success, id: " + requestId +
|
||||
", result: " + JSON.stringify(result));
|
||||
}
|
||||
Services.DOMRequest.fireSuccess(request, result);
|
||||
},
|
||||
|
||||
dispatchFireRequestSuccess: function(requestId, result) {
|
||||
let currentThread = Services.tm.currentThread;
|
||||
|
||||
currentThread.dispatch(this.fireRequestSuccess.bind(this, requestId, result),
|
||||
Ci.nsIThread.DISPATCH_NORMAL);
|
||||
},
|
||||
|
||||
fireRequestError: function(requestId, error) {
|
||||
let request = this.takeRequest(requestId);
|
||||
if (!request) {
|
||||
if (DEBUG) {
|
||||
debug("not firing error for id: " + requestId +
|
||||
", error: " + JSON.stringify(error));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
debug("fire request error, id: " + requestId +
|
||||
", result: " + JSON.stringify(error));
|
||||
}
|
||||
Services.DOMRequest.fireError(request, error);
|
||||
},
|
||||
|
||||
dispatchFireRequestError: function(requestId, error) {
|
||||
let currentThread = Services.tm.currentThread;
|
||||
|
||||
currentThread.dispatch(this.fireRequestError.bind(this, requestId, error),
|
||||
Ci.nsIThread.DISPATCH_NORMAL);
|
||||
},
|
||||
|
||||
fireRequestDetailedError: function(requestId, detailedError) {
|
||||
let request = this.takeRequest(requestId);
|
||||
if (!request) {
|
||||
if (DEBUG) {
|
||||
debug("not firing detailed error for id: " + requestId +
|
||||
", detailedError: " + JSON.stringify(detailedError));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Services.DOMRequest.fireDetailedError(request, detailedError);
|
||||
},
|
||||
|
||||
receiveMessage: function(msg) {
|
||||
let request;
|
||||
if (DEBUG) {
|
||||
debug("Received message '" + msg.name + "': " + JSON.stringify(msg.json));
|
||||
}
|
||||
|
||||
let data = msg.json.data;
|
||||
let clientId = msg.json.clientId;
|
||||
switch (msg.name) {
|
||||
case "RIL:ReadIccContacts":
|
||||
this.handleReadIccContacts(data);
|
||||
break;
|
||||
case "RIL:UpdateIccContact":
|
||||
this.handleUpdateIccContact(data);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
handleReadIccContacts: function(message) {
|
||||
if (message.errorMsg) {
|
||||
this.fireRequestError(message.requestId, message.errorMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
let window = this._windowsMap[message.requestId];
|
||||
delete this._windowsMap[message.requestId];
|
||||
let contacts = message.contacts;
|
||||
let result = new window.Array();
|
||||
contacts.forEach(function(c) {
|
||||
let prop = {name: [c.alphaId], tel: [{value: c.number}]};
|
||||
|
||||
if (c.email) {
|
||||
prop.email = [{value: c.email}];
|
||||
}
|
||||
|
||||
// ANR - Additional Number
|
||||
let anrLen = c.anr ? c.anr.length : 0;
|
||||
for (let i = 0; i < anrLen; i++) {
|
||||
prop.tel.push({value: c.anr[i]});
|
||||
}
|
||||
|
||||
let contact = new window.mozContact(prop);
|
||||
contact.id = c.contactId;
|
||||
result.push(contact);
|
||||
});
|
||||
|
||||
this.fireRequestSuccess(message.requestId, result);
|
||||
},
|
||||
|
||||
handleUpdateIccContact: function(message) {
|
||||
if (message.errorMsg) {
|
||||
this.fireRequestError(message.requestId, message.errorMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
let window = this._windowsMap[message.requestId];
|
||||
delete this._windowsMap[message.requestId];
|
||||
let iccContact = message.contact;
|
||||
let prop = {name: [iccContact.alphaId], tel: [{value: iccContact.number}]};
|
||||
if (iccContact.email) {
|
||||
prop.email = [{value: iccContact.email}];
|
||||
}
|
||||
|
||||
// ANR - Additional Number
|
||||
let anrLen = iccContact.anr ? iccContact.anr.length : 0;
|
||||
for (let i = 0; i < anrLen; i++) {
|
||||
prop.tel.push({value: iccContact.anr[i]});
|
||||
}
|
||||
|
||||
let contact = new window.mozContact(prop);
|
||||
contact.id = iccContact.contactId;
|
||||
|
||||
this.fireRequestSuccess(message.requestId, contact);
|
||||
}
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RILContentHelper]);
|
|
@ -1,20 +0,0 @@
|
|||
# Copyright 2012 Mozilla Foundation and Mozilla contributors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# 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
|
|
@ -63,12 +63,6 @@ const HW_DEFAULT_CLIENT_ID = 0;
|
|||
const NETWORK_TYPE_WIFI = Ci.nsINetworkInterface.NETWORK_TYPE_WIFI;
|
||||
const NETWORK_TYPE_MOBILE = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE;
|
||||
|
||||
// TODO: Bug 815526, deprecate RILContentHelper.
|
||||
const RIL_IPC_ICCMANAGER_MSG_NAMES = [
|
||||
"RIL:ReadIccContacts",
|
||||
"RIL:UpdateIccContact",
|
||||
];
|
||||
|
||||
// set to true in ril_consts.js to see debug messages
|
||||
var DEBUG = RIL.DEBUG_RIL;
|
||||
|
||||
|
@ -144,204 +138,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "gStkCmdFactory",
|
|||
"@mozilla.org/icc/stkcmdfactory;1",
|
||||
"nsIStkCmdFactory");
|
||||
|
||||
// TODO: Bug 815526, deprecate RILContentHelper.
|
||||
XPCOMUtils.defineLazyGetter(this, "gMessageManager", function() {
|
||||
return {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMessageListener,
|
||||
Ci.nsIObserver]),
|
||||
|
||||
ril: null,
|
||||
|
||||
// Manage message targets in terms of topic. Only the authorized and
|
||||
// registered contents can receive related messages.
|
||||
targetsByTopic: {},
|
||||
topics: [],
|
||||
|
||||
targetMessageQueue: [],
|
||||
ready: false,
|
||||
|
||||
init: function(ril) {
|
||||
this.ril = ril;
|
||||
|
||||
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
Services.obs.addObserver(this, kSysMsgListenerReadyObserverTopic, false);
|
||||
this._registerMessageListeners();
|
||||
},
|
||||
|
||||
_shutdown: function() {
|
||||
this.ril = null;
|
||||
|
||||
Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
||||
this._unregisterMessageListeners();
|
||||
},
|
||||
|
||||
_registerMessageListeners: function() {
|
||||
ppmm.addMessageListener("child-process-shutdown", this);
|
||||
for (let msgName of RIL_IPC_ICCMANAGER_MSG_NAMES) {
|
||||
ppmm.addMessageListener(msgName, this);
|
||||
}
|
||||
},
|
||||
|
||||
_unregisterMessageListeners: function() {
|
||||
ppmm.removeMessageListener("child-process-shutdown", this);
|
||||
for (let msgName of RIL_IPC_ICCMANAGER_MSG_NAMES) {
|
||||
ppmm.removeMessageListener(msgName, this);
|
||||
}
|
||||
ppmm = null;
|
||||
},
|
||||
|
||||
_registerMessageTarget: function(topic, target) {
|
||||
let targets = this.targetsByTopic[topic];
|
||||
if (!targets) {
|
||||
targets = this.targetsByTopic[topic] = [];
|
||||
let list = this.topics;
|
||||
if (list.indexOf(topic) == -1) {
|
||||
list.push(topic);
|
||||
}
|
||||
}
|
||||
|
||||
if (targets.indexOf(target) != -1) {
|
||||
if (DEBUG) debug("Already registered this target!");
|
||||
return;
|
||||
}
|
||||
|
||||
targets.push(target);
|
||||
if (DEBUG) debug("Registered " + topic + " target: " + target);
|
||||
},
|
||||
|
||||
_unregisterMessageTarget: function(topic, target) {
|
||||
if (topic == null) {
|
||||
// Unregister the target for every topic when no topic is specified.
|
||||
for (let type of this.topics) {
|
||||
this._unregisterMessageTarget(type, target);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Unregister the target for a specified topic.
|
||||
let targets = this.targetsByTopic[topic];
|
||||
if (!targets) {
|
||||
return;
|
||||
}
|
||||
|
||||
let index = targets.indexOf(target);
|
||||
if (index != -1) {
|
||||
targets.splice(index, 1);
|
||||
if (DEBUG) debug("Unregistered " + topic + " target: " + target);
|
||||
}
|
||||
},
|
||||
|
||||
_enqueueTargetMessage: function(topic, message, options) {
|
||||
let msg = { topic : topic,
|
||||
message : message,
|
||||
options : options };
|
||||
// Remove previous queued message with the same message type and client Id
|
||||
// , only one message per (message type + client Id) is allowed in queue.
|
||||
let messageQueue = this.targetMessageQueue;
|
||||
for(let i = 0; i < messageQueue.length; i++) {
|
||||
if (messageQueue[i].message === message &&
|
||||
messageQueue[i].options.clientId === options.clientId) {
|
||||
messageQueue.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
messageQueue.push(msg);
|
||||
},
|
||||
|
||||
_sendTargetMessage: function(topic, message, options) {
|
||||
if (!this.ready) {
|
||||
this._enqueueTargetMessage(topic, message, options);
|
||||
return;
|
||||
}
|
||||
|
||||
let targets = this.targetsByTopic[topic];
|
||||
if (!targets) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let target of targets) {
|
||||
target.sendAsyncMessage(message, options);
|
||||
}
|
||||
},
|
||||
|
||||
_resendQueuedTargetMessage: function() {
|
||||
this.ready = true;
|
||||
|
||||
// Here uses this._sendTargetMessage() to resend message, which will
|
||||
// enqueue message if listener is not ready.
|
||||
// So only resend after listener is ready, or it will cause infinate loop and
|
||||
// hang the system.
|
||||
|
||||
// Dequeue and resend messages.
|
||||
for each (let msg in this.targetMessageQueue) {
|
||||
this._sendTargetMessage(msg.topic, msg.message, msg.options);
|
||||
}
|
||||
this.targetMessageQueue = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* nsIMessageListener interface methods.
|
||||
*/
|
||||
|
||||
receiveMessage: function(msg) {
|
||||
if (DEBUG) debug("Received '" + msg.name + "' message from content process");
|
||||
if (msg.name == "child-process-shutdown") {
|
||||
// By the time we receive child-process-shutdown, the child process has
|
||||
// already forgotten its permissions so we need to unregister the target
|
||||
// for every permission.
|
||||
this._unregisterMessageTarget(null, msg.target);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (RIL_IPC_ICCMANAGER_MSG_NAMES.indexOf(msg.name) != -1) {
|
||||
if (!msg.target.assertPermission("mobileconnection")) {
|
||||
if (DEBUG) {
|
||||
debug("IccManager message " + msg.name +
|
||||
" from a content process with no 'mobileconnection' privileges.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (DEBUG) debug("Ignoring unknown message type: " + msg.name);
|
||||
return null;
|
||||
}
|
||||
|
||||
let clientId = msg.json.clientId || 0;
|
||||
let radioInterface = this.ril.getRadioInterface(clientId);
|
||||
if (!radioInterface) {
|
||||
if (DEBUG) debug("No such radio interface: " + clientId);
|
||||
return null;
|
||||
}
|
||||
|
||||
return radioInterface.receiveMessage(msg);
|
||||
},
|
||||
|
||||
/**
|
||||
* nsIObserver interface methods.
|
||||
*/
|
||||
|
||||
observe: function(subject, topic, data) {
|
||||
switch (topic) {
|
||||
case kSysMsgListenerReadyObserverTopic:
|
||||
Services.obs.removeObserver(this, kSysMsgListenerReadyObserverTopic);
|
||||
this._resendQueuedTargetMessage();
|
||||
break;
|
||||
case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
|
||||
this._shutdown();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
sendIccMessage: function(message, clientId, data) {
|
||||
this._sendTargetMessage("icc", message, {
|
||||
clientId: clientId,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gRadioEnabledController", function() {
|
||||
let _ril = null;
|
||||
let _pendingMessages = []; // For queueing "setRadioEnabled" message.
|
||||
|
@ -614,7 +410,6 @@ function RadioInterfaceLayer() {
|
|||
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
Services.prefs.addObserver(kPrefRilDebuggingEnabled, this, false);
|
||||
|
||||
gMessageManager.init(this); // TODO: Bug 815526, deprecate RILContentHelper.
|
||||
gRadioEnabledController.init(this);
|
||||
}
|
||||
RadioInterfaceLayer.prototype = {
|
||||
|
@ -841,39 +636,13 @@ WorkerMessenger.prototype = {
|
|||
|
||||
message.rilMessageType = rilMessageType;
|
||||
this.worker.postMessage(message);
|
||||
},
|
||||
|
||||
/**
|
||||
* Send message to worker and return worker reply to RILContentHelper.
|
||||
*
|
||||
* @param msg
|
||||
* A message object from ppmm.
|
||||
* @param rilMessageType
|
||||
* A text string for worker message type.
|
||||
* @param ipcType [optinal]
|
||||
* A text string for ipc message type. "msg.name" if omitted.
|
||||
*
|
||||
* @TODO: Bug 815526 - deprecate RILContentHelper.
|
||||
*/
|
||||
sendWithIPCMessage: function(clientId, msg, rilMessageType, ipcType) {
|
||||
this.send(clientId, rilMessageType, msg.json.data, (function(reply) {
|
||||
ipcType = ipcType || msg.name;
|
||||
msg.target.sendAsyncMessage(ipcType, {
|
||||
clientId: clientId,
|
||||
data: reply
|
||||
});
|
||||
return false;
|
||||
}).bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
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),
|
||||
send: aWorkerMessenger.send.bind(aWorkerMessenger, aClientId)
|
||||
};
|
||||
aWorkerMessenger.registerClient(aClientId, this);
|
||||
|
||||
|
@ -941,23 +710,6 @@ RadioInterface.prototype = {
|
|||
cardState !== Ci.nsIIcc.CARD_STATE_UNKNOWN;
|
||||
},
|
||||
|
||||
/**
|
||||
* Process a message from the content process.
|
||||
*
|
||||
* TODO: Bug 815526, deprecate RILContentHelper
|
||||
*/
|
||||
receiveMessage: function(msg) {
|
||||
switch (msg.name) {
|
||||
case "RIL:ReadIccContacts":
|
||||
this.workerMessenger.sendWithIPCMessage(msg, "readICCContacts");
|
||||
break;
|
||||
case "RIL:UpdateIccContact":
|
||||
this.workerMessenger.sendWithIPCMessage(msg, "updateICCContact");
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
handleUnsolicitedWorkerMessage: function(message) {
|
||||
switch (message.rilMessageType) {
|
||||
case "callRing":
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "nsIObserverService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsRadioInterfaceLayer.h"
|
||||
#include "WifiWorker.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
|
|
|
@ -94,8 +94,6 @@ if CONFIG['MOZ_B2G_RIL']:
|
|||
EXTRA_COMPONENTS += [
|
||||
'DataCallManager.js',
|
||||
'DataCallManager.manifest',
|
||||
'RILContentHelper.js', # TODO: Bug 815526, deprecate RILContentHelper.
|
||||
'RILContentHelper.manifest', # TODO: Bug 815526, deprecate RILContentHelper.
|
||||
'RILSystemMessengerHelper.js',
|
||||
'RILSystemMessengerHelper.manifest',
|
||||
]
|
||||
|
|
|
@ -35,6 +35,13 @@ interface nsIRadioInterface : nsISupports
|
|||
[optional] in nsIRilSendWorkerMessageCallback callback);
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_RADIOINTERFACELAYER_CID \
|
||||
{ 0x2d831c8d, 0x6017, 0x435b, \
|
||||
{ 0xa8, 0x0c, 0xe5, 0xd4, 0x22, 0x81, 0x0c, 0xea } }
|
||||
#define NS_RADIOINTERFACELAYER_CONTRACTID "@mozilla.org/ril;1"
|
||||
%}
|
||||
|
||||
[scriptable, uuid(78b65e8c-68e7-4510-9a05-65bba12b283e)]
|
||||
interface nsIRadioInterfaceLayer : nsISupports
|
||||
{
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
/* 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/. */
|
||||
|
||||
// These must always match the values given in RadioInterfaceLayer.manifest!
|
||||
|
||||
#define NS_RADIOINTERFACELAYER_CID \
|
||||
{ 0x2d831c8d, 0x6017, 0x435b, \
|
||||
{ 0xa8, 0x0c, 0xe5, 0xd4, 0x22, 0x81, 0x0c, 0xea } }
|
||||
|
||||
#define NS_RILCONTENTHELPER_CID \
|
||||
{ 0x472816e1, 0x1fd6, 0x4405, \
|
||||
{ 0x99, 0x6c, 0x80, 0x6f, 0x9e, 0xa6, 0x81, 0x74 } }
|
||||
|
||||
#define NS_RADIOINTERFACELAYER_CONTRACTID "@mozilla.org/ril;1"
|
||||
#define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1"
|
|
@ -2,7 +2,6 @@
|
|||
The test performs the static code analysis check by JSHint.
|
||||
|
||||
Target js files:
|
||||
- RILContentHelper.js TODO: Bug 815526, deprecate RILContentHelper.
|
||||
- RadioInterfaceLayer.js
|
||||
- ril_worker.js
|
||||
- ril_consts.js
|
||||
|
@ -100,7 +99,6 @@ class ResourceUriFileReader:
|
|||
|
||||
URI_PREFIX = 'resource://gre/'
|
||||
URI_PATH = {
|
||||
'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',
|
||||
|
@ -358,10 +356,6 @@ class TestRILCodeQuality(MarionetteTestCase):
|
|||
def tearDown(self):
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
# TODO: Bug 815526, deprecate RILContentHelper.
|
||||
def test_RILContentHelper(self):
|
||||
self._check('RILContentHelper.js')
|
||||
|
||||
def test_RadioInterfaceLayer(self):
|
||||
self._check('RadioInterfaceLayer.js')
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче