Merge B2g-inbound to Mozilla-Central

This commit is contained in:
Carsten "Tomcat" Book 2013-10-25 11:48:38 +02:00
commit 63e13d3fb3
35 changed files with 947 additions and 132 deletions

View File

@ -157,6 +157,16 @@ SettingsListener.observe('language.current', 'en-US', function(value) {
function(value) { function(value) {
Services.prefs.setCharPref('wap.UAProf.tagname', value); Services.prefs.setCharPref('wap.UAProf.tagname', value);
}); });
// DSDS default service IDs
['mms', 'sms', 'telephony', 'voicemail'].forEach(function(key) {
SettingsListener.observe('ril.' + key + '.defaultServiceId', 0,
function(value) {
if (value != null) {
Services.prefs.setIntPref('dom.' + key + '.defaultServiceId', value);
}
});
});
})(); })();
//=================== DeviceInfo ==================== //=================== DeviceInfo ====================

View File

@ -1327,16 +1327,6 @@ window.addEventListener('ContentStart', function update_onContentStart() {
}, 'volume-state-changed', false); }, 'volume-state-changed', false);
})(); })();
Services.obs.addObserver(function(aSubject, aTopic, aData) {
let data = JSON.parse(aData);
shell.sendChromeEvent({
type: "activity-done",
success: data.success,
manifestURL: data.manifestURL,
pageURL: data.pageURL
});
}, "activity-done", false);
#ifdef MOZ_WIDGET_GONK #ifdef MOZ_WIDGET_GONK
// Devices don't have all the same partition size for /cache where we // Devices don't have all the same partition size for /cache where we
// store the http cache. // store the http cache.

View File

@ -1,4 +1,4 @@
{ {
"revision": "20e3f42ccb6073c6d9bc9741de3a19a939a8a7d8", "revision": "e3564b8656fcd189d4a83379e94bef1ab7d657b5",
"repo_path": "/integration/gaia-central" "repo_path": "/integration/gaia-central"
} }

View File

@ -301,12 +301,10 @@ let Activities = {
case "Activity:PostResult": case "Activity:PostResult":
caller.mm.sendAsyncMessage("Activity:FireSuccess", msg); caller.mm.sendAsyncMessage("Activity:FireSuccess", msg);
Services.obs.notifyObservers(null, "activity-done", obsData);
delete this.callers[msg.id]; delete this.callers[msg.id];
break; break;
case "Activity:PostError": case "Activity:PostError":
caller.mm.sendAsyncMessage("Activity:FireError", msg); caller.mm.sendAsyncMessage("Activity:FireError", msg);
Services.obs.notifyObservers(null, "activity-done", obsData);
delete this.callers[msg.id]; delete this.callers[msg.id];
break; break;

View File

@ -9,6 +9,7 @@ const Ci = Components.interfaces;
const Cu = Components.utils; const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "cpmm", XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1", "@mozilla.org/childprocessmessagemanager;1",
@ -53,6 +54,7 @@ ActivityRequestHandler.prototype = {
"id": this._id, "id": this._id,
"result": aResult "result": aResult
}); });
Services.obs.notifyObservers(null, "activity-success", this._id);
}, },
postError: function arh_postError(aError) { postError: function arh_postError(aError) {
@ -60,6 +62,7 @@ ActivityRequestHandler.prototype = {
"id": this._id, "id": this._id,
"error": aError "error": aError
}); });
Services.obs.notifyObservers(null, "activity-error", this._id);
}, },
classID: Components.ID("{9326952a-dbe3-4d81-a51f-d9c160d96d6b}"), classID: Components.ID("{9326952a-dbe3-4d81-a51f-d9c160d96d6b}"),

View File

@ -50,21 +50,36 @@ ActivityWrapper.prototype = {
let observer = { let observer = {
observe: function(aSubject, aTopic, aData) { observe: function(aSubject, aTopic, aData) {
if (aTopic !== "inner-window-destroyed") {
return;
}
let wId = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data; switch (aTopic) {
if (wId == innerWindowID) { case 'inner-window-destroyed':
debug("Closing activity window " + innerWindowID); let wId = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data;
Services.obs.removeObserver(observer, "inner-window-destroyed"); if (wId == innerWindowID) {
cpmm.sendAsyncMessage("Activity:PostError", debug("Closing activity window " + innerWindowID);
{ id: aMessage.id, Services.obs.removeObserver(observer, "inner-window-destroyed");
error: "ActivityCanceled" }); cpmm.sendAsyncMessage("Activity:PostError",
{ id: aMessage.id,
error: "ActivityCanceled"
});
}
break;
case 'activity-error':
case 'activity-success':
if (aData !== aMessage.id) {
return;
}
Services.obs.removeObserver(observer, "activity-error");
Services.obs.removeObserver(observer, "activity-success");
let docshell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation);
Services.obs.notifyObservers(docshell, "activity-done", aTopic);
break;
} }
} }
} }
Services.obs.addObserver(observer, "activity-error", false);
Services.obs.addObserver(observer, "activity-success", false);
Services.obs.addObserver(observer, "inner-window-destroyed", false); Services.obs.addObserver(observer, "inner-window-destroyed", false);
return handler; return handler;
}, },

View File

@ -265,12 +265,18 @@ BrowserElementChild.prototype = {
Services.obs.addObserver(this, Services.obs.addObserver(this,
'xpcom-shutdown', 'xpcom-shutdown',
/* ownsWeak = */ true); /* ownsWeak = */ true);
Services.obs.addObserver(this,
'activity-done',
/* ownsWeak = */ true);
}, },
observe: function(subject, topic, data) { observe: function(subject, topic, data) {
// Ignore notifications not about our document. (Note that |content| /can/ // Ignore notifications not about our document. (Note that |content| /can/
// be null; see bug 874900.) // be null; see bug 874900.)
if (!content || subject != content.document) if (topic !== 'activity-done' && (!content || subject != content.document))
return;
if (topic == 'activity-done' && docShell !== subject)
return; return;
switch (topic) { switch (topic) {
case 'fullscreen-origin-change': case 'fullscreen-origin-change':
@ -282,6 +288,9 @@ BrowserElementChild.prototype = {
case 'ask-parent-to-rollback-fullscreen': case 'ask-parent-to-rollback-fullscreen':
sendAsyncMsg('rollback-fullscreen'); sendAsyncMsg('rollback-fullscreen');
break; break;
case 'activity-done':
sendAsyncMsg('activitydone', { success: (data == 'activity-success') });
break;
case 'xpcom-shutdown': case 'xpcom-shutdown':
this._shuttingDown = true; this._shuttingDown = true;
break; break;

View File

@ -127,6 +127,7 @@ function BrowserElementParent(frameLoader, hasRemoteFrame) {
"iconchange": this._fireEventFromMsg, "iconchange": this._fireEventFromMsg,
"close": this._fireEventFromMsg, "close": this._fireEventFromMsg,
"resize": this._fireEventFromMsg, "resize": this._fireEventFromMsg,
"activitydone": this._fireEventFromMsg,
"opensearch": this._fireEventFromMsg, "opensearch": this._fireEventFromMsg,
"securitychange": this._fireEventFromMsg, "securitychange": this._fireEventFromMsg,
"error": this._fireEventFromMsg, "error": this._fireEventFromMsg,

View File

@ -12,9 +12,11 @@ interface nsIDOMBlob;
#define MMS_SERVICE_CONTRACTID "@mozilla.org/mms/mmsservice;1" #define MMS_SERVICE_CONTRACTID "@mozilla.org/mms/mmsservice;1"
%} %}
[scriptable, uuid(e5ef630a-eab7-425a-ac42-650ef5c4fcef)] [scriptable, uuid(5dc8b3bc-c3a9-45ea-8ee0-7562b0e57257)]
interface nsIMmsService : nsISupports interface nsIMmsService : nsISupports
{ {
readonly attribute unsigned long mmsDefaultServiceId;
void send(in jsval parameters /* MmsParameters */, void send(in jsval parameters /* MmsParameters */,
in nsIMobileMessageCallback request); in nsIMobileMessageCallback request);

View File

@ -13,9 +13,11 @@ interface nsIMobileMessageCallback;
#define SMS_SERVICE_CONTRACTID "@mozilla.org/sms/smsservice;1" #define SMS_SERVICE_CONTRACTID "@mozilla.org/sms/smsservice;1"
%} %}
[scriptable, builtinclass, uuid(0f3f75ec-00dd-11e3-87ac-0b1d5c79afdf)] [scriptable, builtinclass, uuid(ec3221fb-2d4a-4ccd-ac64-65c1b2dee5dd)]
interface nsISmsService : nsISupports interface nsISmsService : nsISupports
{ {
readonly attribute unsigned long smsDefaultServiceId;
boolean hasSupport(); boolean hasSupport();
void getSegmentInfoForText(in DOMString text, void getSegmentInfoForText(in DOMString text,

View File

@ -14,6 +14,13 @@ namespace mobilemessage {
NS_IMPL_ISUPPORTS1(MmsService, nsIMmsService) NS_IMPL_ISUPPORTS1(MmsService, nsIMmsService)
NS_IMETHODIMP
MmsService::GetMmsDefaultServiceId(uint32_t* aServiceId)
{
NS_NOTYETIMPLEMENTED("Implement me!");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP NS_IMETHODIMP
MmsService::Send(const JS::Value& aParameters, MmsService::Send(const JS::Value& aParameters,
nsIMobileMessageCallback *aRequest) nsIMobileMessageCallback *aRequest)

View File

@ -15,6 +15,14 @@ namespace mobilemessage {
NS_IMPL_ISUPPORTS1(SmsService, nsISmsService) NS_IMPL_ISUPPORTS1(SmsService, nsISmsService)
NS_IMETHODIMP
SmsService::GetSmsDefaultServiceId(uint32_t* aServiceId)
{
// Android has no official DSDS support.
*aServiceId = 0;
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
SmsService::HasSupport(bool* aHasSupport) SmsService::HasSupport(bool* aHasSupport)
{ {

View File

@ -13,6 +13,13 @@ namespace mobilemessage {
NS_IMPL_ISUPPORTS1(MmsService, nsIMmsService) NS_IMPL_ISUPPORTS1(MmsService, nsIMmsService)
NS_IMETHODIMP
MmsService::GetMmsDefaultServiceId(uint32_t* aServiceId)
{
NS_NOTYETIMPLEMENTED("Implement me!");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP NS_IMETHODIMP
MmsService::Send(const JS::Value& aParameters, MmsService::Send(const JS::Value& aParameters,
nsIMobileMessageCallback *aRequest) nsIMobileMessageCallback *aRequest)

View File

@ -14,6 +14,13 @@ namespace mobilemessage {
NS_IMPL_ISUPPORTS1(SmsService, nsISmsService) NS_IMPL_ISUPPORTS1(SmsService, nsISmsService)
NS_IMETHODIMP
SmsService::GetSmsDefaultServiceId(uint32_t* aServiceId)
{
NS_ERROR("We should not be here!");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP NS_IMETHODIMP
SmsService::HasSupport(bool* aHasSupport) SmsService::HasSupport(bool* aHasSupport)
{ {

View File

@ -33,9 +33,8 @@ const kSmsRetrievingObserverTopic = "sms-retrieving";
const kSmsDeliverySuccessObserverTopic = "sms-delivery-success"; const kSmsDeliverySuccessObserverTopic = "sms-delivery-success";
const kSmsDeliveryErrorObserverTopic = "sms-delivery-error"; const kSmsDeliveryErrorObserverTopic = "sms-delivery-error";
const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown";
const kNetworkInterfaceStateChangedTopic = "network-interface-state-changed"; const kNetworkInterfaceStateChangedTopic = "network-interface-state-changed";
const kXpcomShutdownObserverTopic = "xpcom-shutdown";
const kPrefenceChangedObserverTopic = "nsPref:changed";
const kMobileMessageDeletedObserverTopic = "mobile-message-deleted"; const kMobileMessageDeletedObserverTopic = "mobile-message-deleted";
// HTTP status codes: // HTTP status codes:
@ -59,17 +58,18 @@ const CONFIG_SEND_REPORT_DEFAULT_NO = 1;
const CONFIG_SEND_REPORT_DEFAULT_YES = 2; const CONFIG_SEND_REPORT_DEFAULT_YES = 2;
const CONFIG_SEND_REPORT_ALWAYS = 3; const CONFIG_SEND_REPORT_ALWAYS = 3;
const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
const TIME_TO_BUFFER_MMS_REQUESTS = 30000; const TIME_TO_BUFFER_MMS_REQUESTS = 30000;
const PREF_TIME_TO_RELEASE_MMS_CONNECTION = const PREF_TIME_TO_RELEASE_MMS_CONNECTION =
Services.prefs.getIntPref("network.gonk.ms-release-mms-connection"); Services.prefs.getIntPref("network.gonk.ms-release-mms-connection");
const PREF_RETRIEVAL_MODE = 'dom.mms.retrieval_mode'; const kPrefRetrievalMode = 'dom.mms.retrieval_mode';
const RETRIEVAL_MODE_MANUAL = "manual"; const RETRIEVAL_MODE_MANUAL = "manual";
const RETRIEVAL_MODE_AUTOMATIC = "automatic"; const RETRIEVAL_MODE_AUTOMATIC = "automatic";
const RETRIEVAL_MODE_AUTOMATIC_HOME = "automatic-home"; const RETRIEVAL_MODE_AUTOMATIC_HOME = "automatic-home";
const RETRIEVAL_MODE_NEVER = "never"; const RETRIEVAL_MODE_NEVER = "never";
//Internal const values. //Internal const values.
const DELIVERY_RECEIVED = "received"; const DELIVERY_RECEIVED = "received";
const DELIVERY_NOT_DOWNLOADED = "not-downloaded"; const DELIVERY_NOT_DOWNLOADED = "not-downloaded";
@ -108,6 +108,9 @@ const PREF_RETRIEVAL_RETRY_INTERVALS = (function () {
return intervals; return intervals;
})(); })();
const kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
const kPrefDefaultServiceId = "dom.mms.defaultServiceId";
XPCOMUtils.defineLazyServiceGetter(this, "gpps", XPCOMUtils.defineLazyServiceGetter(this, "gpps",
"@mozilla.org/network/protocol-proxy-service;1", "@mozilla.org/network/protocol-proxy-service;1",
"nsIProtocolProxyService"); "nsIProtocolProxyService");
@ -197,7 +200,7 @@ XPCOMUtils.defineLazyGetter(this, "gMmsConnection", function () {
init: function init() { init: function init() {
Services.obs.addObserver(this, kNetworkInterfaceStateChangedTopic, Services.obs.addObserver(this, kNetworkInterfaceStateChangedTopic,
false); false);
Services.obs.addObserver(this, kXpcomShutdownObserverTopic, false); Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
this.settings.forEach(function(name) { this.settings.forEach(function(name) {
Services.prefs.addObserver(name, this, false); Services.prefs.addObserver(name, this, false);
}, this); }, this);
@ -341,10 +344,9 @@ XPCOMUtils.defineLazyGetter(this, "gMmsConnection", function () {
}, },
shutdown: function shutdown() { shutdown: function shutdown() {
Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
Services.obs.removeObserver(this, kNetworkInterfaceStateChangedTopic); Services.obs.removeObserver(this, kNetworkInterfaceStateChangedTopic);
this.settings.forEach(function(name) {
Services.prefs.removeObserver(name, this);
}, this);
this.connectTimer.cancel(); this.connectTimer.cancel();
this.flushPendingCallbacks(_HTTP_STATUS_RADIO_DISABLED); this.flushPendingCallbacks(_HTTP_STATUS_RADIO_DISABLED);
this.disconnectTimer.cancel(); this.disconnectTimer.cancel();
@ -370,7 +372,7 @@ XPCOMUtils.defineLazyGetter(this, "gMmsConnection", function () {
this.flushPendingCallbacks(_HTTP_STATUS_ACQUIRE_CONNECTION_SUCCESS) this.flushPendingCallbacks(_HTTP_STATUS_ACQUIRE_CONNECTION_SUCCESS)
break; break;
} }
case kPrefenceChangedObserverTopic: { case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID: {
if (data == "ril.radio.disabled") { if (data == "ril.radio.disabled") {
try { try {
this.radioDisabled = Services.prefs.getBoolPref("ril.radio.disabled"); this.radioDisabled = Services.prefs.getBoolPref("ril.radio.disabled");
@ -404,8 +406,7 @@ XPCOMUtils.defineLazyGetter(this, "gMmsConnection", function () {
} }
break; break;
} }
case kXpcomShutdownObserverTopic: { case NS_XPCOM_SHUTDOWN_OBSERVER_ID: {
Services.obs.removeObserver(this, kXpcomShutdownObserverTopic);
this.shutdown(); this.shutdown();
} }
} }
@ -757,7 +758,7 @@ CancellableTransaction.prototype = {
registerRunCallback: function registerRunCallback(callback) { registerRunCallback: function registerRunCallback(callback) {
if (!this.isObserversAdded) { if (!this.isObserversAdded) {
Services.obs.addObserver(this, kXpcomShutdownObserverTopic, false); Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
Services.obs.addObserver(this, kMobileMessageDeletedObserverTopic, false); Services.obs.addObserver(this, kMobileMessageDeletedObserverTopic, false);
this.isObserversAdded = true; this.isObserversAdded = true;
} }
@ -768,7 +769,7 @@ CancellableTransaction.prototype = {
removeObservers: function removeObservers() { removeObservers: function removeObservers() {
if (this.isObserversAdded) { if (this.isObserversAdded) {
Services.obs.removeObserver(this, kXpcomShutdownObserverTopic); Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
Services.obs.removeObserver(this, kMobileMessageDeletedObserverTopic); Services.obs.removeObserver(this, kMobileMessageDeletedObserverTopic);
this.isObserversAdded = false; this.isObserversAdded = false;
} }
@ -811,7 +812,7 @@ CancellableTransaction.prototype = {
observe: function observe(subject, topic, data) { observe: function observe(subject, topic, data) {
switch (topic) { switch (topic) {
case kXpcomShutdownObserverTopic: { case NS_XPCOM_SHUTDOWN_OBSERVER_ID: {
this.cancelRunning(); this.cancelRunning();
break; break;
} }
@ -1191,6 +1192,17 @@ AcknowledgeTransaction.prototype = {
} }
}; };
function getDefaultServiceId() {
let id = Services.prefs.getIntPref(kPrefDefaultServiceId);
let numRil = Services.prefs.getIntPref(kPrefRilNumRadioInterfaces);
if (id >= numRil || id < 0) {
id = 0;
}
return id;
}
/** /**
* MmsService * MmsService
*/ */
@ -1201,13 +1213,17 @@ function MmsService() {
debug("Running protocol version: " + macro + "." + minor); debug("Running protocol version: " + macro + "." + minor);
} }
Services.prefs.addObserver(kPrefDefaultServiceId, this, false);
this.mmsDefaultServiceId = getDefaultServiceId();
// TODO: bug 810084 - support application identifier // TODO: bug 810084 - support application identifier
} }
MmsService.prototype = { MmsService.prototype = {
classID: RIL_MMSSERVICE_CID, classID: RIL_MMSSERVICE_CID,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMmsService, QueryInterface: XPCOMUtils.generateQI([Ci.nsIMmsService,
Ci.nsIWapPushApplication]), Ci.nsIWapPushApplication,
Ci.nsIObserver]),
/* /*
* Whether or not should we enable X-Mms-Report-Allowed in M-NotifyResp.ind * Whether or not should we enable X-Mms-Report-Allowed in M-NotifyResp.ind
* and M-Acknowledge.ind PDU. * and M-Acknowledge.ind PDU.
@ -1584,7 +1600,7 @@ MmsService.prototype = {
let retrievalMode = RETRIEVAL_MODE_MANUAL; let retrievalMode = RETRIEVAL_MODE_MANUAL;
try { try {
retrievalMode = Services.prefs.getCharPref(PREF_RETRIEVAL_MODE); retrievalMode = Services.prefs.getCharPref(kPrefRetrievalMode);
} catch (e) {} } catch (e) {}
let savableMessage = this.convertIntermediateToSavable(notification, retrievalMode); let savableMessage = this.convertIntermediateToSavable(notification, retrievalMode);
@ -1803,6 +1819,8 @@ MmsService.prototype = {
// nsIMmsService // nsIMmsService
mmsDefaultServiceId: 0,
send: function send(aParams, aRequest) { send: function send(aParams, aRequest) {
if (DEBUG) debug("send: aParams: " + JSON.stringify(aParams)); if (DEBUG) debug("send: aParams: " + JSON.stringify(aParams));
@ -2113,6 +2131,18 @@ MmsService.prototype = {
break; break;
} }
}, },
// nsIObserver
observe: function observe(aSubject, aTopic, aData) {
switch (aTopic) {
case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
if (aData === kPrefDefaultServiceId) {
this.mmsDefaultServiceId = getDefaultServiceId();
}
break;
}
}
}; };
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MmsService]); this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MmsService]);

View File

@ -7,13 +7,40 @@
#include "SmsService.h" #include "SmsService.h"
#include "jsapi.h" #include "jsapi.h"
#include "SmsSegmentInfo.h" #include "SmsSegmentInfo.h"
#include "mozilla/Preferences.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
namespace {
const char* kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
#define kPrefDefaultServiceId "dom.sms.defaultServiceId"
const char* kObservedPrefs[] = {
kPrefDefaultServiceId,
nullptr
};
uint32_t
getDefaultServiceId()
{
int32_t id = mozilla::Preferences::GetInt(kPrefDefaultServiceId, 0);
int32_t numRil = mozilla::Preferences::GetInt(kPrefRilNumRadioInterfaces, 1);
if (id >= numRil || id < 0) {
id = 0;
}
return id;
}
} // Anonymous namespace
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
namespace mobilemessage { namespace mobilemessage {
NS_IMPL_ISUPPORTS1(SmsService, nsISmsService) NS_IMPL_ISUPPORTS2(SmsService,
nsISmsService,
nsIObserver)
SmsService::SmsService() SmsService::SmsService()
{ {
@ -22,6 +49,42 @@ SmsService::SmsService()
ril->GetRadioInterface(0, getter_AddRefs(mRadioInterface)); ril->GetRadioInterface(0, getter_AddRefs(mRadioInterface));
} }
NS_WARN_IF_FALSE(mRadioInterface, "This shouldn't fail!"); NS_WARN_IF_FALSE(mRadioInterface, "This shouldn't fail!");
// Initialize observer.
Preferences::AddStrongObservers(this, kObservedPrefs);
mDefaultServiceId = getDefaultServiceId();
}
/*
* Implementation of nsIObserver.
*/
NS_IMETHODIMP
SmsService::Observe(nsISupports* aSubject,
const char* aTopic,
const PRUnichar* aData)
{
if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
nsDependentString data(aData);
if (data.EqualsLiteral(kPrefDefaultServiceId)) {
mDefaultServiceId = getDefaultServiceId();
}
return NS_OK;
}
MOZ_ASSERT(false, "SmsService got unexpected topic!");
return NS_ERROR_UNEXPECTED;
}
/*
* Implementation of nsISmsService.
*/
NS_IMETHODIMP
SmsService::GetSmsDefaultServiceId(uint32_t* aServiceId)
{
*aServiceId = mDefaultServiceId;
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -7,6 +7,7 @@
#include "nsISmsService.h" #include "nsISmsService.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIObserver.h"
#include "nsIRadioInterfaceLayer.h" #include "nsIRadioInterfaceLayer.h"
#include "nsTArray.h" #include "nsTArray.h"
#include "nsString.h" #include "nsString.h"
@ -17,16 +18,20 @@ namespace dom {
namespace mobilemessage { namespace mobilemessage {
class SmsService MOZ_FINAL : public nsISmsService class SmsService MOZ_FINAL : public nsISmsService
, public nsIObserver
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSISMSSERVICE NS_DECL_NSISMSSERVICE
NS_DECL_NSIOBSERVER
SmsService(); SmsService();
protected: protected:
// TODO: Bug 854326 - B2G Multi-SIM: support multiple SIM cards for SMS/MMS // TODO: Bug 854326 - B2G Multi-SIM: support multiple SIM cards for SMS/MMS
nsCOMPtr<nsIRadioInterface> mRadioInterface; nsCOMPtr<nsIRadioInterface> mRadioInterface;
nsTArray<nsString> mSilentNumbers; nsTArray<nsString> mSilentNumbers;
uint32_t mDefaultServiceId;
}; };
} // namespace mobilemessage } // namespace mobilemessage

View File

@ -17,12 +17,23 @@
#include "mozilla/dom/MobileMessageManagerBinding.h" #include "mozilla/dom/MobileMessageManagerBinding.h"
#include "mozilla/dom/MozMmsMessageBinding.h" #include "mozilla/dom/MozMmsMessageBinding.h"
#include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/BindingUtils.h"
#include "mozilla/Preferences.h"
#include "nsString.h"
using namespace mozilla::dom; using namespace mozilla::dom;
using namespace mozilla::dom::mobilemessage; using namespace mozilla::dom::mobilemessage;
namespace { namespace {
const char* kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
#define kPrefMmsDefaultServiceId "dom.mms.defaultServiceId"
#define kPrefSmsDefaultServiceId "dom.sms.defaultServiceId"
const char* kObservedPrefs[] = {
kPrefMmsDefaultServiceId,
kPrefSmsDefaultServiceId,
nullptr
};
// TODO: Bug 767082 - WebSMS: sSmsChild leaks at shutdown // TODO: Bug 767082 - WebSMS: sSmsChild leaks at shutdown
PSmsChild* gSmsChild; PSmsChild* gSmsChild;
@ -74,16 +85,69 @@ SendCursorRequest(const IPCMobileMessageCursor& aRequest,
actor.forget(aResult); actor.forget(aResult);
return NS_OK; return NS_OK;
} }
uint32_t
getDefaultServiceId(const char* aPrefKey)
{
int32_t id = mozilla::Preferences::GetInt(aPrefKey, 0);
int32_t numRil = mozilla::Preferences::GetInt(kPrefRilNumRadioInterfaces, 1);
if (id >= numRil || id < 0) {
id = 0;
}
return id;
}
} // anonymous namespace } // anonymous namespace
NS_IMPL_ISUPPORTS3(SmsIPCService, NS_IMPL_ISUPPORTS4(SmsIPCService,
nsISmsService, nsISmsService,
nsIMmsService, nsIMmsService,
nsIMobileMessageDatabaseService) nsIMobileMessageDatabaseService,
nsIObserver)
SmsIPCService::SmsIPCService()
{
Preferences::AddStrongObservers(this, kObservedPrefs);
mMmsDefaultServiceId = getDefaultServiceId(kPrefMmsDefaultServiceId);
mSmsDefaultServiceId = getDefaultServiceId(kPrefSmsDefaultServiceId);
}
/*
* Implementation of nsIObserver.
*/
NS_IMETHODIMP
SmsIPCService::Observe(nsISupports* aSubject,
const char* aTopic,
const PRUnichar* aData)
{
if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
nsDependentString data(aData);
if (data.EqualsLiteral(kPrefMmsDefaultServiceId)) {
mMmsDefaultServiceId = getDefaultServiceId(kPrefMmsDefaultServiceId);
} else if (data.EqualsLiteral(kPrefSmsDefaultServiceId)) {
mSmsDefaultServiceId = getDefaultServiceId(kPrefSmsDefaultServiceId);
}
return NS_OK;
}
MOZ_ASSERT(false, "SmsIPCService got unexpected topic!");
return NS_ERROR_UNEXPECTED;
}
/* /*
* Implementation of nsISmsService. * Implementation of nsISmsService.
*/ */
NS_IMETHODIMP
SmsIPCService::GetSmsDefaultServiceId(uint32_t* aServiceId)
{
*aServiceId = mSmsDefaultServiceId;
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
SmsIPCService::HasSupport(bool* aHasSupport) SmsIPCService::HasSupport(bool* aHasSupport)
{ {
@ -236,6 +300,17 @@ GetSendMmsMessageRequestFromParams(const JS::Value& aParam,
return true; return true;
} }
/*
* Implementation of nsIMmsService.
*/
NS_IMETHODIMP
SmsIPCService::GetMmsDefaultServiceId(uint32_t* aServiceId)
{
*aServiceId = mMmsDefaultServiceId;
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
SmsIPCService::Send(const JS::Value& aParameters, SmsIPCService::Send(const JS::Value& aParameters,
nsIMobileMessageCallback *aRequest) nsIMobileMessageCallback *aRequest)

View File

@ -9,6 +9,7 @@
#include "nsISmsService.h" #include "nsISmsService.h"
#include "nsIMmsService.h" #include "nsIMmsService.h"
#include "nsIMobileMessageDatabaseService.h" #include "nsIMobileMessageDatabaseService.h"
#include "nsIObserver.h"
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
namespace mozilla { namespace mozilla {
@ -20,12 +21,20 @@ class PSmsChild;
class SmsIPCService MOZ_FINAL : public nsISmsService class SmsIPCService MOZ_FINAL : public nsISmsService
, public nsIMmsService , public nsIMmsService
, public nsIMobileMessageDatabaseService , public nsIMobileMessageDatabaseService
, public nsIObserver
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSISMSSERVICE NS_DECL_NSISMSSERVICE
NS_DECL_NSIMMSSERVICE NS_DECL_NSIMMSSERVICE
NS_DECL_NSIMOBILEMESSAGEDATABASESERVICE NS_DECL_NSIMOBILEMESSAGEDATABASESERVICE
NS_DECL_NSIOBSERVER
SmsIPCService();
private:
uint32_t mMmsDefaultServiceId;
uint32_t mSmsDefaultServiceId;
}; };
} // namespace mobilemessage } // namespace mobilemessage

View File

@ -36,3 +36,4 @@ qemu = true
[test_invalid_address.js] [test_invalid_address.js]
[test_mmsmessage_attachments.js] [test_mmsmessage_attachments.js]
[test_getthreads.js] [test_getthreads.js]
[test_dsds_default_service_id.js]

View File

@ -0,0 +1,130 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_CONTEXT = "chrome";
Cu.import("resource://gre/modules/Promise.jsm");
const MMS_SERVICE_CONTRACTID = "@mozilla.org/mms/mmsservice;1";
const SMS_SERVICE_CONTRACTID = "@mozilla.org/sms/smsservice;1";
const PREF_RIL_NUM_RADIO_INTERFACES = "ril.numRadioInterfaces";
const PREF_MMS_DEFAULT_SERVICE_ID = "dom.mms.defaultServiceId";
const PREF_SMS_DEFAULT_SERVICE_ID = "dom.sms.defaultServiceId";
function setPrefAndVerify(prefKey, setVal, service, attrName, expectedVal, deferred) {
log(" Set '" + prefKey + "' to " + setVal);
Services.prefs.setIntPref(prefKey, setVal);
let prefVal = Services.prefs.getIntPref(prefKey);
is(prefVal, setVal, "'" + prefKey + "' set to " + setVal);
window.setTimeout(function () {
let defaultVal = service[attrName];
is(defaultVal, expectedVal, attrName);
deferred.resolve(service);
}, 0);
}
function getNumRadioInterfaces() {
let deferred = Promise.defer();
window.setTimeout(function () {
let numRil = Services.prefs.getIntPref(PREF_RIL_NUM_RADIO_INTERFACES);
log("numRil = " + numRil);
deferred.resolve(numRil);
}, 0);
return deferred.promise;
}
function getService(contractId, ifaceName) {
let deferred = Promise.defer();
window.setTimeout(function () {
log("Getting service for " + ifaceName);
let service = Cc[contractId].getService(Ci[ifaceName]);
ok(service, "service.constructor is " + service.constructor);
deferred.resolve(service);
}, 0);
return deferred.promise;
}
function checkInitialEquality(attrName, prefKey, service) {
let deferred = Promise.defer();
log(" Checking initial value for '" + prefKey + "'");
let origPrefVal = Services.prefs.getIntPref(prefKey);
ok(isFinite(origPrefVal), "default '" + prefKey + "' value");
window.setTimeout(function () {
let defaultVal = service[attrName];
is(defaultVal, origPrefVal, attrName);
deferred.resolve(service);
}, 0);
return deferred.promise;
}
function checkSetToNegtiveValue(attrName, prefKey, service) {
let deferred = Promise.defer();
// Set to -1 and verify defaultVal == 0.
setPrefAndVerify(prefKey, -1, service, attrName, 0, deferred);
return deferred.promise;
}
function checkSetToOverflowedValue(attrName, prefKey, numRil, service) {
let deferred = Promise.defer();
// Set to larger-equal than numRil and verify defaultVal == 0.
setPrefAndVerify(prefKey, numRil, service, attrName, 0, deferred);
return deferred.promise;
}
function checkValueChange(attrName, prefKey, numRil, service) {
let deferred = Promise.defer();
if (numRil > 1) {
// Set to (numRil - 1) and verify defaultVal equals.
setPrefAndVerify(prefKey, numRil - 1, service, attrName, numRil - 1, deferred);
} else {
window.setTimeout(function () {
deferred.resolve(service);
}, 0);
}
return deferred.promise;
}
function verify(contractId, ifaceName, attrName, prefKey, numRil) {
let deferred = Promise.defer();
getService(contractId, ifaceName)
.then(checkInitialEquality.bind(null, attrName, prefKey))
.then(checkSetToNegtiveValue.bind(null, attrName, prefKey))
.then(checkSetToOverflowedValue.bind(null, attrName, prefKey, numRil))
.then(checkValueChange.bind(null, attrName, prefKey, numRil))
.then(function () {
// Reset.
Services.prefs.clearUserPref(prefKey);
deferred.resolve(numRil);
});
return deferred.promise;
}
getNumRadioInterfaces()
.then(verify.bind(null, MMS_SERVICE_CONTRACTID, "nsIMmsService",
"mmsDefaultServiceId", PREF_MMS_DEFAULT_SERVICE_ID))
.then(verify.bind(null, SMS_SERVICE_CONTRACTID, "nsISmsService",
"smsDefaultServiceId", PREF_SMS_DEFAULT_SERVICE_ID))
.then(finish);

View File

@ -25,22 +25,17 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
var RIL = {}; var RIL = {};
Cu.import("resource://gre/modules/ril_consts.js", RIL); Cu.import("resource://gre/modules/ril_consts.js", RIL);
// set to true to in ril_consts.js to see debug messages const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown";
var DEBUG = RIL.DEBUG_CONTENT_HELPER;
// Read debug setting from pref const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
try {
let debugPref = Services.prefs.getBoolPref("ril.debugging.enabled");
DEBUG = RIL.DEBUG_CONTENT_HELPER || debugPref;
} catch (e) {}
let debug; const kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
if (DEBUG) { const kPrefRilDebuggingEnabled = "ril.debugging.enabled";
debug = function (s) { const kPrefVoicemailDefaultServiceId = "dom.voicemail.defaultServiceId";
dump("-*- RILContentHelper: " + s + "\n");
}; let DEBUG;
} else { function debug(s) {
debug = function (s) {}; dump("-*- RILContentHelper: " + s + "\n");
} }
const RILCONTENTHELPER_CID = const RILCONTENTHELPER_CID =
@ -126,8 +121,7 @@ XPCOMUtils.defineLazyGetter(this, "gNumRadioInterfaces", function () {
return ril.numRadioInterfaces; return ril.numRadioInterfaces;
} }
let num = cpmm.sendSyncMessage("RIL:GetNumRadioInterfaces")[0]; return Services.prefs.getIntPref(kPrefRilNumRadioInterfaces);
return num;
}); });
function MobileIccCardLockResult(options) { function MobileIccCardLockResult(options) {
@ -449,6 +443,8 @@ IccCardLockError.prototype = {
}; };
function RILContentHelper() { function RILContentHelper() {
this.updateDebugFlag();
this.rilContext = { this.rilContext = {
cardState: RIL.GECKO_CARDSTATE_UNKNOWN, cardState: RIL.GECKO_CARDSTATE_UNKNOWN,
networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN, networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN,
@ -457,10 +453,15 @@ function RILContentHelper() {
dataConnectionInfo: new MobileConnectionInfo() dataConnectionInfo: new MobileConnectionInfo()
}; };
this.voicemailInfo = new VoicemailInfo(); this.voicemailInfo = new VoicemailInfo();
this.voicemailDefaultServiceId = this.getVoicemailDefaultServiceId();
this.initDOMRequestHelper(/* aWindow */ null, RIL_IPC_MSG_NAMES); this.initDOMRequestHelper(/* aWindow */ null, RIL_IPC_MSG_NAMES);
this._windowsMap = []; this._windowsMap = [];
Services.obs.addObserver(this, "xpcom-shutdown", false);
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
Services.prefs.addObserver(kPrefRilDebuggingEnabled, this, false);
Services.prefs.addObserver(kPrefVoicemailDefaultServiceId, this, false);
} }
RILContentHelper.prototype = { RILContentHelper.prototype = {
@ -480,6 +481,13 @@ RILContentHelper.prototype = {
Ci.nsIVoicemailProvider, Ci.nsIVoicemailProvider,
Ci.nsIIccProvider]}), Ci.nsIIccProvider]}),
updateDebugFlag: function updateDebugFlag() {
try {
DEBUG = RIL.DEBUG_CONTENT_HELPER ||
Services.prefs.getBoolPref(kPrefRilDebuggingEnabled);
} catch (e) {}
},
// An utility function to copy objects. // An utility function to copy objects.
updateInfo: function updateInfo(srcInfo, destInfo) { updateInfo: function updateInfo(srcInfo, destInfo) {
for (let key in srcInfo) { for (let key in srcInfo) {
@ -1313,6 +1321,17 @@ RILContentHelper.prototype = {
voicemailStatus: null, voicemailStatus: null,
voicemailDefaultServiceId: 0,
getVoicemailDefaultServiceId: function getVoicemailDefaultServiceId() {
let id = Services.prefs.getIntPref(kPrefVoicemailDefaultServiceId);
if (id >= gNumRadioInterfaces || id < 0) {
id = 0;
}
return id;
},
getVoicemailInfo: function getVoicemailInfo() { getVoicemailInfo: function getVoicemailInfo() {
// Get voicemail infomation by IPC only on first time. // Get voicemail infomation by IPC only on first time.
this.getVoicemailInfo = function getVoicemailInfo() { this.getVoicemailInfo = function getVoicemailInfo() {
@ -1327,9 +1346,11 @@ RILContentHelper.prototype = {
return this.voicemailInfo; return this.voicemailInfo;
}, },
get voicemailNumber() { get voicemailNumber() {
return this.getVoicemailInfo().number; return this.getVoicemailInfo().number;
}, },
get voicemailDisplayName() { get voicemailDisplayName() {
return this.getVoicemailInfo().displayName; return this.getVoicemailInfo().displayName;
}, },
@ -1404,9 +1425,19 @@ RILContentHelper.prototype = {
// nsIObserver // nsIObserver
observe: function observe(subject, topic, data) { observe: function observe(subject, topic, data) {
if (topic == "xpcom-shutdown") { switch (topic) {
this.destroyDOMRequestHelper(); case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
Services.obs.removeObserver(this, "xpcom-shutdown"); if (data == kPrefRilDebuggingEnabled) {
this.updateDebugFlag();
} else if (data == kPrefVoicemailDefaultServiceId) {
this.voicemailDefaultServiceId = this.getVoicemailDefaultServiceId();
}
break;
case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
this.destroyDOMRequestHelper();
Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
break;
} }
}, },

View File

@ -52,6 +52,7 @@ const GSMICCINFO_CID =
const CDMAICCINFO_CID = const CDMAICCINFO_CID =
Components.ID("{39ba3c08-aacc-46d0-8c04-9b619c387061}"); Components.ID("{39ba3c08-aacc-46d0-8c04-9b619c387061}");
const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown";
const kNetworkInterfaceStateChangedTopic = "network-interface-state-changed"; const kNetworkInterfaceStateChangedTopic = "network-interface-state-changed";
const kSmsReceivedObserverTopic = "sms-received"; const kSmsReceivedObserverTopic = "sms-received";
const kSilentSmsReceivedObserverTopic = "silent-sms-received"; const kSilentSmsReceivedObserverTopic = "silent-sms-received";
@ -64,14 +65,18 @@ const kMozSettingsChangedObserverTopic = "mozsettings-changed";
const kSysMsgListenerReadyObserverTopic = "system-message-listener-ready"; const kSysMsgListenerReadyObserverTopic = "system-message-listener-ready";
const kSysClockChangeObserverTopic = "system-clock-change"; const kSysClockChangeObserverTopic = "system-clock-change";
const kScreenStateChangedTopic = "screen-state-changed"; const kScreenStateChangedTopic = "screen-state-changed";
const kClockAutoUpdateEnabled = "time.clock.automatic-update.enabled";
const kClockAutoUpdateAvailable = "time.clock.automatic-update.available"; const kSettingsCellBroadcastSearchList = "ril.cellbroadcast.searchlist";
const kTimezoneAutoUpdateEnabled = "time.timezone.automatic-update.enabled"; const kSettingsClockAutoUpdateEnabled = "time.clock.automatic-update.enabled";
const kTimezoneAutoUpdateAvailable = "time.timezone.automatic-update.available"; const kSettingsClockAutoUpdateAvailable = "time.clock.automatic-update.available";
const kCellBroadcastSearchList = "ril.cellbroadcast.searchlist"; const kSettingsTimezoneAutoUpdateEnabled = "time.timezone.automatic-update.enabled";
const kCellBroadcastDisabled = "ril.cellbroadcast.disabled"; const kSettingsTimezoneAutoUpdateAvailable = "time.timezone.automatic-update.available";
const kPrefenceChangedObserverTopic = "nsPref:changed";
const kClirModePreference = "ril.clirMode"; const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
const kPrefCellBroadcastDisabled = "ril.cellbroadcast.disabled";
const kPrefClirModePreference = "ril.clirMode";
const kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
const DOM_MOBILE_MESSAGE_DELIVERY_RECEIVED = "received"; const DOM_MOBILE_MESSAGE_DELIVERY_RECEIVED = "received";
const DOM_MOBILE_MESSAGE_DELIVERY_SENDING = "sending"; const DOM_MOBILE_MESSAGE_DELIVERY_SENDING = "sending";
@ -82,7 +87,6 @@ const RADIO_POWER_OFF_TIMEOUT = 30000;
const SMS_HANDLED_WAKELOCK_TIMEOUT = 5000; const SMS_HANDLED_WAKELOCK_TIMEOUT = 5000;
const RIL_IPC_MOBILECONNECTION_MSG_NAMES = [ const RIL_IPC_MOBILECONNECTION_MSG_NAMES = [
"RIL:GetNumRadioInterfaces",
"RIL:GetRilContext", "RIL:GetRilContext",
"RIL:GetAvailableNetworks", "RIL:GetAvailableNetworks",
"RIL:SelectNetwork", "RIL:SelectNetwork",
@ -107,7 +111,6 @@ const RIL_IPC_MOBILECONNECTION_MSG_NAMES = [
]; ];
const RIL_IPC_ICCMANAGER_MSG_NAMES = [ const RIL_IPC_ICCMANAGER_MSG_NAMES = [
"RIL:GetNumRadioInterfaces",
"RIL:SendStkResponse", "RIL:SendStkResponse",
"RIL:SendStkMenuSelection", "RIL:SendStkMenuSelection",
"RIL:SendStkTimerExpiration", "RIL:SendStkTimerExpiration",
@ -125,13 +128,11 @@ const RIL_IPC_ICCMANAGER_MSG_NAMES = [
]; ];
const RIL_IPC_VOICEMAIL_MSG_NAMES = [ const RIL_IPC_VOICEMAIL_MSG_NAMES = [
"RIL:GetNumRadioInterfaces",
"RIL:RegisterVoicemailMsg", "RIL:RegisterVoicemailMsg",
"RIL:GetVoicemailInfo" "RIL:GetVoicemailInfo"
]; ];
const RIL_IPC_CELLBROADCAST_MSG_NAMES = [ const RIL_IPC_CELLBROADCAST_MSG_NAMES = [
"RIL:GetNumRadioInterfaces",
"RIL:RegisterCellBroadcastMsg" "RIL:RegisterCellBroadcastMsg"
]; ];
@ -209,7 +210,7 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
init: function init(ril) { init: function init(ril) {
this.ril = ril; this.ril = ril;
Services.obs.addObserver(this, "xpcom-shutdown", false); Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
Services.obs.addObserver(this, kSysMsgListenerReadyObserverTopic, false); Services.obs.addObserver(this, kSysMsgListenerReadyObserverTopic, false);
this._registerMessageListeners(); this._registerMessageListeners();
}, },
@ -217,7 +218,7 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
_shutdown: function _shutdown() { _shutdown: function _shutdown() {
this.ril = null; this.ril = null;
Services.obs.removeObserver(this, "xpcom-shutdown"); Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
this._unregisterMessageListeners(); this._unregisterMessageListeners();
}, },
@ -395,8 +396,6 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
} }
switch (msg.name) { switch (msg.name) {
case "RIL:GetNumRadioInterfaces":
return this.ril.numRadioInterfaces;
case "RIL:RegisterMobileConnectionMsg": case "RIL:RegisterMobileConnectionMsg":
this._registerMessageTarget("mobileconnection", msg.target); this._registerMessageTarget("mobileconnection", msg.target);
return null; return null;
@ -431,7 +430,7 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
Services.obs.removeObserver(this, kSysMsgListenerReadyObserverTopic); Services.obs.removeObserver(this, kSysMsgListenerReadyObserverTopic);
this._resendQueuedTargetMessage(); this._resendQueuedTargetMessage();
break; break;
case "xpcom-shutdown": case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
this._shutdown(); this._shutdown();
break; break;
} }
@ -467,6 +466,25 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
}; };
}); });
// Initialize shared preference 'ril.numRadioInterfaces' according to system
// property.
try {
Services.prefs.setIntPref(kPrefRilNumRadioInterfaces, (function () {
// When Gonk property "ro.moz.ril.numclients" is not set, return 1; if
// explicitly set to any number larger-equal than 0, return num; else, return
// 1 for compatibility.
try {
let numString = libcutils.property_get("ro.moz.ril.numclients", "1");
let num = parseInt(numString, 10);
if (num >= 0) {
return num;
}
} catch (e) {}
return 1;
})());
} catch (e) {}
function IccInfo() {} function IccInfo() {}
IccInfo.prototype = { IccInfo.prototype = {
iccType: null, iccType: null,
@ -524,11 +542,11 @@ function RadioInterfaceLayer() {
try { try {
options.cellBroadcastDisabled = options.cellBroadcastDisabled =
Services.prefs.getBoolPref(kCellBroadcastDisabled); Services.prefs.getBoolPref(kPrefCellBroadcastDisabled);
} catch(e) {} } catch(e) {}
try { try {
options.clirMode = Services.prefs.getIntPref(kClirModePreference); options.clirMode = Services.prefs.getIntPref(kPrefClirModePreference);
} catch(e) {} } catch(e) {}
let numIfaces = this.numRadioInterfaces; let numIfaces = this.numRadioInterfaces;
@ -568,16 +586,9 @@ RadioInterfaceLayer.prototype = {
XPCOMUtils.defineLazyGetter(RadioInterfaceLayer.prototype, XPCOMUtils.defineLazyGetter(RadioInterfaceLayer.prototype,
"numRadioInterfaces", function () { "numRadioInterfaces", function () {
// When Gonk property "ro.moz.ril.numclients" is not set, return 1; if
// explicitly set to any number larger-equal than 0, return num; else, return
// 1 for compatibility.
try { try {
let numString = libcutils.property_get("ro.moz.ril.numclients", "1"); return Services.prefs.getIntPref(kPrefRilNumRadioInterfaces);
let num = parseInt(numString, 10); } catch(e) {}
if (num >= 0) {
return num;
}
} catch (e) {}
return 1; return 1;
}); });
@ -781,11 +792,11 @@ function RadioInterface(options) {
// Read the 'time.clock.automatic-update.enabled' setting to see if // Read the 'time.clock.automatic-update.enabled' setting to see if
// we need to adjust the system clock time by NITZ or SNTP. // we need to adjust the system clock time by NITZ or SNTP.
lock.get(kClockAutoUpdateEnabled, this); lock.get(kSettingsClockAutoUpdateEnabled, this);
// Read the 'time.timezone.automatic-update.enabled' setting to see if // Read the 'time.timezone.automatic-update.enabled' setting to see if
// we need to adjust the system timezone by NITZ. // we need to adjust the system timezone by NITZ.
lock.get(kTimezoneAutoUpdateEnabled, this); lock.get(kSettingsTimezoneAutoUpdateEnabled, this);
// Set "time.clock.automatic-update.available" to false when starting up. // Set "time.clock.automatic-update.available" to false when starting up.
this.setClockAutoUpdateAvailable(false); this.setClockAutoUpdateAvailable(false);
@ -795,16 +806,16 @@ function RadioInterface(options) {
// Read the Cell Broadcast Search List setting, string of integers or integer // Read the Cell Broadcast Search List setting, string of integers or integer
// ranges separated by comma, to set listening channels. // ranges separated by comma, to set listening channels.
lock.get(kCellBroadcastSearchList, this); lock.get(kSettingsCellBroadcastSearchList, this);
Services.obs.addObserver(this, "xpcom-shutdown", false); Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
Services.obs.addObserver(this, kMozSettingsChangedObserverTopic, false); Services.obs.addObserver(this, kMozSettingsChangedObserverTopic, false);
Services.obs.addObserver(this, kSysMsgListenerReadyObserverTopic, false); Services.obs.addObserver(this, kSysMsgListenerReadyObserverTopic, false);
Services.obs.addObserver(this, kSysClockChangeObserverTopic, false); Services.obs.addObserver(this, kSysClockChangeObserverTopic, false);
Services.obs.addObserver(this, kScreenStateChangedTopic, false); Services.obs.addObserver(this, kScreenStateChangedTopic, false);
Services.obs.addObserver(this, kNetworkInterfaceStateChangedTopic, false); Services.obs.addObserver(this, kNetworkInterfaceStateChangedTopic, false);
Services.prefs.addObserver(kCellBroadcastDisabled, this, false); Services.prefs.addObserver(kPrefCellBroadcastDisabled, this, false);
this.portAddressedSmsApps = {}; this.portAddressedSmsApps = {};
this.portAddressedSmsApps[WAP.WDP_PORT_PUSH] = this.handleSmsWdpPortPush.bind(this); this.portAddressedSmsApps[WAP.WDP_PORT_PUSH] = this.handleSmsWdpPortPush.bind(this);
@ -1336,7 +1347,7 @@ RadioInterface.prototype = {
(function callback(response) { (function callback(response) {
if (!response.success) { if (!response.success) {
let lock = gSettingsService.createLock(); let lock = gSettingsService.createLock();
lock.set(kCellBroadcastSearchList, lock.set(kSettingsCellBroadcastSearchList,
this._cellBroadcastSearchListStr, null); this._cellBroadcastSearchListStr, null);
} else { } else {
this._cellBroadcastSearchListStr = response.searchListStr; this._cellBroadcastSearchListStr = response.searchListStr;
@ -1968,7 +1979,7 @@ RadioInterface.prototype = {
* Set the setting value of "time.clock.automatic-update.available". * Set the setting value of "time.clock.automatic-update.available".
*/ */
setClockAutoUpdateAvailable: function setClockAutoUpdateAvailable(value) { setClockAutoUpdateAvailable: function setClockAutoUpdateAvailable(value) {
gSettingsService.createLock().set(kClockAutoUpdateAvailable, value, null, gSettingsService.createLock().set(kSettingsClockAutoUpdateAvailable, value, null,
"fromInternalSetting"); "fromInternalSetting");
}, },
@ -1976,7 +1987,7 @@ RadioInterface.prototype = {
* Set the setting value of "time.timezone.automatic-update.available". * Set the setting value of "time.timezone.automatic-update.available".
*/ */
setTimezoneAutoUpdateAvailable: function setTimezoneAutoUpdateAvailable(value) { setTimezoneAutoUpdateAvailable: function setTimezoneAutoUpdateAvailable(value) {
gSettingsService.createLock().set(kTimezoneAutoUpdateAvailable, value, null, gSettingsService.createLock().set(kSettingsTimezoneAutoUpdateAvailable, value, null,
"fromInternalSetting"); "fromInternalSetting");
}, },
@ -2152,17 +2163,17 @@ RadioInterface.prototype = {
let setting = JSON.parse(data); let setting = JSON.parse(data);
this.handleSettingsChange(setting.key, setting.value, setting.message); this.handleSettingsChange(setting.key, setting.value, setting.message);
break; break;
case kPrefenceChangedObserverTopic: case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
if (data === kCellBroadcastDisabled) { if (data === kPrefCellBroadcastDisabled) {
let value = false; let value = false;
try { try {
value = Services.prefs.getBoolPref(kCellBroadcastDisabled); value = Services.prefs.getBoolPref(kPrefCellBroadcastDisabled);
} catch(e) {} } catch(e) {}
this.workerMessenger.send("setCellBroadcastDisabled", this.workerMessenger.send("setCellBroadcastDisabled",
{ disabled: value }); { disabled: value });
} }
break; break;
case "xpcom-shutdown": case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
// Cancel the timer of the CPU wake lock for handling the received SMS. // Cancel the timer of the CPU wake lock for handling the received SMS.
this._cancelSmsHandledWakeLockTimer(); this._cancelSmsHandledWakeLockTimer();
@ -2172,12 +2183,11 @@ RadioInterface.prototype = {
apnSetting.iface.shutdown(); apnSetting.iface.shutdown();
} }
} }
Services.obs.removeObserver(this, "xpcom-shutdown"); Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
Services.obs.removeObserver(this, kMozSettingsChangedObserverTopic); Services.obs.removeObserver(this, kMozSettingsChangedObserverTopic);
Services.obs.removeObserver(this, kSysClockChangeObserverTopic); Services.obs.removeObserver(this, kSysClockChangeObserverTopic);
Services.obs.removeObserver(this, kScreenStateChangedTopic); Services.obs.removeObserver(this, kScreenStateChangedTopic);
Services.obs.removeObserver(this, kNetworkInterfaceStateChangedTopic); Services.obs.removeObserver(this, kNetworkInterfaceStateChangedTopic);
Services.prefs.removeObserver(kCellBroadcastDisabled, this);
break; break;
case kSysClockChangeObserverTopic: case kSysClockChangeObserverTopic:
let offset = parseInt(data, 10); let offset = parseInt(data, 10);
@ -2240,7 +2250,7 @@ RadioInterface.prototype = {
handleSettingsChange: function handleSettingsChange(aName, aResult, aMessage) { handleSettingsChange: function handleSettingsChange(aName, aResult, aMessage) {
// Don't allow any content processes to modify the setting // Don't allow any content processes to modify the setting
// "time.clock.automatic-update.available" except for the chrome process. // "time.clock.automatic-update.available" except for the chrome process.
if (aName === kClockAutoUpdateAvailable && if (aName === kSettingsClockAutoUpdateAvailable &&
aMessage !== "fromInternalSetting") { aMessage !== "fromInternalSetting") {
let isClockAutoUpdateAvailable = this._lastNitzMessage !== null || let isClockAutoUpdateAvailable = this._lastNitzMessage !== null ||
this._sntp.isAvailable(); this._sntp.isAvailable();
@ -2254,7 +2264,7 @@ RadioInterface.prototype = {
// Don't allow any content processes to modify the setting // Don't allow any content processes to modify the setting
// "time.timezone.automatic-update.available" except for the chrome // "time.timezone.automatic-update.available" except for the chrome
// process. // process.
if (aName === kTimezoneAutoUpdateAvailable && if (aName === kSettingsTimezoneAutoUpdateAvailable &&
aMessage !== "fromInternalSetting") { aMessage !== "fromInternalSetting") {
let isTimezoneAutoUpdateAvailable = this._lastNitzMessage !== null; let isTimezoneAutoUpdateAvailable = this._lastNitzMessage !== null;
if (aResult !== isTimezoneAutoUpdateAvailable) { if (aResult !== isTimezoneAutoUpdateAvailable) {
@ -2306,7 +2316,7 @@ RadioInterface.prototype = {
this.updateRILNetworkInterface(); this.updateRILNetworkInterface();
} }
break; break;
case kClockAutoUpdateEnabled: case kSettingsClockAutoUpdateEnabled:
this._clockAutoUpdateEnabled = aResult; this._clockAutoUpdateEnabled = aResult;
if (!this._clockAutoUpdateEnabled) { if (!this._clockAutoUpdateEnabled) {
break; break;
@ -2326,7 +2336,7 @@ RadioInterface.prototype = {
} }
} }
break; break;
case kTimezoneAutoUpdateEnabled: case kSettingsTimezoneAutoUpdateEnabled:
this._timezoneAutoUpdateEnabled = aResult; this._timezoneAutoUpdateEnabled = aResult;
if (this._timezoneAutoUpdateEnabled) { if (this._timezoneAutoUpdateEnabled) {
@ -2336,9 +2346,9 @@ RadioInterface.prototype = {
} }
} }
break; break;
case kCellBroadcastSearchList: case kSettingsCellBroadcastSearchList:
if (DEBUG) { if (DEBUG) {
this.debug("'" + kCellBroadcastSearchList + "' is now " + aResult); this.debug("'" + kSettingsCellBroadcastSearchList + "' is now " + aResult);
} }
this.setCellBroadcastSearchList(aResult); this.setCellBroadcastSearchList(aResult);
break; break;
@ -2381,10 +2391,10 @@ RadioInterface.prototype = {
_updateCallingLineIdRestrictionPref: _updateCallingLineIdRestrictionPref:
function _updateCallingLineIdRestrictionPref(mode) { function _updateCallingLineIdRestrictionPref(mode) {
try { try {
Services.prefs.setIntPref(kClirModePreference, mode); Services.prefs.setIntPref(kPrefClirModePreference, mode);
Services.prefs.savePrefFile(null); Services.prefs.savePrefFile(null);
if (DEBUG) { if (DEBUG) {
this.debug(kClirModePreference + " pref is now " + mode); this.debug(kPrefClirModePreference + " pref is now " + mode);
} }
} catch (e) {} } catch (e) {}
}, },

View File

@ -8,3 +8,4 @@ disabled = Bug 808783
[test_fakevolume.js] [test_fakevolume.js]
[test_ril_code_quality.py] [test_ril_code_quality.py]
[test_screen_state.js] [test_screen_state.js]
[test_dsds_numRadioInterfaces.js]

View File

@ -0,0 +1,43 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_CONTEXT = "chrome";
Cu.import("resource://gre/modules/Promise.jsm");
Cu.import("resource://gre/modules/systemlibs.js");
const NS_RIL_CONTRACTID = "@mozilla.org/ril;1";
const PROP_RO_MOZ_RIL_NUMCLIENTS = "ro.moz.ril.numclients";
const PREF_RIL_NUM_RADIO_INTERFACES = "ril.numRadioInterfaces";
ok(libcutils, "libcutils is available");
let propNum = (function () {
try {
let numString = libcutils.property_get(PROP_RO_MOZ_RIL_NUMCLIENTS, "1");
let num = parseInt(numString, 10);
if (num >= 0) {
return num;
}
} catch (e) {}
})();
log("Retrieved '" + PROP_RO_MOZ_RIL_NUMCLIENTS + "' = " + propNum);
ok(propNum, PROP_RO_MOZ_RIL_NUMCLIENTS);
let prefNum = Services.prefs.getIntPref(PREF_RIL_NUM_RADIO_INTERFACES);
log("Retrieved '" + PREF_RIL_NUM_RADIO_INTERFACES + "' = " + prefNum);
let ril = Cc[NS_RIL_CONTRACTID].getService(Ci.nsIRadioInterfaceLayer);
ok(ril, "ril.constructor is " + ril.constructor);
let ifaceNum = ril.numRadioInterfaces;
log("Retrieved 'nsIRadioInterfaceLayer.numRadioInterfaces' = " + ifaceNum);
is(propNum, prefNum);
is(propNum, ifaceNum);
finish();

View File

@ -18,8 +18,13 @@ const GONK_TELEPHONYPROVIDER_CONTRACTID =
const GONK_TELEPHONYPROVIDER_CID = const GONK_TELEPHONYPROVIDER_CID =
Components.ID("{67d26434-d063-4d28-9f48-5b3189788155}"); Components.ID("{67d26434-d063-4d28-9f48-5b3189788155}");
const kPrefenceChangedObserverTopic = "nsPref:changed"; const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown";
const kXpcomShutdownObserverTopic = "xpcom-shutdown";
const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
const kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
const kPrefRilDebuggingEnabled = "ril.debugging.enabled";
const kPrefDefaultServiceId = "dom.telephony.defaultServiceId";
const nsIAudioManager = Ci.nsIAudioManager; const nsIAudioManager = Ci.nsIAudioManager;
const nsITelephonyProvider = Ci.nsITelephonyProvider; const nsITelephonyProvider = Ci.nsITelephonyProvider;
@ -83,9 +88,12 @@ function TelephonyProvider() {
this._listeners = []; this._listeners = [];
this._updateDebugFlag(); this._updateDebugFlag();
this.defaultServiceId = this._getDefaultServiceId();
Services.obs.addObserver(this, kPrefenceChangedObserverTopic, false); Services.prefs.addObserver(kPrefRilDebuggingEnabled, this, false);
Services.obs.addObserver(this, kXpcomShutdownObserverTopic, false); Services.prefs.addObserver(kPrefDefaultServiceId, this, false);
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
} }
TelephonyProvider.prototype = { TelephonyProvider.prototype = {
classID: GONK_TELEPHONYPROVIDER_CID, classID: GONK_TELEPHONYPROVIDER_CID,
@ -265,14 +273,27 @@ TelephonyProvider.prototype = {
_updateDebugFlag: function _updateDebugFlag() { _updateDebugFlag: function _updateDebugFlag() {
try { try {
DEBUG = RIL.DEBUG_RIL || DEBUG = RIL.DEBUG_RIL ||
Services.prefs.getBoolPref("ril.debugging.enabled"); Services.prefs.getBoolPref(kPrefRilDebuggingEnabled);
} catch (e) {} } catch (e) {}
}, },
_getDefaultServiceId: function _getDefaultServiceId() {
let id = Services.prefs.getIntPref(kPrefDefaultServiceId);
let numRil = Services.prefs.getIntPref(kPrefRilNumRadioInterfaces);
if (id >= numRil || id < 0) {
id = 0;
}
return id;
},
/** /**
* nsITelephonyProvider interface. * nsITelephonyProvider interface.
*/ */
defaultServiceId: 0,
registerListener: function(aListener) { registerListener: function(aListener) {
if (this._listeners.indexOf(aListener) >= 0) { if (this._listeners.indexOf(aListener) >= 0) {
throw Cr.NS_ERROR_UNEXPECTED; throw Cr.NS_ERROR_UNEXPECTED;
@ -506,18 +527,19 @@ TelephonyProvider.prototype = {
observe: function observe(aSubject, aTopic, aData) { observe: function observe(aSubject, aTopic, aData) {
switch (aTopic) { switch (aTopic) {
case kPrefenceChangedObserverTopic: case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
if (aData === "ril.debugging.enabled") { if (aData === kPrefRilDebuggingEnabled) {
this._updateDebugFlag(); this._updateDebugFlag();
} else if (aData === kPrefDefaultServiceId) {
this.defaultServiceId = this._getDefaultServiceId();
} }
break; break;
case kXpcomShutdownObserverTopic: case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
// Cancel the timer for the call-ring wake lock. // Cancel the timer for the call-ring wake lock.
this._cancelCallRingWakeLockTimer(); this._cancelCallRingWakeLockTimer();
Services.obs.removeObserver(this, kPrefenceChangedObserverTopic); Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
Services.obs.removeObserver(this, kXpcomShutdownObserverTopic);
break; break;
} }
} }

View File

@ -3,22 +3,52 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ipc/TelephonyIPCProvider.h"
#include "mozilla/dom/ContentChild.h" #include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/telephony/TelephonyChild.h" #include "mozilla/dom/telephony/TelephonyChild.h"
#include "ipc/TelephonyIPCProvider.h" #include "mozilla/Preferences.h"
USING_TELEPHONY_NAMESPACE USING_TELEPHONY_NAMESPACE
using namespace mozilla::dom; using namespace mozilla::dom;
NS_IMPL_ISUPPORTS2(TelephonyIPCProvider, namespace {
const char* kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
#define kPrefDefaultServiceId "dom.telephony.defaultServiceId"
const char* kObservedPrefs[] = {
kPrefDefaultServiceId,
nullptr
};
uint32_t
getDefaultServiceId()
{
int32_t id = mozilla::Preferences::GetInt(kPrefDefaultServiceId, 0);
int32_t numRil = mozilla::Preferences::GetInt(kPrefRilNumRadioInterfaces, 1);
if (id >= numRil || id < 0) {
id = 0;
}
return id;
}
} // Anonymous namespace
NS_IMPL_ISUPPORTS3(TelephonyIPCProvider,
nsITelephonyProvider, nsITelephonyProvider,
nsITelephonyListener) nsITelephonyListener,
nsIObserver)
TelephonyIPCProvider::TelephonyIPCProvider() TelephonyIPCProvider::TelephonyIPCProvider()
{ {
// Deallocated in ContentChild::DeallocPTelephonyChild(). // Deallocated in ContentChild::DeallocPTelephonyChild().
mPTelephonyChild = new TelephonyChild(this); mPTelephonyChild = new TelephonyChild(this);
ContentChild::GetSingleton()->SendPTelephonyConstructor(mPTelephonyChild); ContentChild::GetSingleton()->SendPTelephonyConstructor(mPTelephonyChild);
Preferences::AddStrongObservers(this, kObservedPrefs);
mDefaultServiceId = getDefaultServiceId();
} }
TelephonyIPCProvider::~TelephonyIPCProvider() TelephonyIPCProvider::~TelephonyIPCProvider()
@ -27,10 +57,38 @@ TelephonyIPCProvider::~TelephonyIPCProvider()
mPTelephonyChild = nullptr; mPTelephonyChild = nullptr;
} }
/*
* Implementation of nsIObserver.
*/
NS_IMETHODIMP
TelephonyIPCProvider::Observe(nsISupports* aSubject,
const char* aTopic,
const PRUnichar* aData)
{
if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
nsDependentString data(aData);
if (data.EqualsLiteral(kPrefDefaultServiceId)) {
mDefaultServiceId = getDefaultServiceId();
}
return NS_OK;
}
MOZ_ASSERT(false, "TelephonyIPCProvider got unexpected topic!");
return NS_ERROR_UNEXPECTED;
}
/* /*
* Implementation of nsITelephonyProvider. * Implementation of nsITelephonyProvider.
*/ */
NS_IMETHODIMP
TelephonyIPCProvider::GetDefaultServiceId(uint32_t* aServiceId)
{
*aServiceId = mDefaultServiceId;
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
TelephonyIPCProvider::RegisterListener(nsITelephonyListener *aListener) TelephonyIPCProvider::RegisterListener(nsITelephonyListener *aListener)
{ {

View File

@ -8,6 +8,7 @@
#include "mozilla/dom/telephony/TelephonyCommon.h" #include "mozilla/dom/telephony/TelephonyCommon.h"
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "nsIObserver.h"
#include "nsITelephonyProvider.h" #include "nsITelephonyProvider.h"
BEGIN_TELEPHONY_NAMESPACE BEGIN_TELEPHONY_NAMESPACE
@ -16,11 +17,13 @@ class PTelephonyChild;
class TelephonyIPCProvider MOZ_FINAL : public nsITelephonyProvider class TelephonyIPCProvider MOZ_FINAL : public nsITelephonyProvider
, public nsITelephonyListener , public nsITelephonyListener
, public nsIObserver
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSITELEPHONYPROVIDER NS_DECL_NSITELEPHONYPROVIDER
NS_DECL_NSITELEPHONYLISTENER NS_DECL_NSITELEPHONYLISTENER
NS_DECL_NSIOBSERVER
TelephonyIPCProvider(); TelephonyIPCProvider();
@ -30,6 +33,7 @@ protected:
private: private:
nsTArray<nsCOMPtr<nsITelephonyListener> > mListeners; nsTArray<nsCOMPtr<nsITelephonyListener> > mListeners;
PTelephonyChild* mPTelephonyChild; PTelephonyChild* mPTelephonyChild;
uint32_t mDefaultServiceId;
}; };
END_TELEPHONY_NAMESPACE END_TELEPHONY_NAMESPACE

View File

@ -118,7 +118,7 @@ interface nsITelephonyListener : nsISupports
* XPCOM component (in the content process) that provides the telephony * XPCOM component (in the content process) that provides the telephony
* information. * information.
*/ */
[scriptable, uuid(effca006-1ca8-47f7-9bab-1323f90a14ec)] [scriptable, uuid(f7680b82-53fc-42a7-9adf-bc0f2726425c)]
interface nsITelephonyProvider : nsISupports interface nsITelephonyProvider : nsISupports
{ {
const unsigned short CALL_STATE_UNKNOWN = 0; const unsigned short CALL_STATE_UNKNOWN = 0;
@ -136,6 +136,8 @@ interface nsITelephonyProvider : nsISupports
const unsigned short NOTIFICATION_REMOTE_HELD = 0; const unsigned short NOTIFICATION_REMOTE_HELD = 0;
const unsigned short NOTIFICATION_REMOTE_RESUMED = 1; const unsigned short NOTIFICATION_REMOTE_RESUMED = 1;
readonly attribute unsigned long defaultServiceId;
/** /**
* Called when a content process registers receiving unsolicited messages from * Called when a content process registers receiving unsolicited messages from
* RadioInterfaceLayer in the chrome process. Only a content process that has * RadioInterfaceLayer in the chrome process. Only a content process that has

View File

@ -43,3 +43,4 @@ disabled = Bug 821958
[test_outgoing_emergency_in_airplane_mode.js] [test_outgoing_emergency_in_airplane_mode.js]
[test_emergency_label.js] [test_emergency_label.js]
[test_conference.js] [test_conference.js]
[test_dsds_default_service_id.js]

View File

@ -0,0 +1,127 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_CONTEXT = "chrome";
Cu.import("resource://gre/modules/Promise.jsm");
const TELEPHONY_PROVIDER_CONTRACTID =
"@mozilla.org/telephony/telephonyprovider;1";
const PREF_RIL_NUM_RADIO_INTERFACES = "ril.numRadioInterfaces";
const PREF_DEFAULT_SERVICE_ID = "dom.telephony.defaultServiceId";
function setPrefAndVerify(prefKey, setVal, service, attrName, expectedVal, deferred) {
log(" Set '" + prefKey + "' to " + setVal);
Services.prefs.setIntPref(prefKey, setVal);
let prefVal = Services.prefs.getIntPref(prefKey);
is(prefVal, setVal, "'" + prefKey + "' set to " + setVal);
window.setTimeout(function () {
let defaultVal = service[attrName];
is(defaultVal, expectedVal, attrName);
deferred.resolve(service);
}, 0);
}
function getNumRadioInterfaces() {
let deferred = Promise.defer();
window.setTimeout(function () {
let numRil = Services.prefs.getIntPref(PREF_RIL_NUM_RADIO_INTERFACES);
log("numRil = " + numRil);
deferred.resolve(numRil);
}, 0);
return deferred.promise;
}
function getService(contractId, ifaceName) {
let deferred = Promise.defer();
window.setTimeout(function () {
log("Getting service for " + ifaceName);
let service = Cc[contractId].getService(Ci[ifaceName]);
ok(service, "service.constructor is " + service.constructor);
deferred.resolve(service);
}, 0);
return deferred.promise;
}
function checkInitialEquality(attrName, prefKey, service) {
let deferred = Promise.defer();
log(" Checking initial value for '" + prefKey + "'");
let origPrefVal = Services.prefs.getIntPref(prefKey);
ok(isFinite(origPrefVal), "default '" + prefKey + "' value");
window.setTimeout(function () {
let defaultVal = service[attrName];
is(defaultVal, origPrefVal, attrName);
deferred.resolve(service);
}, 0);
return deferred.promise;
}
function checkSetToNegtiveValue(attrName, prefKey, service) {
let deferred = Promise.defer();
// Set to -1 and verify defaultVal == 0.
setPrefAndVerify(prefKey, -1, service, attrName, 0, deferred);
return deferred.promise;
}
function checkSetToOverflowedValue(attrName, prefKey, numRil, service) {
let deferred = Promise.defer();
// Set to larger-equal than numRil and verify defaultVal == 0.
setPrefAndVerify(prefKey, numRil, service, attrName, 0, deferred);
return deferred.promise;
}
function checkValueChange(attrName, prefKey, numRil, service) {
let deferred = Promise.defer();
if (numRil > 1) {
// Set to (numRil - 1) and verify defaultVal equals.
setPrefAndVerify(prefKey, numRil - 1, service, attrName, numRil - 1, deferred);
} else {
window.setTimeout(function () {
deferred.resolve(service);
}, 0);
}
return deferred.promise;
}
function verify(contractId, ifaceName, attrName, prefKey, numRil) {
let deferred = Promise.defer();
getService(contractId, ifaceName)
.then(checkInitialEquality.bind(null, attrName, prefKey))
.then(checkSetToNegtiveValue.bind(null, attrName, prefKey))
.then(checkSetToOverflowedValue.bind(null, attrName, prefKey, numRil))
.then(checkValueChange.bind(null, attrName, prefKey, numRil))
.then(function () {
// Reset.
Services.prefs.clearUserPref(prefKey);
deferred.resolve(numRil);
});
return deferred.promise;
}
getNumRadioInterfaces()
.then(verify.bind(null, TELEPHONY_PROVIDER_CONTRACTID, "nsITelephonyProvider",
"defaultServiceId", PREF_DEFAULT_SERVICE_ID))
.then(finish);

View File

@ -22,9 +22,11 @@ interface nsIVoicemailListener : nsISupports
* XPCOM component (in the content process) that provides the voicemail * XPCOM component (in the content process) that provides the voicemail
* information. * information.
*/ */
[scriptable, uuid(37bc0991-21a3-4de9-b888-d667fea6c05d)] [scriptable, uuid(38746f3c-f4e3-4804-b900-ba2463b923c8)]
interface nsIVoicemailProvider : nsISupports interface nsIVoicemailProvider : nsISupports
{ {
readonly attribute unsigned long voicemailDefaultServiceId;
/** /**
* Called when a content process registers receiving unsolicited messages from * Called when a content process registers receiving unsolicited messages from
* RadioInterfaceLayer in the chrome process. Only a content process that has * RadioInterfaceLayer in the chrome process. Only a content process that has

View File

@ -5,3 +5,4 @@ qemu = true
[test_voicemail_statuschanged.py] [test_voicemail_statuschanged.py]
[test_voicemail_number.js] [test_voicemail_number.js]
[test_dsds_default_service_id.js]

View File

@ -0,0 +1,126 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_CONTEXT = "chrome";
Cu.import("resource://gre/modules/Promise.jsm");
const VOICEMAIL_PROVIDER_CONTRACTID = "@mozilla.org/ril/content-helper;1";
const PREF_RIL_NUM_RADIO_INTERFACES = "ril.numRadioInterfaces";
const PREF_DEFAULT_SERVICE_ID = "dom.voicemail.defaultServiceId";
function setPrefAndVerify(prefKey, setVal, service, attrName, expectedVal, deferred) {
log(" Set '" + prefKey + "' to " + setVal);
Services.prefs.setIntPref(prefKey, setVal);
let prefVal = Services.prefs.getIntPref(prefKey);
is(prefVal, setVal, "'" + prefKey + "' set to " + setVal);
window.setTimeout(function () {
let defaultVal = service[attrName];
is(defaultVal, expectedVal, attrName);
deferred.resolve(service);
}, 0);
}
function getNumRadioInterfaces() {
let deferred = Promise.defer();
window.setTimeout(function () {
let numRil = Services.prefs.getIntPref(PREF_RIL_NUM_RADIO_INTERFACES);
log("numRil = " + numRil);
deferred.resolve(numRil);
}, 0);
return deferred.promise;
}
function getService(contractId, ifaceName) {
let deferred = Promise.defer();
window.setTimeout(function () {
log("Getting service for " + ifaceName);
let service = Cc[contractId].getService(Ci[ifaceName]);
ok(service, "service.constructor is " + service.constructor);
deferred.resolve(service);
}, 0);
return deferred.promise;
}
function checkInitialEquality(attrName, prefKey, service) {
let deferred = Promise.defer();
log(" Checking initial value for '" + prefKey + "'");
let origPrefVal = Services.prefs.getIntPref(prefKey);
ok(isFinite(origPrefVal), "default '" + prefKey + "' value");
window.setTimeout(function () {
let defaultVal = service[attrName];
is(defaultVal, origPrefVal, attrName);
deferred.resolve(service);
}, 0);
return deferred.promise;
}
function checkSetToNegtiveValue(attrName, prefKey, service) {
let deferred = Promise.defer();
// Set to -1 and verify defaultVal == 0.
setPrefAndVerify(prefKey, -1, service, attrName, 0, deferred);
return deferred.promise;
}
function checkSetToOverflowedValue(attrName, prefKey, numRil, service) {
let deferred = Promise.defer();
// Set to larger-equal than numRil and verify defaultVal == 0.
setPrefAndVerify(prefKey, numRil, service, attrName, 0, deferred);
return deferred.promise;
}
function checkValueChange(attrName, prefKey, numRil, service) {
let deferred = Promise.defer();
if (numRil > 1) {
// Set to (numRil - 1) and verify defaultVal equals.
setPrefAndVerify(prefKey, numRil - 1, service, attrName, numRil - 1, deferred);
} else {
window.setTimeout(function () {
deferred.resolve(service);
}, 0);
}
return deferred.promise;
}
function verify(contractId, ifaceName, attrName, prefKey, numRil) {
let deferred = Promise.defer();
getService(contractId, ifaceName)
.then(checkInitialEquality.bind(null, attrName, prefKey))
.then(checkSetToNegtiveValue.bind(null, attrName, prefKey))
.then(checkSetToOverflowedValue.bind(null, attrName, prefKey, numRil))
.then(checkValueChange.bind(null, attrName, prefKey, numRil))
.then(function () {
// Reset.
Services.prefs.clearUserPref(prefKey);
deferred.resolve(numRil);
});
return deferred.promise;
}
getNumRadioInterfaces()
.then(verify.bind(null, VOICEMAIL_PROVIDER_CONTRACTID, "nsIVoicemailProvider",
"voicemailDefaultServiceId", PREF_DEFAULT_SERVICE_ID))
.then(finish);

View File

@ -4300,7 +4300,9 @@ pref("dom.sms.enabled", false);
// 7-bit default alphabet. // 7-bit default alphabet.
pref("dom.sms.strict7BitEncoding", false); pref("dom.sms.strict7BitEncoding", false);
pref("dom.sms.requestStatusReport", true); pref("dom.sms.requestStatusReport", true);
pref("dom.mms.requestStatusReport", true); // Numeric default service id for SMS API calls with |serviceId| parameter
// omitted.
pref("dom.sms.defaultServiceId", 0);
// WebContacts // WebContacts
pref("dom.mozContacts.enabled", false); pref("dom.mozContacts.enabled", false);
@ -4426,6 +4428,8 @@ pref("wap.UAProf.tagname", "x-wap-profile");
// @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.34 // @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.34
pref("dom.mms.version", 19); pref("dom.mms.version", 19);
pref("dom.mms.requestStatusReport", true);
// Retrieval mode for MMS // Retrieval mode for MMS
// manual: Manual retrieval mode. // manual: Manual retrieval mode.
// automatic: Automatic retrieval mode even in roaming. // automatic: Automatic retrieval mode even in roaming.
@ -4438,10 +4442,15 @@ pref("dom.mms.sendRetryInterval", 300000);
pref("dom.mms.retrievalRetryCount", 4); pref("dom.mms.retrievalRetryCount", 4);
pref("dom.mms.retrievalRetryIntervals", "60000,300000,600000,1800000"); pref("dom.mms.retrievalRetryIntervals", "60000,300000,600000,1800000");
// Numeric default service id for MMS API calls with |serviceId| parameter
// omitted.
pref("dom.mms.defaultServiceId", 0);
// Debug enabler for MMS. // Debug enabler for MMS.
pref("mms.debugging.enabled", false); pref("mms.debugging.enabled", false);
// Number of RadioInterface instances to create.
pref("ril.numRadioInterfaces", 0);
// If the user puts a finger down on an element and we think the user // If the user puts a finger down on an element and we think the user
// might be executing a pan gesture, how long do we wait before // might be executing a pan gesture, how long do we wait before
// tentatively deciding the gesture is actually a tap and activating // tentatively deciding the gesture is actually a tap and activating
@ -4477,6 +4486,9 @@ pref("dom.datastore.enabled", false);
// Telephony API // Telephony API
pref("dom.telephony.enabled", false); pref("dom.telephony.enabled", false);
// Numeric default service id for WebTelephony API calls with |serviceId|
// parameter omitted.
pref("dom.telephony.defaultServiceId", 0);
// Cell Broadcast API // Cell Broadcast API
pref("dom.cellbroadcast.enabled", false); pref("dom.cellbroadcast.enabled", false);
@ -4489,6 +4501,9 @@ pref("dom.mobileconnection.enabled", false);
// Voice Mail API // Voice Mail API
pref("dom.voicemail.enabled", false); pref("dom.voicemail.enabled", false);
// Numeric default service id for Voice Mail API calls with |serviceId|
// parameter omitted.
pref("dom.voicemail.defaultServiceId", 0);
// DOM Inter-App Communication API. // DOM Inter-App Communication API.
pref("dom.inter-app-communication-api.enabled", false); pref("dom.inter-app-communication-api.enabled", false);