2012-07-20 09:10:44 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
"use strict";
|
|
|
|
|
2011-12-05 07:58:27 +00:00
|
|
|
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
|
|
|
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
2011-12-24 05:02:52 +00:00
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
2013-06-22 14:22:05 +00:00
|
|
|
Cu.import("resource://gre/modules/Sntp.jsm");
|
2013-09-30 09:24:54 +00:00
|
|
|
Cu.import("resource://gre/modules/systemlibs.js");
|
2013-11-21 14:09:14 +00:00
|
|
|
Cu.import("resource://gre/modules/Promise.jsm");
|
2014-02-18 14:41:36 +00:00
|
|
|
Cu.import("resource://gre/modules/FileUtils.jsm");
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2014-05-07 22:53:17 +00:00
|
|
|
XPCOMUtils.defineLazyGetter(this, "RIL", function () {
|
|
|
|
let obj = {};
|
|
|
|
Cu.import("resource://gre/modules/ril_consts.js", obj);
|
|
|
|
return obj;
|
|
|
|
});
|
2012-01-09 22:28:47 +00:00
|
|
|
|
2014-01-15 14:40:49 +00:00
|
|
|
// Ril quirk to always turn the radio off for the client without SIM card
|
|
|
|
// except hw default client.
|
2015-09-15 18:19:45 +00:00
|
|
|
var RILQUIRKS_RADIO_OFF_WO_CARD =
|
2014-01-15 14:40:49 +00:00
|
|
|
libcutils.property_get("ro.moz.ril.radio_off_wo_card", "false") == "true";
|
|
|
|
|
2012-01-19 20:53:32 +00:00
|
|
|
const RADIOINTERFACELAYER_CID =
|
2012-01-09 23:18:23 +00:00
|
|
|
Components.ID("{2d831c8d-6017-435b-a80c-e5d422810cea}");
|
2013-07-02 09:36:37 +00:00
|
|
|
const RADIOINTERFACE_CID =
|
|
|
|
Components.ID("{6a7c91f0-a2b3-4193-8562-8969296c0b54}");
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2013-10-24 08:14:59 +00:00
|
|
|
const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown";
|
2014-03-10 03:36:42 +00:00
|
|
|
const kNetworkConnStateChangedTopic = "network-connection-state-changed";
|
2012-04-24 20:46:42 +00:00
|
|
|
const kMozSettingsChangedObserverTopic = "mozsettings-changed";
|
2012-09-05 20:00:06 +00:00
|
|
|
const kSysMsgListenerReadyObserverTopic = "system-message-listener-ready";
|
2012-10-23 07:15:53 +00:00
|
|
|
const kSysClockChangeObserverTopic = "system-clock-change";
|
2013-06-06 07:28:59 +00:00
|
|
|
const kScreenStateChangedTopic = "screen-state-changed";
|
2013-10-24 08:14:59 +00:00
|
|
|
|
|
|
|
const kSettingsClockAutoUpdateEnabled = "time.clock.automatic-update.enabled";
|
|
|
|
const kSettingsClockAutoUpdateAvailable = "time.clock.automatic-update.available";
|
|
|
|
const kSettingsTimezoneAutoUpdateEnabled = "time.timezone.automatic-update.enabled";
|
|
|
|
const kSettingsTimezoneAutoUpdateAvailable = "time.timezone.automatic-update.available";
|
|
|
|
|
|
|
|
const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
|
|
|
|
|
2013-10-24 08:15:06 +00:00
|
|
|
const kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
|
2014-05-20 22:50:00 +00:00
|
|
|
const kPrefRilDebuggingEnabled = "ril.debugging.enabled";
|
2012-10-30 10:53:27 +00:00
|
|
|
|
2013-09-07 06:19:57 +00:00
|
|
|
const RADIO_POWER_OFF_TIMEOUT = 30000;
|
2014-01-15 14:40:49 +00:00
|
|
|
const HW_DEFAULT_CLIENT_ID = 0;
|
2012-09-28 05:43:35 +00:00
|
|
|
|
2015-07-29 06:06:00 +00:00
|
|
|
const NETWORK_TYPE_WIFI = Ci.nsINetworkInfo.NETWORK_TYPE_WIFI;
|
|
|
|
const NETWORK_TYPE_MOBILE = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE;
|
2014-11-25 01:44:33 +00:00
|
|
|
|
2014-05-20 22:50:00 +00:00
|
|
|
// set to true in ril_consts.js to see debug messages
|
|
|
|
var DEBUG = RIL.DEBUG_RIL;
|
|
|
|
|
|
|
|
function updateDebugFlag() {
|
|
|
|
// Read debug setting from pref
|
|
|
|
let debugPref;
|
|
|
|
try {
|
|
|
|
debugPref = Services.prefs.getBoolPref(kPrefRilDebuggingEnabled);
|
|
|
|
} catch (e) {
|
|
|
|
debugPref = false;
|
|
|
|
}
|
|
|
|
DEBUG = RIL.DEBUG_RIL || debugPref;
|
|
|
|
}
|
|
|
|
updateDebugFlag();
|
|
|
|
|
|
|
|
function debug(s) {
|
|
|
|
dump("-*- RadioInterfaceLayer: " + s + "\n");
|
|
|
|
}
|
|
|
|
|
2015-01-06 05:32:08 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gIccService",
|
|
|
|
"@mozilla.org/icc/gonkiccservice;1",
|
|
|
|
"nsIGonkIccService");
|
|
|
|
|
2013-09-07 11:09:54 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gMobileMessageService",
|
|
|
|
"@mozilla.org/mobilemessage/mobilemessageservice;1",
|
|
|
|
"nsIMobileMessageService");
|
|
|
|
|
2013-07-29 22:50:22 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gSmsService",
|
2014-11-24 10:43:54 +00:00
|
|
|
"@mozilla.org/sms/gonksmsservice;1",
|
|
|
|
"nsIGonkSmsService");
|
2013-09-07 11:09:54 +00:00
|
|
|
|
2013-09-07 11:32:23 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
|
|
|
|
"@mozilla.org/parentprocessmessagemanager;1",
|
|
|
|
"nsIMessageBroadcaster");
|
|
|
|
|
2012-05-24 05:12:07 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService",
|
|
|
|
"@mozilla.org/settingsService;1",
|
|
|
|
"nsISettingsService");
|
|
|
|
|
2012-09-26 12:52:21 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gNetworkManager",
|
|
|
|
"@mozilla.org/network/manager;1",
|
|
|
|
"nsINetworkManager");
|
|
|
|
|
2012-09-28 06:02:57 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gTimeService",
|
|
|
|
"@mozilla.org/time/timeservice;1",
|
|
|
|
"nsITimeService");
|
|
|
|
|
2013-01-24 06:42:07 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gSystemWorkerManager",
|
|
|
|
"@mozilla.org/telephony/system-worker-manager;1",
|
|
|
|
"nsISystemWorkerManager");
|
|
|
|
|
2014-06-03 14:15:25 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gTelephonyService",
|
|
|
|
"@mozilla.org/telephony/telephonyservice;1",
|
|
|
|
"nsIGonkTelephonyService");
|
2013-09-07 06:19:57 +00:00
|
|
|
|
2014-02-10 11:55:22 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gMobileConnectionService",
|
|
|
|
"@mozilla.org/mobileconnection/mobileconnectionservice;1",
|
2014-09-21 07:24:42 +00:00
|
|
|
"nsIGonkMobileConnectionService");
|
2014-02-10 11:55:22 +00:00
|
|
|
|
2014-08-13 10:28:34 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gCellBroadcastService",
|
2015-04-17 11:06:24 +00:00
|
|
|
"@mozilla.org/cellbroadcast/cellbroadcastservice;1",
|
2014-08-13 10:28:34 +00:00
|
|
|
"nsIGonkCellBroadcastService");
|
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gDataCallManager",
|
|
|
|
"@mozilla.org/datacall/manager;1",
|
|
|
|
"nsIDataCallManager");
|
|
|
|
|
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gDataCallInterfaceService",
|
|
|
|
"@mozilla.org/datacall/interfaceservice;1",
|
|
|
|
"nsIGonkDataCallInterfaceService");
|
|
|
|
|
2015-04-15 10:33:26 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gStkCmdFactory",
|
|
|
|
"@mozilla.org/icc/stkcmdfactory;1",
|
|
|
|
"nsIStkCmdFactory");
|
2014-10-27 07:58:56 +00:00
|
|
|
|
2014-01-13 02:44:33 +00:00
|
|
|
XPCOMUtils.defineLazyGetter(this, "gRadioEnabledController", function() {
|
2014-02-14 09:42:32 +00:00
|
|
|
let _ril = null;
|
2014-02-10 11:55:22 +00:00
|
|
|
let _pendingMessages = []; // For queueing "setRadioEnabled" message.
|
2014-02-14 09:42:32 +00:00
|
|
|
let _isProcessingPending = false;
|
|
|
|
let _timer = null;
|
|
|
|
let _request = null;
|
|
|
|
let _deactivatingDeferred = {};
|
|
|
|
let _initializedCardState = {};
|
|
|
|
let _allCardStateInitialized = !RILQUIRKS_RADIO_OFF_WO_CARD;
|
2013-11-21 14:09:14 +00:00
|
|
|
|
2014-02-14 09:42:32 +00:00
|
|
|
return {
|
2014-01-13 02:44:40 +00:00
|
|
|
init: function(ril) {
|
2014-02-14 09:42:32 +00:00
|
|
|
_ril = ril;
|
2013-11-21 14:09:14 +00:00
|
|
|
},
|
|
|
|
|
2014-02-14 09:42:32 +00:00
|
|
|
receiveCardState: function(clientId) {
|
|
|
|
if (_allCardStateInitialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DEBUG) debug("RadioControl: receive cardState from " + clientId);
|
|
|
|
_initializedCardState[clientId] = true;
|
|
|
|
if (Object.keys(_initializedCardState).length == _ril.numRadioInterfaces) {
|
|
|
|
_allCardStateInitialized = true;
|
|
|
|
this._startProcessingPending();
|
2013-11-21 14:09:14 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-02-10 11:55:22 +00:00
|
|
|
setRadioEnabled: function(clientId, data, callback) {
|
|
|
|
if (DEBUG) debug("setRadioEnabled: " + clientId + ": " + JSON.stringify(data));
|
|
|
|
let message = {
|
|
|
|
clientId: clientId,
|
|
|
|
data: data,
|
|
|
|
callback: callback
|
|
|
|
};
|
|
|
|
_pendingMessages.push(message);
|
2014-02-14 09:42:32 +00:00
|
|
|
this._startProcessingPending();
|
|
|
|
},
|
|
|
|
|
2014-02-10 11:55:22 +00:00
|
|
|
notifyRadioStateChanged: function(clientId, radioState) {
|
|
|
|
gMobileConnectionService.notifyRadioStateChanged(clientId, radioState);
|
|
|
|
},
|
|
|
|
|
2014-02-14 09:42:32 +00:00
|
|
|
_startProcessingPending: function() {
|
|
|
|
if (!_isProcessingPending) {
|
|
|
|
if (DEBUG) debug("RadioControl: start dequeue");
|
|
|
|
_isProcessingPending = true;
|
|
|
|
this._processNextMessage();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-11-21 14:09:14 +00:00
|
|
|
_processNextMessage: function() {
|
2014-02-14 09:42:32 +00:00
|
|
|
if (_pendingMessages.length === 0 || !_allCardStateInitialized) {
|
|
|
|
if (DEBUG) debug("RadioControl: stop dequeue");
|
|
|
|
_isProcessingPending = false;
|
2013-11-21 14:09:14 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-14 09:42:32 +00:00
|
|
|
let msg = _pendingMessages.shift();
|
2013-11-21 14:09:14 +00:00
|
|
|
this._handleMessage(msg);
|
|
|
|
},
|
|
|
|
|
2014-01-15 14:40:49 +00:00
|
|
|
_getNumCards: function() {
|
|
|
|
let numCards = 0;
|
2014-02-14 09:42:32 +00:00
|
|
|
for (let i = 0, N = _ril.numRadioInterfaces; i < N; ++i) {
|
2014-12-16 22:51:09 +00:00
|
|
|
if (_ril.getRadioInterface(i).isCardPresent()) {
|
2014-01-15 14:40:49 +00:00
|
|
|
numCards++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return numCards;
|
|
|
|
},
|
|
|
|
|
|
|
|
_isRadioAbleToEnableAtClient: function(clientId, numCards) {
|
|
|
|
if (!RILQUIRKS_RADIO_OFF_WO_CARD) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We could only turn on the radio for clientId if
|
|
|
|
// 1. a SIM card is presented or
|
|
|
|
// 2. it is the default clientId and there is no any SIM card at any client.
|
|
|
|
|
2014-12-16 22:51:09 +00:00
|
|
|
if (_ril.getRadioInterface(clientId).isCardPresent()) {
|
2014-01-15 14:40:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
numCards = numCards == null ? this._getNumCards() : numCards;
|
|
|
|
if (clientId === HW_DEFAULT_CLIENT_ID && numCards === 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2014-02-10 11:55:22 +00:00
|
|
|
_handleMessage: function(message) {
|
|
|
|
if (DEBUG) debug("RadioControl: handleMessage: " + JSON.stringify(message));
|
|
|
|
let clientId = message.clientId || 0;
|
2014-09-21 07:24:43 +00:00
|
|
|
let connection =
|
|
|
|
gMobileConnectionService.getItemByServiceId(clientId);
|
|
|
|
let radioState = connection && connection.radioState;
|
2013-11-21 14:09:14 +00:00
|
|
|
|
2014-02-10 11:55:22 +00:00
|
|
|
if (message.data.enabled) {
|
2014-01-15 14:40:49 +00:00
|
|
|
if (this._isRadioAbleToEnableAtClient(clientId)) {
|
2014-02-10 11:55:22 +00:00
|
|
|
this._setRadioEnabledInternal(message);
|
2014-01-15 14:40:49 +00:00
|
|
|
} else {
|
|
|
|
// Not really do it but respond success.
|
2014-02-10 11:55:22 +00:00
|
|
|
message.callback(message.data);
|
2014-01-15 14:40:49 +00:00
|
|
|
}
|
|
|
|
|
2013-11-21 14:09:14 +00:00
|
|
|
this._processNextMessage();
|
|
|
|
} else {
|
2014-02-10 11:55:22 +00:00
|
|
|
_request = this._setRadioEnabledInternal.bind(this, message);
|
2013-11-21 14:09:14 +00:00
|
|
|
|
2014-02-06 04:31:53 +00:00
|
|
|
// In 2G network, modem takes 35+ seconds to process deactivate data
|
|
|
|
// call request if device has active voice call (please see bug 964974
|
|
|
|
// for more details). Therefore we should hangup all active voice calls
|
|
|
|
// first. And considering some DSDS architecture, toggling one radio may
|
|
|
|
// toggle both, so we send hangUpAll to all clients.
|
2015-02-13 02:57:29 +00:00
|
|
|
let hangUpCallback = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsITelephonyCallback]),
|
|
|
|
notifySuccess: function() {},
|
|
|
|
notifyError: function() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
gTelephonyService.enumerateCalls({
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsITelephonyListener]),
|
|
|
|
enumerateCallState: function(aInfo) {
|
|
|
|
gTelephonyService.hangUpCall(aInfo.clientId, aInfo.callIndex,
|
|
|
|
hangUpCallback);
|
|
|
|
},
|
|
|
|
enumerateCallStateComplete: function() {}
|
|
|
|
});
|
2014-02-06 04:31:53 +00:00
|
|
|
|
2013-11-21 14:09:14 +00:00
|
|
|
// In some DSDS architecture with only one modem, toggling one radio may
|
|
|
|
// toggle both. Therefore, for safely turning off, we should first
|
|
|
|
// explicitly deactivate all data calls from all clients.
|
|
|
|
this._deactivateDataCalls().then(() => {
|
2014-02-14 09:42:32 +00:00
|
|
|
if (DEBUG) debug("RadioControl: deactivation done");
|
2013-11-21 14:09:14 +00:00
|
|
|
this._executeRequest();
|
|
|
|
});
|
|
|
|
|
|
|
|
this._createTimer();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-02-10 11:55:22 +00:00
|
|
|
_setRadioEnabledInternal: function(message) {
|
|
|
|
let clientId = message.clientId || 0;
|
|
|
|
let enabled = message.data.enabled || false;
|
|
|
|
let radioInterface = _ril.getRadioInterface(clientId);
|
|
|
|
|
|
|
|
radioInterface.workerMessenger.send("setRadioEnabled", message.data,
|
|
|
|
(function(response) {
|
|
|
|
if (response.errorMsg) {
|
2015-02-06 08:08:00 +00:00
|
|
|
// If request fails, set current radio state to unknown, since we will
|
|
|
|
// handle it in |mobileConnectionService|.
|
2014-02-10 11:55:22 +00:00
|
|
|
this.notifyRadioStateChanged(clientId,
|
2015-02-06 08:08:00 +00:00
|
|
|
Ci.nsIMobileConnection.MOBILE_RADIO_STATE_UNKNOWN);
|
2014-02-10 11:55:22 +00:00
|
|
|
}
|
2015-02-06 08:08:00 +00:00
|
|
|
return message.callback(response);
|
2014-02-10 11:55:22 +00:00
|
|
|
}).bind(this));
|
|
|
|
},
|
|
|
|
|
2013-11-21 14:09:14 +00:00
|
|
|
_deactivateDataCalls: function() {
|
2014-02-14 09:42:32 +00:00
|
|
|
if (DEBUG) debug("RadioControl: deactivating data calls...");
|
|
|
|
_deactivatingDeferred = {};
|
2013-11-21 14:09:14 +00:00
|
|
|
|
|
|
|
let promise = Promise.resolve();
|
2014-02-14 09:42:32 +00:00
|
|
|
for (let i = 0, N = _ril.numRadioInterfaces; i < N; ++i) {
|
2013-11-21 14:09:14 +00:00
|
|
|
promise = promise.then(this._deactivateDataCallsForClient(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
return promise;
|
|
|
|
},
|
|
|
|
|
|
|
|
_deactivateDataCallsForClient: function(clientId) {
|
2014-02-14 09:42:32 +00:00
|
|
|
return function() {
|
|
|
|
let deferred = _deactivatingDeferred[clientId] = Promise.defer();
|
2015-05-20 02:08:39 +00:00
|
|
|
let dataCallHandler = gDataCallManager.getDataCallHandler(clientId);
|
|
|
|
|
|
|
|
dataCallHandler.deactivateDataCalls(function() {
|
|
|
|
deferred.resolve();
|
|
|
|
});
|
|
|
|
|
2013-11-21 14:09:14 +00:00
|
|
|
return deferred.promise;
|
2014-02-14 09:42:32 +00:00
|
|
|
};
|
2013-11-21 14:09:14 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_createTimer: function() {
|
2014-02-21 06:15:35 +00:00
|
|
|
if (!_timer) {
|
2014-02-14 09:42:32 +00:00
|
|
|
_timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
2013-11-21 14:09:14 +00:00
|
|
|
}
|
2014-02-14 09:42:32 +00:00
|
|
|
_timer.initWithCallback(this._executeRequest.bind(this),
|
|
|
|
RADIO_POWER_OFF_TIMEOUT,
|
|
|
|
Ci.nsITimer.TYPE_ONE_SHOT);
|
2013-11-21 14:09:14 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_cancelTimer: function() {
|
2014-02-14 09:42:32 +00:00
|
|
|
if (_timer) {
|
|
|
|
_timer.cancel();
|
2013-11-21 14:09:14 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_executeRequest: function() {
|
2014-02-14 09:42:32 +00:00
|
|
|
if (typeof _request === "function") {
|
|
|
|
if (DEBUG) debug("RadioControl: executeRequest");
|
2013-11-21 14:09:14 +00:00
|
|
|
this._cancelTimer();
|
2014-02-14 09:42:32 +00:00
|
|
|
_request();
|
|
|
|
_request = null;
|
2013-11-21 14:09:14 +00:00
|
|
|
}
|
2013-12-13 16:46:23 +00:00
|
|
|
this._processNextMessage();
|
2014-01-15 14:40:49 +00:00
|
|
|
},
|
2013-11-21 14:09:14 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2013-12-03 06:18:32 +00:00
|
|
|
// 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) {}
|
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
function DataCall(aAttributes) {
|
|
|
|
for (let key in aAttributes) {
|
|
|
|
if (key === "pdpType") {
|
|
|
|
// Convert pdp type into constant int value.
|
|
|
|
this[key] = RIL.RIL_DATACALL_PDP_TYPES.indexOf(aAttributes[key]);
|
|
|
|
continue;
|
|
|
|
}
|
2014-05-27 00:08:00 +00:00
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
this[key] = aAttributes[key];
|
|
|
|
}
|
2013-12-03 06:18:32 +00:00
|
|
|
}
|
2015-05-20 02:08:39 +00:00
|
|
|
DataCall.prototype = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDataCall]),
|
|
|
|
|
|
|
|
failCause: Ci.nsIDataCallInterface.DATACALL_FAIL_NONE,
|
|
|
|
suggestedRetryTime: -1,
|
|
|
|
cid: -1,
|
|
|
|
active: -1,
|
|
|
|
pdpType: -1,
|
|
|
|
ifname: null,
|
|
|
|
addreses: null,
|
|
|
|
dnses: null,
|
2015-08-18 01:54:36 +00:00
|
|
|
gateways: null,
|
|
|
|
pcscf: null
|
2015-05-20 02:08:39 +00:00
|
|
|
};
|
2013-12-03 06:18:32 +00:00
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
function RadioInterfaceLayer() {
|
|
|
|
let workerMessenger = new WorkerMessenger();
|
|
|
|
workerMessenger.init();
|
|
|
|
this.setWorkerDebugFlag = workerMessenger.setDebugFlag.bind(workerMessenger);
|
2013-12-03 06:18:32 +00:00
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
let numIfaces = this.numRadioInterfaces;
|
|
|
|
if (DEBUG) debug(numIfaces + " interfaces");
|
|
|
|
this.radioInterfaces = [];
|
|
|
|
for (let clientId = 0; clientId < numIfaces; clientId++) {
|
|
|
|
this.radioInterfaces.push(new RadioInterface(clientId, workerMessenger));
|
|
|
|
}
|
2013-12-03 06:18:32 +00:00
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
|
|
|
Services.prefs.addObserver(kPrefRilDebuggingEnabled, this, false);
|
2013-12-03 06:18:32 +00:00
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
gRadioEnabledController.init(this);
|
|
|
|
}
|
|
|
|
RadioInterfaceLayer.prototype = {
|
2013-12-03 06:18:32 +00:00
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
classID: RADIOINTERFACELAYER_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({classID: RADIOINTERFACELAYER_CID,
|
|
|
|
classDescription: "RadioInterfaceLayer",
|
|
|
|
interfaces: [Ci.nsIRadioInterfaceLayer]}),
|
2014-05-27 00:08:00 +00:00
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIRadioInterfaceLayer,
|
|
|
|
Ci.nsIObserver]),
|
2014-10-08 18:24:00 +00:00
|
|
|
|
2013-12-03 06:18:32 +00:00
|
|
|
/**
|
2015-05-20 02:08:39 +00:00
|
|
|
* nsIObserver interface methods.
|
2013-12-03 06:18:32 +00:00
|
|
|
*/
|
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
observe: function(subject, topic, data) {
|
|
|
|
switch (topic) {
|
|
|
|
case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
|
|
|
|
for (let radioInterface of this.radioInterfaces) {
|
|
|
|
radioInterface.shutdown();
|
2014-05-27 00:08:00 +00:00
|
|
|
}
|
2015-05-20 02:08:39 +00:00
|
|
|
this.radioInterfaces = null;
|
|
|
|
Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
|
|
|
break;
|
2013-12-03 06:18:32 +00:00
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
|
|
|
|
if (data === kPrefRilDebuggingEnabled) {
|
|
|
|
updateDebugFlag();
|
|
|
|
this.setWorkerDebugFlag(DEBUG);
|
2014-05-27 00:08:00 +00:00
|
|
|
}
|
2015-05-20 02:08:39 +00:00
|
|
|
break;
|
2013-12-03 06:18:32 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2015-05-20 02:08:39 +00:00
|
|
|
* nsIRadioInterfaceLayer interface methods.
|
2013-12-03 06:18:32 +00:00
|
|
|
*/
|
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
getRadioInterface: function(clientId) {
|
|
|
|
return this.radioInterfaces[clientId];
|
2013-12-03 06:18:32 +00:00
|
|
|
},
|
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
getClientIdForEmergencyCall: function() {
|
|
|
|
// Select the client with sim card first.
|
|
|
|
for (let cid = 0; cid < this.numRadioInterfaces; ++cid) {
|
|
|
|
if (this.getRadioInterface(cid).isCardPresent()) {
|
|
|
|
return cid;
|
2013-12-03 06:18:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
// Use the defualt client if no card presents.
|
|
|
|
return HW_DEFAULT_CLIENT_ID;
|
|
|
|
},
|
2014-09-21 07:24:43 +00:00
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
setMicrophoneMuted: function(muted) {
|
|
|
|
for (let clientId = 0; clientId < this.numRadioInterfaces; clientId++) {
|
|
|
|
let radioInterface = this.radioInterfaces[clientId];
|
|
|
|
radioInterface.workerMessenger.send("setMute", { muted: muted });
|
2013-12-03 06:18:32 +00:00
|
|
|
}
|
2015-05-20 02:08:39 +00:00
|
|
|
}
|
|
|
|
};
|
2013-12-03 06:18:32 +00:00
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
XPCOMUtils.defineLazyGetter(RadioInterfaceLayer.prototype,
|
|
|
|
"numRadioInterfaces", function() {
|
|
|
|
try {
|
|
|
|
return Services.prefs.getIntPref(kPrefRilNumRadioInterfaces);
|
|
|
|
} catch(e) {}
|
2013-12-03 06:18:32 +00:00
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
return 1;
|
|
|
|
});
|
2013-12-03 06:18:32 +00:00
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
function WorkerMessenger() {
|
|
|
|
// Initial owning attributes.
|
|
|
|
this.radioInterfaces = [];
|
|
|
|
this.tokenCallbackMap = {};
|
2014-05-27 00:08:00 +00:00
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
this.worker = new ChromeWorker("resource://gre/modules/ril_worker.js");
|
|
|
|
this.worker.onerror = this.onerror.bind(this);
|
|
|
|
this.worker.onmessage = this.onmessage.bind(this);
|
|
|
|
}
|
|
|
|
WorkerMessenger.prototype = {
|
|
|
|
radioInterfaces: null,
|
|
|
|
worker: null,
|
2013-12-03 06:18:32 +00:00
|
|
|
|
2015-05-20 02:08:39 +00:00
|
|
|
// This gets incremented each time we send out a message.
|
|
|
|
token: 1,
|
2013-08-13 12:14:10 +00:00
|
|
|
|
|
|
|
// Maps tokens we send out with messages to the message callback.
|
|
|
|
tokenCallbackMap: null,
|
|
|
|
|
2014-02-17 11:35:02 +00:00
|
|
|
init: function() {
|
|
|
|
let options = {
|
|
|
|
debug: DEBUG,
|
|
|
|
quirks: {
|
|
|
|
callstateExtraUint32:
|
|
|
|
libcutils.property_get("ro.moz.ril.callstate_extra_int", "false") === "true",
|
|
|
|
requestUseDialEmergencyCall:
|
|
|
|
libcutils.property_get("ro.moz.ril.dial_emergency_call", "false") === "true",
|
|
|
|
simAppStateExtraFields:
|
|
|
|
libcutils.property_get("ro.moz.ril.simstate_extra_field", "false") === "true",
|
|
|
|
extraUint2ndCall:
|
2015-07-07 10:47:45 +00:00
|
|
|
libcutils.property_get("ro.moz.ril.extra_int_2nd_call", "false") === "true",
|
2014-02-17 11:35:02 +00:00
|
|
|
haveQueryIccLockRetryCount:
|
2015-07-07 10:47:45 +00:00
|
|
|
libcutils.property_get("ro.moz.ril.query_icc_count", "false") === "true",
|
2014-02-17 11:35:02 +00:00
|
|
|
sendStkProfileDownload:
|
2015-07-07 10:47:45 +00:00
|
|
|
libcutils.property_get("ro.moz.ril.send_stk_profile_dl", "false") === "true",
|
2015-04-29 02:41:47 +00:00
|
|
|
smscAddressFormat:
|
|
|
|
libcutils.property_get("ro.moz.ril.smsc_address_format", "text"),
|
2015-07-07 10:47:45 +00:00
|
|
|
dataRegistrationOnDemand:
|
|
|
|
libcutils.property_get("ro.moz.ril.data_reg_on_demand", "false") === "true",
|
|
|
|
subscriptionControl:
|
|
|
|
libcutils.property_get("ro.moz.ril.subscription_control", "false") === "true",
|
|
|
|
signalExtraInt:
|
|
|
|
libcutils.property_get("ro.moz.ril.signal_extra_int", "false") === "true",
|
|
|
|
availableNetworkExtraStr:
|
|
|
|
libcutils.property_get("ro.moz.ril.avlbl_nw_extra_str", "false") === "true",
|
2014-06-24 10:32:41 +00:00
|
|
|
}
|
2014-02-17 11:35:02 +00:00
|
|
|
};
|
|
|
|
|
2014-02-17 11:35:03 +00:00
|
|
|
this.send(null, "setInitialOptions", options);
|
|
|
|
},
|
|
|
|
|
2014-05-20 22:50:00 +00:00
|
|
|
setDebugFlag: function(aDebug) {
|
|
|
|
let options = { debug: aDebug };
|
|
|
|
this.send(null, "setDebugFlag", options);
|
|
|
|
},
|
|
|
|
|
2014-02-17 11:35:03 +00:00
|
|
|
debug: function(aClientId, aMessage) {
|
|
|
|
// We use the same debug subject with RadioInterface's here.
|
|
|
|
dump("-*- RadioInterface[" + aClientId + "]: " + aMessage + "\n");
|
2014-02-17 11:35:02 +00:00
|
|
|
},
|
|
|
|
|
2014-01-13 02:44:40 +00:00
|
|
|
onerror: function(event) {
|
2013-08-13 12:14:10 +00:00
|
|
|
if (DEBUG) {
|
2014-02-17 11:35:03 +00:00
|
|
|
this.debug("X", "Got an error: " + event.filename + ":" +
|
2013-08-13 12:14:10 +00:00
|
|
|
event.lineno + ": " + event.message + "\n");
|
|
|
|
}
|
|
|
|
event.preventDefault();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process the incoming message from the RIL worker.
|
|
|
|
*/
|
2014-01-13 02:44:40 +00:00
|
|
|
onmessage: function(event) {
|
2013-08-13 12:14:10 +00:00
|
|
|
let message = event.data;
|
2014-02-17 11:35:03 +00:00
|
|
|
let clientId = message.rilMessageClientId;
|
|
|
|
if (clientId === null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-13 12:14:10 +00:00
|
|
|
if (DEBUG) {
|
2014-02-17 11:35:03 +00:00
|
|
|
this.debug(clientId, "Received message from worker: " + JSON.stringify(message));
|
2013-08-13 12:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let token = message.rilMessageToken;
|
|
|
|
if (token == null) {
|
|
|
|
// That's an unsolicited message. Pass to RadioInterface directly.
|
2014-02-17 11:35:03 +00:00
|
|
|
let radioInterface = this.radioInterfaces[clientId];
|
|
|
|
radioInterface.handleUnsolicitedWorkerMessage(message);
|
2013-08-13 12:14:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let callback = this.tokenCallbackMap[message.rilMessageToken];
|
|
|
|
if (!callback) {
|
2014-02-17 11:35:03 +00:00
|
|
|
if (DEBUG) this.debug(clientId, "Ignore orphan token: " + message.rilMessageToken);
|
2013-08-13 12:14:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let keep = false;
|
|
|
|
try {
|
|
|
|
keep = callback(message);
|
|
|
|
} catch(e) {
|
2014-02-17 11:35:03 +00:00
|
|
|
if (DEBUG) this.debug(clientId, "callback throws an exception: " + e);
|
2013-08-13 12:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!keep) {
|
|
|
|
delete this.tokenCallbackMap[message.rilMessageToken];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-02-17 11:35:03 +00:00
|
|
|
registerClient: function(aClientId, aRadioInterface) {
|
|
|
|
if (DEBUG) this.debug(aClientId, "Starting RIL Worker");
|
|
|
|
|
|
|
|
// Keep a reference so that we can dispatch unsolicited messages to it.
|
|
|
|
this.radioInterfaces[aClientId] = aRadioInterface;
|
|
|
|
|
|
|
|
this.send(null, "registerClient", { clientId: aClientId });
|
|
|
|
gSystemWorkerManager.registerRilWorker(aClientId, this.worker);
|
|
|
|
},
|
|
|
|
|
2013-08-13 12:14:10 +00:00
|
|
|
/**
|
|
|
|
* Send arbitrary message to worker.
|
|
|
|
*
|
|
|
|
* @param rilMessageType
|
|
|
|
* A text message type.
|
|
|
|
* @param message [optional]
|
|
|
|
* An optional message object to send.
|
|
|
|
* @param callback [optional]
|
|
|
|
* An optional callback function which is called when worker replies
|
2013-11-21 14:09:14 +00:00
|
|
|
* with an message containing a "rilMessageToken" attribute of the
|
2013-08-13 12:14:10 +00:00
|
|
|
* same value we passed. This callback function accepts only one
|
|
|
|
* parameter -- the reply from worker. It also returns a boolean
|
|
|
|
* value true to keep current token-callback mapping and wait for
|
|
|
|
* another worker reply, or false to remove the mapping.
|
|
|
|
*/
|
2014-02-17 11:35:03 +00:00
|
|
|
send: function(clientId, rilMessageType, message, callback) {
|
2013-08-13 12:14:10 +00:00
|
|
|
message = message || {};
|
|
|
|
|
2014-02-17 11:35:03 +00:00
|
|
|
message.rilMessageClientId = clientId;
|
2013-08-13 12:14:10 +00:00
|
|
|
message.rilMessageToken = this.token;
|
|
|
|
this.token++;
|
|
|
|
|
|
|
|
if (callback) {
|
|
|
|
// Only create the map if callback is provided. For sending a request
|
|
|
|
// and intentionally leaving the callback undefined, that reply will
|
|
|
|
// be dropped in |this.onmessage| because of that orphan token.
|
|
|
|
//
|
|
|
|
// For sending a request that never replied at all, we're fine with this
|
|
|
|
// because no callback shall be passed and we leave nothing to be cleaned
|
|
|
|
// up later.
|
|
|
|
this.tokenCallbackMap[message.rilMessageToken] = callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
message.rilMessageType = rilMessageType;
|
|
|
|
this.worker.postMessage(message);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-02-17 11:35:03 +00:00
|
|
|
function RadioInterface(aClientId, aWorkerMessenger) {
|
2014-02-17 11:35:02 +00:00
|
|
|
this.clientId = aClientId;
|
2014-02-17 11:35:03 +00:00
|
|
|
this.workerMessenger = {
|
2015-06-16 10:56:38 +00:00
|
|
|
send: aWorkerMessenger.send.bind(aWorkerMessenger, aClientId)
|
2014-02-17 11:35:03 +00:00
|
|
|
};
|
|
|
|
aWorkerMessenger.registerClient(aClientId, this);
|
2013-07-02 09:36:37 +00:00
|
|
|
|
2013-08-08 09:29:42 +00:00
|
|
|
this.operatorInfo = {};
|
|
|
|
|
2012-09-07 18:05:08 +00:00
|
|
|
let lock = gSettingsService.createLock();
|
2012-05-24 05:12:07 +00:00
|
|
|
|
2013-11-21 14:09:14 +00:00
|
|
|
// Read the "time.clock.automatic-update.enabled" setting to see if
|
2013-06-22 14:22:05 +00:00
|
|
|
// we need to adjust the system clock time by NITZ or SNTP.
|
2013-10-24 08:14:59 +00:00
|
|
|
lock.get(kSettingsClockAutoUpdateEnabled, this);
|
2012-09-28 06:02:57 +00:00
|
|
|
|
2013-11-21 14:09:14 +00:00
|
|
|
// Read the "time.timezone.automatic-update.enabled" setting to see if
|
2013-06-22 14:22:05 +00:00
|
|
|
// we need to adjust the system timezone by NITZ.
|
2013-10-24 08:14:59 +00:00
|
|
|
lock.get(kSettingsTimezoneAutoUpdateEnabled, this);
|
2013-06-22 14:22:05 +00:00
|
|
|
|
|
|
|
// Set "time.clock.automatic-update.available" to false when starting up.
|
|
|
|
this.setClockAutoUpdateAvailable(false);
|
|
|
|
|
|
|
|
// Set "time.timezone.automatic-update.available" to false when starting up.
|
|
|
|
this.setTimezoneAutoUpdateAvailable(false);
|
2013-01-25 10:06:24 +00:00
|
|
|
|
2012-04-24 20:46:42 +00:00
|
|
|
Services.obs.addObserver(this, kMozSettingsChangedObserverTopic, false);
|
2012-10-23 07:15:53 +00:00
|
|
|
Services.obs.addObserver(this, kSysClockChangeObserverTopic, false);
|
2013-06-06 07:28:59 +00:00
|
|
|
Services.obs.addObserver(this, kScreenStateChangedTopic, false);
|
2012-04-19 21:33:25 +00:00
|
|
|
|
2014-03-10 03:36:42 +00:00
|
|
|
Services.obs.addObserver(this, kNetworkConnStateChangedTopic, false);
|
2013-09-07 11:09:54 +00:00
|
|
|
|
2013-06-22 14:22:05 +00:00
|
|
|
this._sntp = new Sntp(this.setClockBySntp.bind(this),
|
2013-11-21 14:09:14 +00:00
|
|
|
Services.prefs.getIntPref("network.sntp.maxRetryCount"),
|
|
|
|
Services.prefs.getIntPref("network.sntp.refreshPeriod"),
|
|
|
|
Services.prefs.getIntPref("network.sntp.timeout"),
|
|
|
|
Services.prefs.getCharPref("network.sntp.pools").split(";"),
|
|
|
|
Services.prefs.getIntPref("network.sntp.port"));
|
2011-12-05 07:58:27 +00:00
|
|
|
}
|
2013-06-22 14:22:05 +00:00
|
|
|
|
2013-07-02 09:36:37 +00:00
|
|
|
RadioInterface.prototype = {
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2013-07-02 09:36:37 +00:00
|
|
|
classID: RADIOINTERFACE_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({classID: RADIOINTERFACE_CID,
|
|
|
|
classDescription: "RadioInterface",
|
|
|
|
interfaces: [Ci.nsIRadioInterface]}),
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2013-07-02 09:36:37 +00:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIRadioInterface,
|
2012-05-24 05:12:07 +00:00
|
|
|
Ci.nsIObserver,
|
|
|
|
Ci.nsISettingsServiceCallback]),
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2014-02-17 11:35:03 +00:00
|
|
|
// A private wrapped WorkerMessenger instance.
|
2013-08-13 12:14:10 +00:00
|
|
|
workerMessenger: null,
|
|
|
|
|
2014-01-13 02:44:40 +00:00
|
|
|
debug: function(s) {
|
2013-07-02 09:36:58 +00:00
|
|
|
dump("-*- RadioInterface[" + this.clientId + "]: " + s + "\n");
|
|
|
|
},
|
|
|
|
|
2013-12-03 06:18:32 +00:00
|
|
|
shutdown: function() {
|
|
|
|
Services.obs.removeObserver(this, kMozSettingsChangedObserverTopic);
|
|
|
|
Services.obs.removeObserver(this, kSysClockChangeObserverTopic);
|
|
|
|
Services.obs.removeObserver(this, kScreenStateChangedTopic);
|
2014-03-10 03:36:42 +00:00
|
|
|
Services.obs.removeObserver(this, kNetworkConnStateChangedTopic);
|
2013-12-03 06:18:32 +00:00
|
|
|
},
|
|
|
|
|
2014-12-16 22:51:09 +00:00
|
|
|
isCardPresent: function() {
|
2015-04-17 11:03:46 +00:00
|
|
|
let icc = gIccService.getIccByServiceId(this.clientId);
|
|
|
|
let cardState = icc ? icc.cardState : Ci.nsIIcc.CARD_STATE_UNKNOWN;
|
2015-01-15 10:12:23 +00:00
|
|
|
return cardState !== Ci.nsIIcc.CARD_STATE_UNDETECTED &&
|
|
|
|
cardState !== Ci.nsIIcc.CARD_STATE_UNKNOWN;
|
2014-12-16 22:51:09 +00:00
|
|
|
},
|
|
|
|
|
2014-01-13 02:44:40 +00:00
|
|
|
handleUnsolicitedWorkerMessage: function(message) {
|
2012-08-06 21:28:03 +00:00
|
|
|
switch (message.rilMessageType) {
|
2012-11-28 01:28:43 +00:00
|
|
|
case "callRing":
|
2014-06-03 14:15:25 +00:00
|
|
|
gTelephonyService.notifyCallRing();
|
2012-11-28 01:28:43 +00:00
|
|
|
break;
|
2015-03-24 10:04:49 +00:00
|
|
|
case "currentCalls":
|
|
|
|
gTelephonyService.notifyCurrentCalls(this.clientId, message.calls);
|
2013-07-06 10:40:58 +00:00
|
|
|
break;
|
2013-07-30 09:24:43 +00:00
|
|
|
case "cdmaCallWaiting":
|
2014-10-15 06:51:00 +00:00
|
|
|
gTelephonyService.notifyCdmaCallWaiting(this.clientId,
|
|
|
|
message.waitingCall);
|
2013-07-30 09:24:43 +00:00
|
|
|
break;
|
2013-08-05 20:28:31 +00:00
|
|
|
case "suppSvcNotification":
|
2014-06-03 14:15:25 +00:00
|
|
|
gTelephonyService.notifySupplementaryService(this.clientId,
|
2015-03-24 10:04:49 +00:00
|
|
|
message.number,
|
2014-02-10 11:55:22 +00:00
|
|
|
message.notification);
|
2013-08-05 20:28:31 +00:00
|
|
|
break;
|
2014-10-15 06:51:00 +00:00
|
|
|
case "ussdreceived":
|
|
|
|
gTelephonyService.notifyUssdReceived(this.clientId, message.message,
|
|
|
|
message.sessionEnded);
|
|
|
|
break;
|
2015-03-18 03:28:54 +00:00
|
|
|
case "datacalllistchanged":
|
2015-05-20 02:08:39 +00:00
|
|
|
let dataCalls = message.datacalls.map(dataCall => new DataCall(dataCall));
|
|
|
|
gDataCallInterfaceService.notifyDataCallListChanged(this.clientId,
|
|
|
|
dataCalls.length,
|
|
|
|
dataCalls);
|
2013-12-03 06:18:32 +00:00
|
|
|
break;
|
2013-08-14 12:50:36 +00:00
|
|
|
case "emergencyCbModeChange":
|
2014-02-10 11:55:22 +00:00
|
|
|
gMobileConnectionService.notifyEmergencyCallbackModeChanged(this.clientId,
|
2014-12-09 08:03:19 +00:00
|
|
|
message.active,
|
|
|
|
message.timeoutMs);
|
2013-08-14 12:50:36 +00:00
|
|
|
break;
|
2012-06-19 22:52:06 +00:00
|
|
|
case "networkinfochanged":
|
2014-02-10 11:55:22 +00:00
|
|
|
gMobileConnectionService.notifyNetworkInfoChanged(this.clientId,
|
|
|
|
message);
|
2012-06-19 22:52:06 +00:00
|
|
|
break;
|
|
|
|
case "networkselectionmodechange":
|
2014-02-10 11:55:22 +00:00
|
|
|
gMobileConnectionService.notifyNetworkSelectModeChanged(this.clientId,
|
|
|
|
message.mode);
|
2012-06-19 22:52:06 +00:00
|
|
|
break;
|
2012-03-19 22:49:27 +00:00
|
|
|
case "voiceregistrationstatechange":
|
2014-02-10 11:55:22 +00:00
|
|
|
gMobileConnectionService.notifyVoiceInfoChanged(this.clientId, message);
|
2012-02-10 19:27:23 +00:00
|
|
|
break;
|
2012-03-19 22:49:27 +00:00
|
|
|
case "dataregistrationstatechange":
|
2014-02-10 11:55:22 +00:00
|
|
|
gMobileConnectionService.notifyDataInfoChanged(this.clientId, message);
|
2012-02-10 19:27:23 +00:00
|
|
|
break;
|
2011-12-05 07:58:27 +00:00
|
|
|
case "signalstrengthchange":
|
2014-02-10 11:55:22 +00:00
|
|
|
gMobileConnectionService.notifySignalStrengthChanged(this.clientId,
|
|
|
|
message);
|
2011-12-05 07:58:27 +00:00
|
|
|
break;
|
|
|
|
case "operatorchange":
|
2014-02-10 11:55:22 +00:00
|
|
|
gMobileConnectionService.notifyOperatorChanged(this.clientId, message);
|
2011-12-05 07:58:27 +00:00
|
|
|
break;
|
2013-08-27 12:25:54 +00:00
|
|
|
case "otastatuschange":
|
2014-02-10 11:55:22 +00:00
|
|
|
gMobileConnectionService.notifyOtaStatusChanged(this.clientId, message.status);
|
2013-08-27 12:25:54 +00:00
|
|
|
break;
|
2011-12-07 06:57:19 +00:00
|
|
|
case "radiostatechange":
|
2014-02-10 11:55:22 +00:00
|
|
|
// gRadioEnabledController should know the radio state for each client,
|
|
|
|
// so notify gRadioEnabledController here.
|
|
|
|
gRadioEnabledController.notifyRadioStateChanged(this.clientId,
|
|
|
|
message.radioState);
|
|
|
|
break;
|
2011-12-05 07:58:27 +00:00
|
|
|
case "cardstatechange":
|
2015-01-06 05:32:08 +00:00
|
|
|
gIccService.notifyCardStateChanged(this.clientId,
|
2015-04-17 11:03:46 +00:00
|
|
|
message.cardState);
|
|
|
|
gRadioEnabledController.receiveCardState(this.clientId);
|
2011-12-05 07:58:27 +00:00
|
|
|
break;
|
2011-12-24 05:02:52 +00:00
|
|
|
case "sms-received":
|
2014-11-27 10:59:06 +00:00
|
|
|
this.handleSmsReceived(message);
|
2014-03-12 16:27:00 +00:00
|
|
|
break;
|
2012-12-04 02:40:47 +00:00
|
|
|
case "cellbroadcast-received":
|
2014-08-13 10:28:34 +00:00
|
|
|
this.handleCellbroadcastMessageReceived(message);
|
2012-12-04 02:40:47 +00:00
|
|
|
break;
|
2012-03-09 04:16:06 +00:00
|
|
|
case "nitzTime":
|
2012-09-28 06:02:57 +00:00
|
|
|
this.handleNitzTime(message);
|
2012-03-09 04:16:06 +00:00
|
|
|
break;
|
2012-04-18 10:07:29 +00:00
|
|
|
case "iccinfochange":
|
2015-04-17 11:03:46 +00:00
|
|
|
gIccService.notifyIccInfoChanged(this.clientId,
|
|
|
|
message.iccid ? message : null);
|
2012-03-17 14:23:17 +00:00
|
|
|
break;
|
2013-01-11 09:20:12 +00:00
|
|
|
case "iccimsi":
|
2015-04-17 11:03:46 +00:00
|
|
|
gIccService.notifyImsiChanged(this.clientId, message.imsi);
|
2013-01-11 09:20:12 +00:00
|
|
|
break;
|
2012-07-21 00:19:38 +00:00
|
|
|
case "iccmbdn":
|
2013-03-25 03:09:01 +00:00
|
|
|
this.handleIccMbdn(message);
|
2012-07-21 00:19:38 +00:00
|
|
|
break;
|
2013-12-06 09:35:13 +00:00
|
|
|
case "iccmwis":
|
2014-09-26 05:00:25 +00:00
|
|
|
this.handleIccMwis(message.mwi);
|
2013-12-06 09:35:13 +00:00
|
|
|
break;
|
2012-04-10 12:04:27 +00:00
|
|
|
case "stkcommand":
|
2015-04-27 08:01:56 +00:00
|
|
|
gIccService.notifyStkCommand(this.clientId,
|
|
|
|
gStkCmdFactory.createCommand(message));
|
2012-04-10 12:04:27 +00:00
|
|
|
break;
|
|
|
|
case "stksessionend":
|
2015-04-27 08:01:56 +00:00
|
|
|
gIccService.notifyStkSessionEnd(this.clientId);
|
2012-04-10 12:04:27 +00:00
|
|
|
break;
|
2013-09-10 16:48:19 +00:00
|
|
|
case "cdma-info-rec-received":
|
2014-10-03 06:23:41 +00:00
|
|
|
this.handleCdmaInformationRecords(message.records);
|
2013-09-10 16:48:19 +00:00
|
|
|
break;
|
2012-01-09 22:28:47 +00:00
|
|
|
default:
|
2012-08-06 21:28:03 +00:00
|
|
|
throw new Error("Don't know about this message type: " +
|
|
|
|
message.rilMessageType);
|
2011-12-05 07:58:27 +00:00
|
|
|
}
|
2012-01-09 22:28:47 +00:00
|
|
|
},
|
|
|
|
|
2013-12-03 06:18:32 +00:00
|
|
|
setDataRegistration: function(attach) {
|
2014-08-07 10:38:21 +00:00
|
|
|
let deferred = Promise.defer();
|
|
|
|
this.workerMessenger.send("setDataRegistration",
|
|
|
|
{attach: attach},
|
|
|
|
(function(response) {
|
|
|
|
// Always resolve to proceed with the following steps.
|
|
|
|
deferred.resolve(response.errorMsg ? response.errorMsg : null);
|
|
|
|
}).bind(this));
|
|
|
|
|
|
|
|
return deferred.promise;
|
2013-12-03 06:18:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TODO: Bug 911713 - B2G NetworkManager: Move policy control logic to
|
|
|
|
* NetworkManager
|
|
|
|
*/
|
|
|
|
updateRILNetworkInterface: function() {
|
2015-05-20 02:08:39 +00:00
|
|
|
let connHandler = gDataCallManager.getDataCallHandler(this.clientId);
|
2013-12-03 06:18:32 +00:00
|
|
|
connHandler.updateRILNetworkInterface();
|
2012-08-01 14:54:04 +00:00
|
|
|
},
|
|
|
|
|
2013-09-07 11:09:54 +00:00
|
|
|
/**
|
2014-11-27 10:59:06 +00:00
|
|
|
* handle received SMS.
|
2014-03-12 16:27:00 +00:00
|
|
|
*/
|
2014-11-27 10:59:06 +00:00
|
|
|
handleSmsReceived: function(aMessage) {
|
|
|
|
let header = aMessage.header;
|
|
|
|
// Concatenation Info:
|
|
|
|
// - segmentRef: a modulo 256 counter indicating the reference number for a
|
|
|
|
// particular concatenated short message. '0' is a valid number.
|
|
|
|
// - The concatenation info will not be available in |header| if
|
|
|
|
// segmentSeq or segmentMaxSeq is 0.
|
|
|
|
// See 3GPP TS 23.040, 9.2.3.24.1 Concatenated Short Messages.
|
|
|
|
let segmentRef = (header && header.segmentRef !== undefined)
|
|
|
|
? header.segmentRef : 1;
|
|
|
|
let segmentSeq = header && header.segmentSeq || 1;
|
|
|
|
let segmentMaxSeq = header && header.segmentMaxSeq || 1;
|
|
|
|
// Application Ports:
|
|
|
|
// The port number ranges from 0 to 49151.
|
|
|
|
// see 3GPP TS 23.040, 9.2.3.24.3/4 Application Port Addressing.
|
|
|
|
let originatorPort = (header && header.originatorPort !== undefined)
|
|
|
|
? header.originatorPort
|
|
|
|
: Ci.nsIGonkSmsService.SMS_APPLICATION_PORT_INVALID;
|
|
|
|
let destinationPort = (header && header.destinationPort !== undefined)
|
|
|
|
? header.destinationPort
|
|
|
|
: Ci.nsIGonkSmsService.SMS_APPLICATION_PORT_INVALID;
|
|
|
|
// MWI info:
|
|
|
|
let mwiPresent = (aMessage.mwi)? true : false;
|
|
|
|
let mwiDiscard = (mwiPresent)? aMessage.mwi.discard: false;
|
|
|
|
let mwiMsgCount = (mwiPresent)? aMessage.mwi.msgCount: 0;
|
|
|
|
let mwiActive = (mwiPresent)? aMessage.mwi.active: false;
|
|
|
|
// CDMA related attributes:
|
|
|
|
let cdmaMessageType = aMessage.messageType || 0;
|
|
|
|
let cdmaTeleservice = aMessage.teleservice || 0;
|
|
|
|
let cdmaServiceCategory = aMessage.serviceCategory || 0;
|
|
|
|
|
|
|
|
gSmsService
|
|
|
|
.notifyMessageReceived(this.clientId,
|
|
|
|
aMessage.SMSC || null,
|
|
|
|
aMessage.sentTimestamp,
|
|
|
|
aMessage.sender,
|
|
|
|
aMessage.pid,
|
|
|
|
aMessage.encoding,
|
|
|
|
RIL.GECKO_SMS_MESSAGE_CLASSES
|
|
|
|
.indexOf(aMessage.messageClass),
|
|
|
|
aMessage.language || null,
|
|
|
|
segmentRef,
|
|
|
|
segmentSeq,
|
|
|
|
segmentMaxSeq,
|
|
|
|
originatorPort,
|
|
|
|
destinationPort,
|
|
|
|
mwiPresent,
|
|
|
|
mwiDiscard,
|
|
|
|
mwiMsgCount,
|
|
|
|
mwiActive,
|
|
|
|
cdmaMessageType,
|
|
|
|
cdmaTeleservice,
|
|
|
|
cdmaServiceCategory,
|
|
|
|
aMessage.body || null,
|
|
|
|
aMessage.data || [],
|
|
|
|
(aMessage.data) ? aMessage.data.length : 0);
|
2014-03-12 16:27:00 +00:00
|
|
|
},
|
|
|
|
|
2013-01-25 10:06:24 +00:00
|
|
|
/**
|
2013-06-22 14:22:05 +00:00
|
|
|
* Set the setting value of "time.clock.automatic-update.available".
|
|
|
|
*/
|
2014-01-13 02:44:40 +00:00
|
|
|
setClockAutoUpdateAvailable: function(value) {
|
2014-08-28 04:01:31 +00:00
|
|
|
gSettingsService.createLock().set(kSettingsClockAutoUpdateAvailable, value, null);
|
2013-06-22 14:22:05 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the setting value of "time.timezone.automatic-update.available".
|
2013-01-25 10:06:24 +00:00
|
|
|
*/
|
2014-01-13 02:44:40 +00:00
|
|
|
setTimezoneAutoUpdateAvailable: function(value) {
|
2014-08-28 04:01:31 +00:00
|
|
|
gSettingsService.createLock().set(kSettingsTimezoneAutoUpdateAvailable, value, null);
|
2013-01-25 10:06:24 +00:00
|
|
|
},
|
|
|
|
|
2012-09-28 06:02:57 +00:00
|
|
|
/**
|
2013-06-22 14:22:05 +00:00
|
|
|
* Set the system clock by NITZ.
|
2012-09-28 06:02:57 +00:00
|
|
|
*/
|
2014-01-13 02:44:40 +00:00
|
|
|
setClockByNitz: function(message) {
|
2012-09-28 06:02:57 +00:00
|
|
|
// To set the system clock time. Note that there could be a time diff
|
|
|
|
// between when the NITZ was received and when the time is actually set.
|
|
|
|
gTimeService.set(
|
|
|
|
message.networkTimeInMS + (Date.now() - message.receiveTimeInMS));
|
2013-06-22 14:22:05 +00:00
|
|
|
},
|
2012-09-28 06:02:57 +00:00
|
|
|
|
2013-06-22 14:22:05 +00:00
|
|
|
/**
|
|
|
|
* Set the system time zone by NITZ.
|
|
|
|
*/
|
2014-01-13 02:44:40 +00:00
|
|
|
setTimezoneByNitz: function(message) {
|
2012-09-28 06:02:57 +00:00
|
|
|
// To set the sytem timezone. Note that we need to convert the time zone
|
|
|
|
// value to a UTC repesentation string in the format of "UTC(+/-)hh:mm".
|
2013-10-15 08:43:53 +00:00
|
|
|
// Ex, time zone -480 is "UTC+08:00"; time zone 630 is "UTC-10:30".
|
2012-09-28 06:02:57 +00:00
|
|
|
//
|
|
|
|
// We can unapply the DST correction if we want the raw time zone offset:
|
|
|
|
// message.networkTimeZoneInMinutes -= message.networkDSTInMinutes;
|
|
|
|
if (message.networkTimeZoneInMinutes != (new Date()).getTimezoneOffset()) {
|
|
|
|
let absTimeZoneInMinutes = Math.abs(message.networkTimeZoneInMinutes);
|
|
|
|
let timeZoneStr = "UTC";
|
2013-10-15 08:43:53 +00:00
|
|
|
timeZoneStr += (message.networkTimeZoneInMinutes > 0 ? "-" : "+");
|
2012-09-28 06:02:57 +00:00
|
|
|
timeZoneStr += ("0" + Math.floor(absTimeZoneInMinutes / 60)).slice(-2);
|
|
|
|
timeZoneStr += ":";
|
|
|
|
timeZoneStr += ("0" + absTimeZoneInMinutes % 60).slice(-2);
|
|
|
|
gSettingsService.createLock().set("time.timezone", timeZoneStr, null);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-10-23 07:15:53 +00:00
|
|
|
/**
|
|
|
|
* Handle the NITZ message.
|
|
|
|
*/
|
2014-01-13 02:44:40 +00:00
|
|
|
handleNitzTime: function(message) {
|
2013-01-25 10:06:24 +00:00
|
|
|
// Got the NITZ info received from the ril_worker.
|
2013-06-22 14:22:05 +00:00
|
|
|
this.setClockAutoUpdateAvailable(true);
|
|
|
|
this.setTimezoneAutoUpdateAvailable(true);
|
2013-01-25 10:06:24 +00:00
|
|
|
|
2012-10-23 07:15:53 +00:00
|
|
|
// Cache the latest NITZ message whenever receiving it.
|
|
|
|
this._lastNitzMessage = message;
|
|
|
|
|
2013-06-22 14:22:05 +00:00
|
|
|
// Set the received NITZ clock if the setting is enabled.
|
|
|
|
if (this._clockAutoUpdateEnabled) {
|
|
|
|
this.setClockByNitz(message);
|
|
|
|
}
|
|
|
|
// Set the received NITZ timezone if the setting is enabled.
|
|
|
|
if (this._timezoneAutoUpdateEnabled) {
|
|
|
|
this.setTimezoneByNitz(message);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the system clock by SNTP.
|
|
|
|
*/
|
2014-01-13 02:44:40 +00:00
|
|
|
setClockBySntp: function(offset) {
|
2013-06-22 14:22:05 +00:00
|
|
|
// Got the SNTP info.
|
|
|
|
this.setClockAutoUpdateAvailable(true);
|
|
|
|
if (!this._clockAutoUpdateEnabled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (this._lastNitzMessage) {
|
2014-01-23 08:44:20 +00:00
|
|
|
if (DEBUG) debug("SNTP: NITZ available, discard SNTP");
|
2013-06-22 14:22:05 +00:00
|
|
|
return;
|
2012-10-23 07:15:53 +00:00
|
|
|
}
|
2013-06-22 14:22:05 +00:00
|
|
|
gTimeService.set(Date.now() + offset);
|
2012-10-23 07:15:53 +00:00
|
|
|
},
|
|
|
|
|
2014-01-13 02:44:40 +00:00
|
|
|
handleIccMbdn: function(message) {
|
2014-09-26 05:00:25 +00:00
|
|
|
let service = Cc["@mozilla.org/voicemail/voicemailservice;1"]
|
|
|
|
.getService(Ci.nsIGonkVoicemailService);
|
|
|
|
service.notifyInfoChanged(this.clientId, message.number, message.alphaId);
|
|
|
|
},
|
2012-11-23 04:09:01 +00:00
|
|
|
|
2014-09-26 05:00:25 +00:00
|
|
|
handleIccMwis: function(mwi) {
|
|
|
|
let service = Cc["@mozilla.org/voicemail/voicemailservice;1"]
|
|
|
|
.getService(Ci.nsIGonkVoicemailService);
|
2014-11-27 10:59:06 +00:00
|
|
|
// Note: returnNumber and returnMessage is not available from UICC.
|
2014-09-26 05:00:25 +00:00
|
|
|
service.notifyStatusChanged(this.clientId, mwi.active, mwi.msgCount,
|
2014-11-27 10:59:06 +00:00
|
|
|
null, null);
|
2012-11-23 04:09:01 +00:00
|
|
|
},
|
|
|
|
|
2014-09-23 10:27:03 +00:00
|
|
|
_convertCbGsmGeographicalScope: function(aGeographicalScope) {
|
|
|
|
return (aGeographicalScope != null)
|
|
|
|
? aGeographicalScope
|
|
|
|
: Ci.nsICellBroadcastService.GSM_GEOGRAPHICAL_SCOPE_INVALID;
|
|
|
|
},
|
|
|
|
|
|
|
|
_convertCbMessageClass: function(aMessageClass) {
|
|
|
|
let index = RIL.GECKO_SMS_MESSAGE_CLASSES.indexOf(aMessageClass);
|
|
|
|
return (index != -1)
|
|
|
|
? index
|
2014-10-24 05:18:26 +00:00
|
|
|
: Ci.nsICellBroadcastService.GSM_MESSAGE_CLASS_NORMAL;
|
2014-09-23 10:27:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_convertCbEtwsWarningType: function(aWarningType) {
|
|
|
|
return (aWarningType != null)
|
|
|
|
? aWarningType
|
|
|
|
: Ci.nsICellBroadcastService.GSM_ETWS_WARNING_INVALID;
|
|
|
|
},
|
|
|
|
|
2014-08-13 10:28:34 +00:00
|
|
|
handleCellbroadcastMessageReceived: function(aMessage) {
|
|
|
|
let etwsInfo = aMessage.etws;
|
|
|
|
let hasEtwsInfo = etwsInfo != null;
|
|
|
|
let serviceCategory = (aMessage.serviceCategory)
|
|
|
|
? aMessage.serviceCategory
|
|
|
|
: Ci.nsICellBroadcastService.CDMA_SERVICE_CATEGORY_INVALID;
|
|
|
|
|
|
|
|
gCellBroadcastService
|
|
|
|
.notifyMessageReceived(this.clientId,
|
2014-09-23 10:27:03 +00:00
|
|
|
this._convertCbGsmGeographicalScope(aMessage.geographicalScope),
|
2014-08-13 10:28:34 +00:00
|
|
|
aMessage.messageCode,
|
|
|
|
aMessage.messageId,
|
|
|
|
aMessage.language,
|
|
|
|
aMessage.fullBody,
|
2014-09-23 10:27:03 +00:00
|
|
|
this._convertCbMessageClass(aMessage.messageClass),
|
2014-09-15 09:44:46 +00:00
|
|
|
Date.now(),
|
2014-08-13 10:28:34 +00:00
|
|
|
serviceCategory,
|
|
|
|
hasEtwsInfo,
|
2014-09-23 10:27:03 +00:00
|
|
|
(hasEtwsInfo)
|
|
|
|
? this._convertCbEtwsWarningType(etwsInfo.warningType)
|
|
|
|
: Ci.nsICellBroadcastService.GSM_ETWS_WARNING_INVALID,
|
2014-08-13 10:28:34 +00:00
|
|
|
hasEtwsInfo ? etwsInfo.emergencyUserAlert : false,
|
|
|
|
hasEtwsInfo ? etwsInfo.popup : false);
|
|
|
|
},
|
|
|
|
|
2014-10-03 06:23:41 +00:00
|
|
|
handleCdmaInformationRecords: function(aRecords) {
|
|
|
|
if (DEBUG) this.debug("cdma-info-rec-received: " + JSON.stringify(aRecords));
|
|
|
|
|
|
|
|
let clientId = this.clientId;
|
|
|
|
|
|
|
|
aRecords.forEach(function(aRecord) {
|
|
|
|
if (aRecord.display) {
|
|
|
|
gMobileConnectionService
|
|
|
|
.notifyCdmaInfoRecDisplay(clientId, aRecord.display);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aRecord.calledNumber) {
|
|
|
|
gMobileConnectionService
|
|
|
|
.notifyCdmaInfoRecCalledPartyNumber(clientId,
|
|
|
|
aRecord.calledNumber.type,
|
|
|
|
aRecord.calledNumber.plan,
|
|
|
|
aRecord.calledNumber.number,
|
|
|
|
aRecord.calledNumber.pi,
|
|
|
|
aRecord.calledNumber.si);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aRecord.callingNumber) {
|
|
|
|
gMobileConnectionService
|
|
|
|
.notifyCdmaInfoRecCallingPartyNumber(clientId,
|
|
|
|
aRecord.callingNumber.type,
|
|
|
|
aRecord.callingNumber.plan,
|
|
|
|
aRecord.callingNumber.number,
|
|
|
|
aRecord.callingNumber.pi,
|
|
|
|
aRecord.callingNumber.si);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aRecord.connectedNumber) {
|
|
|
|
gMobileConnectionService
|
|
|
|
.notifyCdmaInfoRecConnectedPartyNumber(clientId,
|
|
|
|
aRecord.connectedNumber.type,
|
|
|
|
aRecord.connectedNumber.plan,
|
|
|
|
aRecord.connectedNumber.number,
|
|
|
|
aRecord.connectedNumber.pi,
|
|
|
|
aRecord.connectedNumber.si);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aRecord.signal) {
|
|
|
|
gMobileConnectionService
|
|
|
|
.notifyCdmaInfoRecSignal(clientId,
|
|
|
|
aRecord.signal.type,
|
|
|
|
aRecord.signal.alertPitch,
|
|
|
|
aRecord.signal.signal);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aRecord.redirect) {
|
|
|
|
gMobileConnectionService
|
|
|
|
.notifyCdmaInfoRecRedirectingNumber(clientId,
|
|
|
|
aRecord.redirect.type,
|
|
|
|
aRecord.redirect.plan,
|
|
|
|
aRecord.redirect.number,
|
|
|
|
aRecord.redirect.pi,
|
|
|
|
aRecord.redirect.si,
|
|
|
|
aRecord.redirect.reason);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aRecord.lineControl) {
|
|
|
|
gMobileConnectionService
|
|
|
|
.notifyCdmaInfoRecLineControl(clientId,
|
|
|
|
aRecord.lineControl.polarityIncluded,
|
|
|
|
aRecord.lineControl.toggle,
|
|
|
|
aRecord.lineControl.reverse,
|
|
|
|
aRecord.lineControl.powerDenial);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aRecord.clirCause) {
|
|
|
|
gMobileConnectionService
|
|
|
|
.notifyCdmaInfoRecClir(clientId,
|
|
|
|
aRecord.clirCause);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aRecord.audioControl) {
|
|
|
|
gMobileConnectionService
|
|
|
|
.notifyCdmaInfoRecAudioControl(clientId,
|
|
|
|
aRecord.audioControl.upLink,
|
|
|
|
aRecord.audioControl.downLink);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2012-04-19 21:33:25 +00:00
|
|
|
// nsIObserver
|
2012-03-12 23:45:57 +00:00
|
|
|
|
2014-01-13 02:44:40 +00:00
|
|
|
observe: function(subject, topic, data) {
|
2012-04-24 20:46:42 +00:00
|
|
|
switch (topic) {
|
|
|
|
case kMozSettingsChangedObserverTopic:
|
2014-09-16 17:15:16 +00:00
|
|
|
if ("wrappedJSObject" in subject) {
|
|
|
|
subject = subject.wrappedJSObject;
|
|
|
|
}
|
|
|
|
this.handleSettingsChange(subject.key, subject.value, subject.isInternalChange);
|
2012-04-24 20:46:42 +00:00
|
|
|
break;
|
2012-10-23 07:15:53 +00:00
|
|
|
case kSysClockChangeObserverTopic:
|
2013-06-22 14:22:05 +00:00
|
|
|
let offset = parseInt(data, 10);
|
2012-10-23 07:15:53 +00:00
|
|
|
if (this._lastNitzMessage) {
|
2013-06-22 14:22:05 +00:00
|
|
|
this._lastNitzMessage.receiveTimeInMS += offset;
|
|
|
|
}
|
|
|
|
this._sntp.updateOffset(offset);
|
|
|
|
break;
|
2014-03-10 03:36:42 +00:00
|
|
|
case kNetworkConnStateChangedTopic:
|
2015-07-29 06:06:00 +00:00
|
|
|
let networkInfo = subject.QueryInterface(Ci.nsINetworkInfo);
|
|
|
|
if (networkInfo.state != Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED) {
|
2013-10-29 08:13:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SNTP can only update when we have mobile or Wifi connections.
|
2015-07-29 06:06:00 +00:00
|
|
|
if (networkInfo.type != NETWORK_TYPE_WIFI &&
|
|
|
|
networkInfo.type != NETWORK_TYPE_MOBILE) {
|
2013-10-29 08:13:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the network comes from RIL, make sure the RIL service is matched.
|
2015-07-29 06:06:00 +00:00
|
|
|
if (subject instanceof Ci.nsIRilNetworkInfo) {
|
|
|
|
networkInfo = subject.QueryInterface(Ci.nsIRilNetworkInfo);
|
|
|
|
if (networkInfo.serviceId != this.clientId) {
|
2013-10-29 08:13:06 +00:00
|
|
|
return;
|
2013-06-22 14:22:05 +00:00
|
|
|
}
|
2012-10-23 07:15:53 +00:00
|
|
|
}
|
2013-10-29 08:13:06 +00:00
|
|
|
|
|
|
|
// SNTP won't update unless the SNTP is already expired.
|
|
|
|
if (this._sntp.isExpired()) {
|
|
|
|
this._sntp.request();
|
|
|
|
}
|
2012-04-24 20:46:42 +00:00
|
|
|
break;
|
2013-06-06 07:28:59 +00:00
|
|
|
case kScreenStateChangedTopic:
|
2013-08-14 10:11:47 +00:00
|
|
|
this.workerMessenger.send("setScreenState", { on: (data === "on") });
|
2013-06-06 07:28:59 +00:00
|
|
|
break;
|
2012-04-19 21:33:25 +00:00
|
|
|
}
|
2012-03-12 23:45:57 +00:00
|
|
|
},
|
|
|
|
|
2013-06-22 14:22:05 +00:00
|
|
|
// Flag to determine whether to update system clock automatically. It
|
2013-11-21 14:09:14 +00:00
|
|
|
// corresponds to the "time.clock.automatic-update.enabled" setting.
|
2013-06-22 14:22:05 +00:00
|
|
|
_clockAutoUpdateEnabled: null,
|
|
|
|
|
|
|
|
// Flag to determine whether to update system timezone automatically. It
|
2013-11-21 14:09:14 +00:00
|
|
|
// corresponds to the "time.clock.automatic-update.enabled" setting.
|
2013-06-22 14:22:05 +00:00
|
|
|
_timezoneAutoUpdateEnabled: null,
|
2012-09-28 13:08:04 +00:00
|
|
|
|
2012-10-23 07:15:53 +00:00
|
|
|
// Remember the last NITZ message so that we can set the time based on
|
|
|
|
// the network immediately when users enable network-based time.
|
|
|
|
_lastNitzMessage: null,
|
|
|
|
|
2013-06-22 14:22:05 +00:00
|
|
|
// Object that handles SNTP.
|
|
|
|
_sntp: null,
|
|
|
|
|
2012-12-04 02:41:39 +00:00
|
|
|
// Cell Broadcast settings values.
|
2014-04-03 08:33:56 +00:00
|
|
|
_cellBroadcastSearchList: null,
|
2012-12-04 02:41:39 +00:00
|
|
|
|
2014-08-28 04:01:31 +00:00
|
|
|
handleSettingsChange: function(aName, aResult, aIsInternalSetting) {
|
2013-01-25 10:06:24 +00:00
|
|
|
// Don't allow any content processes to modify the setting
|
2013-06-22 14:22:05 +00:00
|
|
|
// "time.clock.automatic-update.available" except for the chrome process.
|
2013-10-24 08:14:59 +00:00
|
|
|
if (aName === kSettingsClockAutoUpdateAvailable &&
|
2014-08-28 04:01:31 +00:00
|
|
|
!aIsInternalSetting) {
|
2013-06-22 14:22:05 +00:00
|
|
|
let isClockAutoUpdateAvailable = this._lastNitzMessage !== null ||
|
|
|
|
this._sntp.isAvailable();
|
|
|
|
if (aResult !== isClockAutoUpdateAvailable) {
|
2014-01-23 08:44:20 +00:00
|
|
|
if (DEBUG) {
|
|
|
|
debug("Content processes cannot modify 'time.clock.automatic-update.available'. Restore!");
|
|
|
|
}
|
2013-06-22 14:22:05 +00:00
|
|
|
// Restore the setting to the current value.
|
|
|
|
this.setClockAutoUpdateAvailable(isClockAutoUpdateAvailable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't allow any content processes to modify the setting
|
|
|
|
// "time.timezone.automatic-update.available" except for the chrome
|
|
|
|
// process.
|
2013-10-24 08:14:59 +00:00
|
|
|
if (aName === kSettingsTimezoneAutoUpdateAvailable &&
|
2014-08-28 04:01:31 +00:00
|
|
|
!aIsInternalSetting) {
|
2013-06-22 14:22:05 +00:00
|
|
|
let isTimezoneAutoUpdateAvailable = this._lastNitzMessage !== null;
|
|
|
|
if (aResult !== isTimezoneAutoUpdateAvailable) {
|
|
|
|
if (DEBUG) {
|
|
|
|
this.debug("Content processes cannot modify 'time.timezone.automatic-update.available'. Restore!");
|
|
|
|
}
|
|
|
|
// Restore the setting to the current value.
|
|
|
|
this.setTimezoneAutoUpdateAvailable(isTimezoneAutoUpdateAvailable);
|
2013-07-02 09:36:58 +00:00
|
|
|
}
|
2013-01-25 10:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.handle(aName, aResult);
|
|
|
|
},
|
|
|
|
|
2012-09-28 06:02:57 +00:00
|
|
|
// nsISettingsServiceCallback
|
2014-01-13 02:44:40 +00:00
|
|
|
handle: function(aName, aResult) {
|
2012-08-01 14:54:04 +00:00
|
|
|
switch(aName) {
|
2013-10-24 08:14:59 +00:00
|
|
|
case kSettingsClockAutoUpdateEnabled:
|
2013-06-22 14:22:05 +00:00
|
|
|
this._clockAutoUpdateEnabled = aResult;
|
|
|
|
if (!this._clockAutoUpdateEnabled) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the latest cached NITZ time if it's available.
|
|
|
|
if (this._lastNitzMessage) {
|
|
|
|
this.setClockByNitz(this._lastNitzMessage);
|
2015-07-29 06:06:00 +00:00
|
|
|
} else if (gNetworkManager.activeNetworkInfo &&
|
|
|
|
gNetworkManager.activeNetworkInfo.state ==
|
|
|
|
Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED) {
|
2013-06-22 14:22:05 +00:00
|
|
|
// Set the latest cached SNTP time if it's available.
|
|
|
|
if (!this._sntp.isExpired()) {
|
|
|
|
this.setClockBySntp(this._sntp.getOffset());
|
|
|
|
} else {
|
|
|
|
// Or refresh the SNTP.
|
|
|
|
this._sntp.request();
|
|
|
|
}
|
2014-02-18 14:41:36 +00:00
|
|
|
} else {
|
|
|
|
// Set a sane minimum time.
|
|
|
|
let buildTime = libcutils.property_get("ro.build.date.utc", "0") * 1000;
|
|
|
|
let file = FileUtils.File("/system/b2g/b2g");
|
|
|
|
if (file.lastModifiedTime > buildTime) {
|
|
|
|
buildTime = file.lastModifiedTime;
|
|
|
|
}
|
|
|
|
if (buildTime > Date.now()) {
|
|
|
|
gTimeService.set(buildTime);
|
|
|
|
}
|
2013-06-22 14:22:05 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-10-24 08:14:59 +00:00
|
|
|
case kSettingsTimezoneAutoUpdateEnabled:
|
2013-06-22 14:22:05 +00:00
|
|
|
this._timezoneAutoUpdateEnabled = aResult;
|
2012-10-23 07:15:53 +00:00
|
|
|
|
2013-06-22 14:22:05 +00:00
|
|
|
if (this._timezoneAutoUpdateEnabled) {
|
|
|
|
// Apply the latest cached NITZ for timezone if it's available.
|
|
|
|
if (this._timezoneAutoUpdateEnabled && this._lastNitzMessage) {
|
|
|
|
this.setTimezoneByNitz(this._lastNitzMessage);
|
|
|
|
}
|
2012-10-23 07:15:53 +00:00
|
|
|
}
|
2012-09-28 06:02:57 +00:00
|
|
|
break;
|
2013-06-10 02:41:14 +00:00
|
|
|
}
|
2012-05-24 05:12:07 +00:00
|
|
|
},
|
2012-09-05 09:36:01 +00:00
|
|
|
|
2014-01-13 02:44:40 +00:00
|
|
|
handleError: function(aErrorMessage) {
|
2013-12-03 06:18:32 +00:00
|
|
|
if (DEBUG) {
|
|
|
|
this.debug("There was an error while reading RIL settings.");
|
|
|
|
}
|
2012-05-24 05:12:07 +00:00
|
|
|
},
|
|
|
|
|
2013-07-02 09:36:37 +00:00
|
|
|
// nsIRadioInterface
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2013-12-03 06:18:32 +00:00
|
|
|
// TODO: Bug 928861 - B2G NetworkManager: Provide a more generic function
|
|
|
|
// for connecting
|
2014-11-25 01:44:33 +00:00
|
|
|
setupDataCallByType: function(networkType) {
|
2015-05-20 02:08:39 +00:00
|
|
|
let connHandler = gDataCallManager.getDataCallHandler(this.clientId);
|
2014-11-25 01:44:33 +00:00
|
|
|
connHandler.setupDataCallByType(networkType);
|
2013-06-28 01:46:00 +00:00
|
|
|
},
|
2013-01-23 04:05:34 +00:00
|
|
|
|
2013-12-03 06:18:32 +00:00
|
|
|
// TODO: Bug 928861 - B2G NetworkManager: Provide a more generic function
|
|
|
|
// for connecting
|
2014-11-25 01:44:33 +00:00
|
|
|
deactivateDataCallByType: function(networkType) {
|
2015-05-20 02:08:39 +00:00
|
|
|
let connHandler = gDataCallManager.getDataCallHandler(this.clientId);
|
2014-11-25 01:44:33 +00:00
|
|
|
connHandler.deactivateDataCallByType(networkType);
|
2013-06-28 01:46:00 +00:00
|
|
|
},
|
|
|
|
|
2013-12-03 06:18:32 +00:00
|
|
|
// TODO: Bug 904514 - [meta] NetworkManager enhancement
|
2014-11-25 01:44:33 +00:00
|
|
|
getDataCallStateByType: function(networkType) {
|
2015-05-20 02:08:39 +00:00
|
|
|
let connHandler = gDataCallManager.getDataCallHandler(this.clientId);
|
2014-11-25 01:44:33 +00:00
|
|
|
return connHandler.getDataCallStateByType(networkType);
|
2012-09-26 12:57:37 +00:00
|
|
|
},
|
|
|
|
|
2014-01-13 02:44:44 +00:00
|
|
|
sendWorkerMessage: function(rilMessageType, message, callback) {
|
2014-02-10 11:55:22 +00:00
|
|
|
// Special handler for setRadioEnabled.
|
|
|
|
if (rilMessageType === "setRadioEnabled") {
|
|
|
|
// Forward it to gRadioEnabledController.
|
|
|
|
gRadioEnabledController.setRadioEnabled(this.clientId, message,
|
|
|
|
callback.handleResponse);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-21 09:46:58 +00:00
|
|
|
if (callback) {
|
|
|
|
this.workerMessenger.send(rilMessageType, message, function(response) {
|
|
|
|
return callback.handleResponse(response);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.workerMessenger.send(rilMessageType, message);
|
|
|
|
}
|
2014-06-24 23:27:00 +00:00
|
|
|
},
|
2012-04-12 04:01:49 +00:00
|
|
|
};
|
2012-03-12 23:46:08 +00:00
|
|
|
|
2012-10-31 16:13:28 +00:00
|
|
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RadioInterfaceLayer]);
|