зеркало из https://github.com/mozilla/gecko-dev.git
Bug 864484 - Part 6: Move broadcastCbsSystemMessage() From RadioInterfaceLayer to CellBroadcastService. r=vyang
--HG-- extra : rebase_source : 9d77590199e2b94a9dad50a97e7a3f3e488694f3
This commit is contained in:
Родитель
0ce3edef4c
Коммит
8a91370464
|
@ -16,6 +16,10 @@ XPCOMUtils.defineLazyGetter(this, "RIL", function () {
|
|||
return obj;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gSystemMessenger",
|
||||
"@mozilla.org/system-message-internal;1",
|
||||
"nsISystemMessagesInternal");
|
||||
|
||||
const GONK_CELLBROADCAST_SERVICE_CONTRACTID =
|
||||
"@mozilla.org/cellbroadcast/gonkservice;1";
|
||||
const GONK_CELLBROADCAST_SERVICE_CID =
|
||||
|
@ -100,6 +104,41 @@ CellBroadcastService.prototype = {
|
|||
aEtwsWarningType,
|
||||
aEtwsEmergencyUserAlert,
|
||||
aEtwsPopup) {
|
||||
// Broadcast CBS System message
|
||||
// Align the same layout to MozCellBroadcastMessage
|
||||
let systemMessage = {
|
||||
serviceId: aServiceId,
|
||||
gsmGeographicalScope: aGsmGeographicalScope,
|
||||
messageCode: aMessageCode,
|
||||
messageId: aMessageId,
|
||||
language: aLanguage,
|
||||
body: aBody,
|
||||
messageClass: aMessageClass,
|
||||
timestamp: aTimestamp,
|
||||
cdmaServiceCategory: null,
|
||||
etws: null
|
||||
};
|
||||
|
||||
if (aHasEtwsInfo) {
|
||||
systemMessage.etws = {
|
||||
warningType: aEtwsWarningType,
|
||||
emergencyUserAlert: aEtwsEmergencyUserAlert,
|
||||
popup: aEtwsPopup
|
||||
};
|
||||
}
|
||||
|
||||
if (aCdmaServiceCategory !=
|
||||
Ci.nsICellBroadcastService.CDMA_SERVICE_CATEGORY_INVALID) {
|
||||
systemMessage.cdmaServiceCategory = aCdmaServiceCategory;
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
debug("CBS system message to be broadcasted: " + JSON.stringify(systemMessage));
|
||||
}
|
||||
|
||||
gSystemMessenger.broadcastMessage("cellbroadcast-received", systemMessage);
|
||||
|
||||
// Notify received message to registered listener
|
||||
for (let listener of this._listeners) {
|
||||
try {
|
||||
listener.notifyMessageReceived(aServiceId,
|
||||
|
|
|
@ -2104,8 +2104,6 @@ RadioInterface.prototype = {
|
|||
this.handleSmsMultipart(message);
|
||||
break;
|
||||
case "cellbroadcast-received":
|
||||
message.timestamp = Date.now();
|
||||
this.broadcastCbsSystemMessage(message);
|
||||
this.handleCellbroadcastMessageReceived(message);
|
||||
break;
|
||||
case "nitzTime":
|
||||
|
@ -2778,48 +2776,6 @@ RadioInterface.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper to broadcast the system message to launch registered apps
|
||||
* like CMAS app and etc.
|
||||
*
|
||||
* @param aName
|
||||
* The system message name.
|
||||
* @param aMessage
|
||||
* The Cellbroadcast message received from ril_worker.
|
||||
*/
|
||||
broadcastCbsSystemMessage: function(aMessage) {
|
||||
// Create system message with the same structure of nsIDOMMozCellBroadcastMessage
|
||||
// and nsIDOMMozCellBroadcastEtwsInfo.
|
||||
let etws = (aMessage.etws != null)
|
||||
? {
|
||||
warningType: (aMessage.etws.warningType != null)
|
||||
? RIL.CB_ETWS_WARNING_TYPE_NAMES[aMessage.etws.warningType]
|
||||
: null,
|
||||
emergencyUserAlert: aMessage.etws.emergencyUserAlert,
|
||||
popup: aMessage.etws.popup
|
||||
}
|
||||
: null;
|
||||
|
||||
let systemMessage = {
|
||||
serviceId: this.clientId,
|
||||
gsmGeographicalScope: RIL.CB_GSM_GEOGRAPHICAL_SCOPE_NAMES[aMessage.geographicalScope],
|
||||
messageCode: aMessage.messageCode,
|
||||
messageId: aMessage.messageId,
|
||||
language: aMessage.language,
|
||||
body: aMessage.fullBody,
|
||||
messageClass: aMessage.messageClass,
|
||||
timestamp: aMessage.timestamp,
|
||||
etws: etws,
|
||||
cdmaServiceCategory: aMessage.serviceCategory
|
||||
};
|
||||
|
||||
if (DEBUG) {
|
||||
this.debug("CBS system message to be broadcasted: " + JSON.stringify(systemMessage));
|
||||
}
|
||||
|
||||
gSystemMessenger.broadcastMessage("cellbroadcast-received", systemMessage);
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the setting value of "time.clock.automatic-update.available".
|
||||
*/
|
||||
|
@ -3002,7 +2958,7 @@ RadioInterface.prototype = {
|
|||
aMessage.language,
|
||||
aMessage.fullBody,
|
||||
aMessage.messageClass,
|
||||
aMessage.timestamp,
|
||||
Date.now(),
|
||||
serviceCategory,
|
||||
hasEtwsInfo,
|
||||
(hasEtwsInfo && etwsInfo.warningType != null)
|
||||
|
|
Загрузка…
Ссылка в новой задаче