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");
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
var RIL = {};
|
|
|
|
Cu.import("resource://gre/modules/ril_consts.js", RIL);
|
|
|
|
|
2012-06-19 22:52:06 +00:00
|
|
|
// set to true in ril_consts.js to see debug messages
|
|
|
|
const DEBUG = RIL.DEBUG_RIL;
|
2011-12-05 07:58:27 +00:00
|
|
|
|
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}");
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
const nsIAudioManager = Ci.nsIAudioManager;
|
2012-01-19 20:53:32 +00:00
|
|
|
const nsIRadioInterfaceLayer = Ci.nsIRadioInterfaceLayer;
|
2011-12-12 18:22:26 +00:00
|
|
|
|
2012-04-19 21:33:25 +00:00
|
|
|
const kNetworkInterfaceStateChangedTopic = "network-interface-state-changed";
|
2011-12-24 05:02:52 +00:00
|
|
|
const kSmsReceivedObserverTopic = "sms-received";
|
2012-04-05 21:16:56 +00:00
|
|
|
const kSmsDeliveredObserverTopic = "sms-delivered";
|
2012-04-24 20:46:42 +00:00
|
|
|
const kMozSettingsChangedObserverTopic = "mozsettings-changed";
|
2011-12-24 05:02:52 +00:00
|
|
|
const DOM_SMS_DELIVERY_RECEIVED = "received";
|
2012-02-19 23:44:29 +00:00
|
|
|
const DOM_SMS_DELIVERY_SENT = "sent";
|
2011-12-24 05:02:52 +00:00
|
|
|
|
2012-04-24 15:44:42 +00:00
|
|
|
const RIL_IPC_MSG_NAMES = [
|
2012-06-13 02:46:41 +00:00
|
|
|
"RIL:GetRilContext",
|
2012-04-24 15:44:42 +00:00
|
|
|
"RIL:EnumerateCalls",
|
|
|
|
"RIL:GetMicrophoneMuted",
|
|
|
|
"RIL:SetMicrophoneMuted",
|
|
|
|
"RIL:GetSpeakerEnabled",
|
|
|
|
"RIL:SetSpeakerEnabled",
|
|
|
|
"RIL:StartTone",
|
|
|
|
"RIL:StopTone",
|
|
|
|
"RIL:Dial",
|
2012-07-20 12:08:24 +00:00
|
|
|
"RIL:DialEmergency",
|
2012-04-24 15:44:42 +00:00
|
|
|
"RIL:HangUp",
|
|
|
|
"RIL:AnswerCall",
|
|
|
|
"RIL:RejectCall",
|
|
|
|
"RIL:HoldCall",
|
|
|
|
"RIL:ResumeCall",
|
2012-06-01 21:10:39 +00:00
|
|
|
"RIL:GetAvailableNetworks",
|
2012-06-19 22:52:06 +00:00
|
|
|
"RIL:SelectNetwork",
|
|
|
|
"RIL:SelectNetworkAuto",
|
2012-04-12 04:01:49 +00:00
|
|
|
"RIL:GetCardLock",
|
|
|
|
"RIL:UnlockCardLock",
|
2012-06-09 21:07:18 +00:00
|
|
|
"RIL:SetCardLock",
|
|
|
|
"RIL:SendUSSD",
|
2012-04-10 12:04:27 +00:00
|
|
|
"RIL:CancelUSSD",
|
|
|
|
"RIL:SendStkResponse",
|
|
|
|
"RIL:SendStkMenuSelection"
|
2012-04-24 15:44:42 +00:00
|
|
|
];
|
|
|
|
|
2011-12-24 05:02:52 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gSmsService",
|
|
|
|
"@mozilla.org/sms/smsservice;1",
|
|
|
|
"nsISmsService");
|
2011-12-12 18:22:26 +00:00
|
|
|
|
2012-02-19 23:44:29 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gSmsRequestManager",
|
|
|
|
"@mozilla.org/sms/smsrequestmanager;1",
|
|
|
|
"nsISmsRequestManager");
|
|
|
|
|
2012-02-20 17:12:37 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gSmsDatabaseService",
|
|
|
|
"@mozilla.org/sms/rilsmsdatabaseservice;1",
|
|
|
|
"nsISmsDatabaseService");
|
|
|
|
|
2012-04-19 21:33:25 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
|
|
|
|
"@mozilla.org/parentprocessmessagemanager;1",
|
2012-08-27 14:13:02 +00:00
|
|
|
"nsIMessageBroadcaster");
|
2012-04-19 21:33:25 +00:00
|
|
|
|
2012-05-24 05:12:07 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService",
|
|
|
|
"@mozilla.org/settingsService;1",
|
|
|
|
"nsISettingsService");
|
|
|
|
|
2012-08-31 14:45:32 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gSystemMessenger",
|
|
|
|
"@mozilla.org/system-message-internal;1",
|
|
|
|
"nsISystemMessagesInternal");
|
|
|
|
|
2012-06-04 05:04:28 +00:00
|
|
|
XPCOMUtils.defineLazyGetter(this, "WAP", function () {
|
|
|
|
let WAP = {};
|
|
|
|
Cu.import("resource://gre/modules/WapPushManager.js", WAP);
|
|
|
|
return WAP;
|
|
|
|
});
|
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
function convertRILCallState(state) {
|
|
|
|
switch (state) {
|
|
|
|
case RIL.CALL_STATE_ACTIVE:
|
2012-01-19 20:53:32 +00:00
|
|
|
return nsIRadioInterfaceLayer.CALL_STATE_CONNECTED;
|
2012-01-09 22:28:47 +00:00
|
|
|
case RIL.CALL_STATE_HOLDING:
|
2012-01-19 20:53:32 +00:00
|
|
|
return nsIRadioInterfaceLayer.CALL_STATE_HELD;
|
2012-01-09 22:28:47 +00:00
|
|
|
case RIL.CALL_STATE_DIALING:
|
2012-01-19 20:53:32 +00:00
|
|
|
return nsIRadioInterfaceLayer.CALL_STATE_DIALING;
|
2012-01-09 22:28:47 +00:00
|
|
|
case RIL.CALL_STATE_ALERTING:
|
2012-03-14 11:03:33 +00:00
|
|
|
return nsIRadioInterfaceLayer.CALL_STATE_ALERTING;
|
2012-01-09 22:28:47 +00:00
|
|
|
case RIL.CALL_STATE_INCOMING:
|
|
|
|
case RIL.CALL_STATE_WAITING:
|
2012-04-05 08:12:42 +00:00
|
|
|
return nsIRadioInterfaceLayer.CALL_STATE_INCOMING;
|
2012-06-18 09:51:11 +00:00
|
|
|
case RIL.CALL_STATE_BUSY:
|
|
|
|
return nsIRadioInterfaceLayer.CALL_STATE_BUSY;
|
2012-01-09 22:28:47 +00:00
|
|
|
default:
|
|
|
|
throw new Error("Unknown rilCallState: " + state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-12 18:22:26 +00:00
|
|
|
/**
|
|
|
|
* Fake nsIAudioManager implementation so that we can run the telephony
|
|
|
|
* code in a non-Gonk build.
|
|
|
|
*/
|
|
|
|
let FakeAudioManager = {
|
|
|
|
microphoneMuted: false,
|
|
|
|
masterVolume: 1.0,
|
|
|
|
masterMuted: false,
|
2012-01-09 22:28:47 +00:00
|
|
|
phoneState: nsIAudioManager.PHONE_STATE_CURRENT,
|
2011-12-12 18:22:26 +00:00
|
|
|
_forceForUse: {},
|
|
|
|
setForceForUse: function setForceForUse(usage, force) {
|
|
|
|
this._forceForUse[usage] = force;
|
|
|
|
},
|
|
|
|
getForceForUse: function setForceForUse(usage) {
|
2012-01-09 22:28:47 +00:00
|
|
|
return this._forceForUse[usage] || nsIAudioManager.FORCE_NONE;
|
2011-12-12 18:22:26 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
XPCOMUtils.defineLazyGetter(this, "gAudioManager", function getAudioManager() {
|
|
|
|
try {
|
|
|
|
return Cc["@mozilla.org/telephony/audiomanager;1"]
|
2012-01-09 22:28:47 +00:00
|
|
|
.getService(nsIAudioManager);
|
2011-12-12 18:22:26 +00:00
|
|
|
} catch (ex) {
|
|
|
|
//TODO on the phone this should not fall back as silently.
|
|
|
|
debug("Using fake audio manager.");
|
|
|
|
return FakeAudioManager;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2012-01-19 20:53:32 +00:00
|
|
|
function RadioInterfaceLayer() {
|
2012-04-19 21:33:25 +00:00
|
|
|
debug("Starting RIL Worker");
|
2011-12-05 07:58:27 +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);
|
2012-04-19 21:33:25 +00:00
|
|
|
|
2012-06-13 02:46:41 +00:00
|
|
|
this.rilContext = {
|
2012-03-20 23:18:41 +00:00
|
|
|
radioState: RIL.GECKO_RADIOSTATE_UNAVAILABLE,
|
|
|
|
cardState: RIL.GECKO_CARDSTATE_UNAVAILABLE,
|
2012-04-18 10:07:29 +00:00
|
|
|
icc: null,
|
2012-04-19 21:33:25 +00:00
|
|
|
|
|
|
|
// These objects implement the nsIDOMMozMobileConnectionInfo interface,
|
2012-08-16 01:36:56 +00:00
|
|
|
// although the actual implementation lives in the content process. So are
|
|
|
|
// the child attributes `network` and `cell`, which implement
|
|
|
|
// nsIDOMMozMobileNetworkInfo and nsIDOMMozMobileCellInfo respectively.
|
2012-04-19 21:33:25 +00:00
|
|
|
voice: {connected: false,
|
|
|
|
emergencyCallsOnly: false,
|
|
|
|
roaming: false,
|
2012-06-12 21:05:50 +00:00
|
|
|
network: null,
|
2012-08-16 01:36:56 +00:00
|
|
|
cell: null,
|
2012-04-19 21:33:25 +00:00
|
|
|
type: null,
|
|
|
|
signalStrength: null,
|
|
|
|
relSignalStrength: null},
|
2012-06-13 02:46:41 +00:00
|
|
|
data: {connected: false,
|
2012-04-19 21:33:25 +00:00
|
|
|
emergencyCallsOnly: false,
|
|
|
|
roaming: false,
|
2012-06-12 21:05:50 +00:00
|
|
|
network: null,
|
2012-08-16 01:36:56 +00:00
|
|
|
cell: null,
|
2012-04-19 21:33:25 +00:00
|
|
|
type: null,
|
|
|
|
signalStrength: null,
|
|
|
|
relSignalStrength: null},
|
2011-12-07 06:57:19 +00:00
|
|
|
};
|
2012-05-24 05:12:07 +00:00
|
|
|
|
2012-05-25 17:37:37 +00:00
|
|
|
// Read the 'ril.radio.disabled' setting in order to start with a known
|
|
|
|
// value at boot time.
|
2012-05-24 05:12:07 +00:00
|
|
|
gSettingsService.getLock().get("ril.radio.disabled", this);
|
|
|
|
|
2012-08-01 14:54:04 +00:00
|
|
|
// Read the APN data form the setting DB.
|
|
|
|
gSettingsService.getLock().get("ril.data.apn", this);
|
|
|
|
gSettingsService.getLock().get("ril.data.user", this);
|
|
|
|
gSettingsService.getLock().get("ril.data.passwd", this);
|
2012-08-01 14:55:43 +00:00
|
|
|
gSettingsService.getLock().get("ril.data.httpProxyHost", this);
|
|
|
|
gSettingsService.getLock().get("ril.data.httpProxyPort", this);
|
2012-08-01 14:54:04 +00:00
|
|
|
gSettingsService.getLock().get("ril.data.roaming_enabled", this);
|
|
|
|
gSettingsService.getLock().get("ril.data.enabled", this);
|
|
|
|
this._dataCallSettingsToRead = ["ril.data.enabled",
|
|
|
|
"ril.data.roaming_enabled",
|
|
|
|
"ril.data.apn",
|
|
|
|
"ril.data.user",
|
2012-08-01 14:55:43 +00:00
|
|
|
"ril.data.passwd",
|
|
|
|
"ril.data.httpProxyHost",
|
|
|
|
"ril.data.httpProxyPort"];
|
2012-08-01 14:54:04 +00:00
|
|
|
|
2012-08-17 03:46:34 +00:00
|
|
|
this._messageManagerByRequest = {};
|
|
|
|
|
2012-04-24 15:44:42 +00:00
|
|
|
for each (let msgname in RIL_IPC_MSG_NAMES) {
|
|
|
|
ppmm.addMessageListener(msgname, this);
|
|
|
|
}
|
2012-04-19 21:33:25 +00:00
|
|
|
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
2012-04-24 20:46:42 +00:00
|
|
|
Services.obs.addObserver(this, kMozSettingsChangedObserverTopic, false);
|
2012-04-19 21:33:25 +00:00
|
|
|
|
2012-04-05 21:16:56 +00:00
|
|
|
this._sentSmsEnvelopes = {};
|
2012-06-04 05:04:28 +00:00
|
|
|
|
2012-04-23 23:43:32 +00:00
|
|
|
this.portAddressedSmsApps = {};
|
2012-06-04 05:04:28 +00:00
|
|
|
this.portAddressedSmsApps[WAP.WDP_PORT_PUSH] = this.handleSmsWdpPortPush.bind(this);
|
2011-12-05 07:58:27 +00:00
|
|
|
}
|
2012-01-19 20:53:32 +00:00
|
|
|
RadioInterfaceLayer.prototype = {
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2012-01-19 20:53:32 +00:00
|
|
|
classID: RADIOINTERFACELAYER_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({classID: RADIOINTERFACELAYER_CID,
|
|
|
|
classDescription: "RadioInterfaceLayer",
|
2012-01-09 23:18:23 +00:00
|
|
|
interfaces: [Ci.nsIWorkerHolder,
|
2012-01-19 20:53:32 +00:00
|
|
|
Ci.nsIRadioInterfaceLayer]}),
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2012-01-09 23:18:23 +00:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWorkerHolder,
|
2012-04-24 20:46:42 +00:00
|
|
|
Ci.nsIRadioInterfaceLayer,
|
2012-05-24 05:12:07 +00:00
|
|
|
Ci.nsIObserver,
|
|
|
|
Ci.nsISettingsServiceCallback]),
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2012-04-19 21:33:25 +00:00
|
|
|
/**
|
|
|
|
* Process a message from the content process.
|
|
|
|
*/
|
|
|
|
receiveMessage: function receiveMessage(msg) {
|
|
|
|
debug("Received '" + msg.name + "' message from content process");
|
|
|
|
switch (msg.name) {
|
2012-06-13 02:46:41 +00:00
|
|
|
case "RIL:GetRilContext":
|
2012-04-19 21:33:25 +00:00
|
|
|
// This message is sync.
|
2012-06-13 02:46:41 +00:00
|
|
|
return this.rilContext;
|
2012-04-24 15:44:42 +00:00
|
|
|
case "RIL:EnumerateCalls":
|
2012-08-17 03:46:34 +00:00
|
|
|
this.saveRequestTarget(msg);
|
|
|
|
this.enumerateCalls(msg.json);
|
2012-04-24 15:44:42 +00:00
|
|
|
break;
|
|
|
|
case "RIL:GetMicrophoneMuted":
|
|
|
|
// This message is sync.
|
|
|
|
return this.microphoneMuted;
|
|
|
|
case "RIL:SetMicrophoneMuted":
|
|
|
|
this.microphoneMuted = msg.json;
|
|
|
|
break;
|
|
|
|
case "RIL:GetSpeakerEnabled":
|
|
|
|
// This message is sync.
|
|
|
|
return this.speakerEnabled;
|
|
|
|
case "RIL:SetSpeakerEnabled":
|
|
|
|
this.speakerEnabled = msg.json;
|
|
|
|
break;
|
|
|
|
case "RIL:StartTone":
|
|
|
|
this.startTone(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:StopTone":
|
|
|
|
this.stopTone();
|
|
|
|
break;
|
|
|
|
case "RIL:Dial":
|
|
|
|
this.dial(msg.json);
|
|
|
|
break;
|
2012-07-20 12:08:24 +00:00
|
|
|
case "RIL:DialEmergency":
|
|
|
|
this.dialEmergency(msg.json);
|
|
|
|
break;
|
2012-04-24 15:44:42 +00:00
|
|
|
case "RIL:HangUp":
|
|
|
|
this.hangUp(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:AnswerCall":
|
|
|
|
this.answerCall(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:RejectCall":
|
|
|
|
this.rejectCall(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:HoldCall":
|
|
|
|
this.holdCall(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:ResumeCall":
|
|
|
|
this.resumeCall(msg.json);
|
|
|
|
break;
|
2012-06-01 21:10:39 +00:00
|
|
|
case "RIL:GetAvailableNetworks":
|
2012-08-17 03:46:34 +00:00
|
|
|
this.saveRequestTarget(msg);
|
|
|
|
this.getAvailableNetworks(msg.json.requestId);
|
2012-06-01 21:10:39 +00:00
|
|
|
break;
|
2012-06-19 22:52:06 +00:00
|
|
|
case "RIL:SelectNetwork":
|
2012-08-17 03:46:34 +00:00
|
|
|
this.saveRequestTarget(msg);
|
2012-06-19 22:52:06 +00:00
|
|
|
this.selectNetwork(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:SelectNetworkAuto":
|
2012-08-17 03:46:34 +00:00
|
|
|
this.saveRequestTarget(msg);
|
|
|
|
this.selectNetworkAuto(msg.json.requestId);
|
2012-04-12 04:01:49 +00:00
|
|
|
case "RIL:GetCardLock":
|
2012-08-17 03:46:34 +00:00
|
|
|
this.saveRequestTarget(msg);
|
2012-04-12 04:01:49 +00:00
|
|
|
this.getCardLock(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:UnlockCardLock":
|
2012-08-17 03:46:34 +00:00
|
|
|
this.saveRequestTarget(msg);
|
2012-04-12 04:01:49 +00:00
|
|
|
this.unlockCardLock(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:SetCardLock":
|
2012-08-17 03:46:34 +00:00
|
|
|
this.saveRequestTarget(msg);
|
2012-04-12 04:01:49 +00:00
|
|
|
this.setCardLock(msg.json);
|
|
|
|
break;
|
2012-06-09 21:07:18 +00:00
|
|
|
case "RIL:SendUSSD":
|
2012-08-17 03:46:34 +00:00
|
|
|
this.saveRequestTarget(msg);
|
2012-06-09 21:07:18 +00:00
|
|
|
this.sendUSSD(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:CancelUSSD":
|
2012-08-17 03:46:34 +00:00
|
|
|
this.saveRequestTarget(msg);
|
2012-06-09 21:07:18 +00:00
|
|
|
this.cancelUSSD(msg.json);
|
|
|
|
break;
|
2012-04-10 12:04:27 +00:00
|
|
|
case "RIL:SendStkResponse":
|
|
|
|
this.sendStkResponse(msg.json);
|
|
|
|
break;
|
|
|
|
case "RIL:SendStkMenuSelection":
|
|
|
|
this.sendStkMenuSelection(msg.json);
|
|
|
|
break;
|
2012-04-19 21:33:25 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-12-05 07:58:27 +00:00
|
|
|
onerror: function onerror(event) {
|
|
|
|
debug("Got an error: " + event.filename + ":" +
|
|
|
|
event.lineno + ": " + event.message + "\n");
|
2012-01-09 22:28:47 +00:00
|
|
|
event.preventDefault();
|
2011-12-05 07:58:27 +00:00
|
|
|
},
|
|
|
|
|
2011-12-12 18:22:26 +00:00
|
|
|
/**
|
2012-04-19 21:33:25 +00:00
|
|
|
* Process the incoming message from the RIL worker. This roughly
|
|
|
|
* works as follows:
|
|
|
|
* (1) Update local state.
|
2011-12-12 18:22:26 +00:00
|
|
|
* (2) Update state in related systems such as the audio.
|
2012-04-19 21:33:25 +00:00
|
|
|
* (3) Multiplex the message to callbacks / listeners (typically the DOM).
|
2011-12-12 18:22:26 +00:00
|
|
|
*/
|
2011-12-05 07:58:27 +00:00
|
|
|
onmessage: function onmessage(event) {
|
|
|
|
let message = event.data;
|
2012-04-19 21:33:25 +00:00
|
|
|
debug("Received message from worker: " + JSON.stringify(message));
|
2012-08-06 21:28:03 +00:00
|
|
|
switch (message.rilMessageType) {
|
2012-01-09 22:28:47 +00:00
|
|
|
case "callStateChange":
|
|
|
|
// This one will handle its own notifications.
|
|
|
|
this.handleCallStateChange(message.call);
|
|
|
|
break;
|
|
|
|
case "callDisconnected":
|
|
|
|
// This one will handle its own notifications.
|
|
|
|
this.handleCallDisconnected(message.call);
|
|
|
|
break;
|
|
|
|
case "enumerateCalls":
|
|
|
|
// This one will handle its own notifications.
|
2012-08-17 03:46:34 +00:00
|
|
|
this.handleEnumerateCalls(message);
|
2012-01-09 22:28:47 +00:00
|
|
|
break;
|
2012-05-15 04:13:06 +00:00
|
|
|
case "callError":
|
|
|
|
this.handleCallError(message);
|
|
|
|
break;
|
2012-06-01 21:10:39 +00:00
|
|
|
case "getAvailableNetworks":
|
|
|
|
this.handleGetAvailableNetworks(message);
|
|
|
|
break;
|
2012-06-19 22:52:06 +00:00
|
|
|
case "selectNetwork":
|
|
|
|
this.handleSelectNetwork(message);
|
|
|
|
break;
|
|
|
|
case "selectNetworkAuto":
|
|
|
|
this.handleSelectNetworkAuto(message);
|
|
|
|
break;
|
|
|
|
case "networkinfochanged":
|
|
|
|
this.updateNetworkInfo(message);
|
|
|
|
break;
|
|
|
|
case "networkselectionmodechange":
|
|
|
|
this.updateNetworkSelectionMode(message);
|
|
|
|
break;
|
2012-03-19 22:49:27 +00:00
|
|
|
case "voiceregistrationstatechange":
|
2012-04-19 21:33:25 +00:00
|
|
|
this.updateVoiceConnection(message);
|
2012-02-10 19:27:23 +00:00
|
|
|
break;
|
2012-03-19 22:49:27 +00:00
|
|
|
case "dataregistrationstatechange":
|
2012-04-19 21:33:25 +00:00
|
|
|
this.updateDataConnection(message);
|
2012-02-10 19:27:23 +00:00
|
|
|
break;
|
2012-06-01 21:09:59 +00:00
|
|
|
case "datacallerror":
|
|
|
|
// 3G Network revoked the data connection, possible unavailable APN
|
|
|
|
debug("Received data registration error message. Failed APN " +
|
2012-08-01 14:54:04 +00:00
|
|
|
this.dataCallSettings["apn"]);
|
2012-06-01 21:09:59 +00:00
|
|
|
RILNetworkInterface.reset();
|
|
|
|
break;
|
2011-12-05 07:58:27 +00:00
|
|
|
case "signalstrengthchange":
|
2012-04-19 21:33:25 +00:00
|
|
|
this.handleSignalStrengthChange(message);
|
2011-12-05 07:58:27 +00:00
|
|
|
break;
|
|
|
|
case "operatorchange":
|
2012-04-19 21:33:25 +00:00
|
|
|
this.handleOperatorChange(message);
|
2011-12-05 07:58:27 +00:00
|
|
|
break;
|
2011-12-07 06:57:19 +00:00
|
|
|
case "radiostatechange":
|
2012-05-24 05:12:07 +00:00
|
|
|
this.handleRadioStateChange(message);
|
2011-12-05 07:58:27 +00:00
|
|
|
break;
|
|
|
|
case "cardstatechange":
|
2012-06-13 02:46:41 +00:00
|
|
|
this.rilContext.cardState = message.cardState;
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:CardStateChanged", message);
|
2011-12-05 07:58:27 +00:00
|
|
|
break;
|
2011-12-24 05:02:52 +00:00
|
|
|
case "sms-received":
|
|
|
|
this.handleSmsReceived(message);
|
2011-12-07 06:57:19 +00:00
|
|
|
return;
|
2012-02-19 23:44:29 +00:00
|
|
|
case "sms-sent":
|
|
|
|
this.handleSmsSent(message);
|
|
|
|
return;
|
2012-04-05 21:16:56 +00:00
|
|
|
case "sms-delivered":
|
|
|
|
this.handleSmsDelivered(message);
|
|
|
|
return;
|
2012-04-05 21:16:56 +00:00
|
|
|
case "sms-send-failed":
|
|
|
|
this.handleSmsSendFailed(message);
|
|
|
|
return;
|
2012-01-18 01:34:09 +00:00
|
|
|
case "datacallstatechange":
|
2012-07-19 23:56:57 +00:00
|
|
|
this.handleDataCallState(message);
|
2012-01-18 01:34:09 +00:00
|
|
|
break;
|
|
|
|
case "datacalllist":
|
|
|
|
this.handleDataCallList(message);
|
|
|
|
break;
|
2012-03-09 04:16:06 +00:00
|
|
|
case "nitzTime":
|
|
|
|
// TODO bug 714349
|
|
|
|
// Send information to time manager to decide what to do with it
|
|
|
|
// Message contains networkTimeInSeconds, networkTimeZoneInMinutes,
|
|
|
|
// dstFlag,localTimeStampInMS
|
|
|
|
// indicating the time, daylight savings flag, and timezone
|
|
|
|
// sent from the network and a timestamp of when the message was received
|
|
|
|
// so an offset can be added if/when the time is actually set.
|
2012-04-11 17:05:35 +00:00
|
|
|
debug("nitzTime networkTime=" + message.networkTimeInSeconds +
|
|
|
|
" timezone=" + message.networkTimeZoneInMinutes +
|
|
|
|
" dst=" + message.dstFlag +
|
|
|
|
" timestamp=" + message.localTimeStampInMS);
|
2012-03-09 04:16:06 +00:00
|
|
|
break;
|
2012-04-18 10:07:29 +00:00
|
|
|
case "iccinfochange":
|
2012-06-13 02:46:41 +00:00
|
|
|
this.rilContext.icc = message;
|
2012-03-17 14:23:17 +00:00
|
|
|
break;
|
2012-08-15 16:49:12 +00:00
|
|
|
case "iccGetCardLock":
|
|
|
|
case "iccSetCardLock":
|
|
|
|
case "iccUnlockCardLock":
|
|
|
|
this.handleICCCardLockResult(message);
|
2012-04-12 04:01:49 +00:00
|
|
|
break;
|
2012-05-07 18:53:42 +00:00
|
|
|
case "icccontacts":
|
|
|
|
if (!this._contactsCallbacks) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let callback = this._contactsCallbacks[message.requestId];
|
|
|
|
if (callback) {
|
|
|
|
delete this._contactsCallbacks[message.requestId];
|
|
|
|
callback.receiveContactsList(message.contactType, message.contacts);
|
|
|
|
}
|
|
|
|
break;
|
2012-07-21 00:19:38 +00:00
|
|
|
case "iccmbdn":
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:VoicemailNumberChanged", message);
|
2012-07-21 00:19:38 +00:00
|
|
|
break;
|
2012-06-09 21:07:18 +00:00
|
|
|
case "ussdreceived":
|
|
|
|
debug("ussdreceived " + JSON.stringify(message));
|
|
|
|
this.handleUSSDReceived(message);
|
|
|
|
break;
|
|
|
|
case "sendussd":
|
|
|
|
this.handleSendUSSD(message);
|
|
|
|
break;
|
|
|
|
case "cancelussd":
|
|
|
|
this.handleCancelUSSD(message);
|
|
|
|
break;
|
2012-04-10 12:04:27 +00:00
|
|
|
case "stkcommand":
|
|
|
|
this.handleStkProactiveCommand(message);
|
|
|
|
break;
|
|
|
|
case "stksessionend":
|
|
|
|
ppmm.broadcastAsyncMessage("RIL:StkSessionEnd", null);
|
|
|
|
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
|
|
|
},
|
|
|
|
|
2012-08-17 03:46:34 +00:00
|
|
|
_messageManagerByRequest: null,
|
|
|
|
saveRequestTarget: function saveRequestTarget(msg) {
|
|
|
|
let requestId = msg.json.requestId;
|
|
|
|
if (!requestId) {
|
|
|
|
// The content is not interested in a response;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-27 14:13:02 +00:00
|
|
|
this._messageManagerByRequest[requestId] = msg.target;
|
2012-08-17 03:46:34 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_sendRequestResults: function _sendRequestResults(requestType, options) {
|
|
|
|
let target = this._messageManagerByRequest[options.requestId];
|
|
|
|
delete this._messageManagerByRequest[options.requestId];
|
|
|
|
|
|
|
|
if (!target) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-27 18:27:37 +00:00
|
|
|
target.sendAsyncMessage(requestType, options);
|
2012-08-17 03:46:34 +00:00
|
|
|
},
|
|
|
|
|
2012-06-19 22:52:06 +00:00
|
|
|
updateNetworkInfo: function updateNetworkInfo(message) {
|
|
|
|
let voiceMessage = message[RIL.NETWORK_INFO_VOICE_REGISTRATION_STATE];
|
|
|
|
let dataMessage = message[RIL.NETWORK_INFO_DATA_REGISTRATION_STATE];
|
|
|
|
let operatorMessage = message[RIL.NETWORK_INFO_OPERATOR];
|
|
|
|
let selectionMessage = message[RIL.NETWORK_INFO_NETWORK_SELECTION_MODE];
|
|
|
|
|
|
|
|
// Batch the *InfoChanged messages together
|
|
|
|
if (voiceMessage) {
|
|
|
|
voiceMessage.batch = true;
|
2012-08-07 19:11:48 +00:00
|
|
|
this.updateVoiceConnection(voiceMessage);
|
2012-06-19 22:52:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let dataInfoChanged = false;
|
|
|
|
if (dataMessage) {
|
|
|
|
dataMessage.batch = true;
|
2012-08-07 19:11:48 +00:00
|
|
|
this.updateDataConnection(dataMessage);
|
2012-06-19 22:52:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let voice = this.rilContext.voice;
|
|
|
|
let data = this.rilContext.data;
|
|
|
|
if (operatorMessage) {
|
|
|
|
if (this.networkChanged(operatorMessage, voice.network)) {
|
|
|
|
voice.network = operatorMessage;
|
|
|
|
}
|
|
|
|
if (this.networkChanged(operatorMessage, data.network)) {
|
|
|
|
data.network = operatorMessage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-07 19:11:48 +00:00
|
|
|
if (voiceMessage || operatorMessage) {
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:VoiceInfoChanged", voice);
|
2012-06-19 22:52:06 +00:00
|
|
|
}
|
2012-08-07 19:11:48 +00:00
|
|
|
if (dataMessage || operatorMessage) {
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:DataInfoChanged", data);
|
2012-06-19 22:52:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (selectionMessage) {
|
|
|
|
this.updateNetworkSelectionMode(selectionMessage);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends the RIL:VoiceInfoChanged message when the voice
|
|
|
|
* connection's state has changed.
|
|
|
|
*
|
2012-08-07 19:11:48 +00:00
|
|
|
* @param newInfo The new voice connection information. When newInfo.batch is true,
|
|
|
|
* the RIL:VoiceInfoChanged message will not be sent.
|
2012-06-19 22:52:06 +00:00
|
|
|
*/
|
2012-08-07 19:11:48 +00:00
|
|
|
updateVoiceConnection: function updateVoiceConnection(newInfo) {
|
2012-06-13 02:46:41 +00:00
|
|
|
let voiceInfo = this.rilContext.voice;
|
2012-08-07 19:11:48 +00:00
|
|
|
voiceInfo.state = newInfo.state;
|
|
|
|
voiceInfo.connected = newInfo.connected;
|
|
|
|
voiceInfo.roaming = newInfo.roaming;
|
|
|
|
voiceInfo.emergencyCallsOnly = newInfo.emergencyCallsOnly;
|
|
|
|
// Unlike the data registration info, the voice info typically contains
|
|
|
|
// no (useful) radio tech information, so we have to manually set
|
|
|
|
// this here. (TODO GSM only for now, see bug 726098.)
|
|
|
|
voiceInfo.type = "gsm";
|
|
|
|
|
|
|
|
// Make sure we also reset the operator and signal strength information
|
|
|
|
// if we drop off the network.
|
|
|
|
if (newInfo.regState == RIL.NETWORK_CREG_STATE_UNKNOWN) {
|
2012-06-12 21:05:50 +00:00
|
|
|
voiceInfo.network = null;
|
2012-04-19 21:33:25 +00:00
|
|
|
voiceInfo.signalStrength = null;
|
|
|
|
voiceInfo.relSignalStrength = null;
|
|
|
|
}
|
|
|
|
|
2012-08-16 01:36:56 +00:00
|
|
|
let newCell = newInfo.cell;
|
|
|
|
if ((newCell.gsmLocationAreaCode < 0) || (newCell.gsmCellId < 0)) {
|
|
|
|
voiceInfo.cell = null;
|
|
|
|
} else {
|
|
|
|
voiceInfo.cell = newCell;
|
|
|
|
}
|
|
|
|
|
2012-08-07 19:11:48 +00:00
|
|
|
if (!newInfo.batch) {
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:VoiceInfoChanged", voiceInfo);
|
2012-06-19 22:52:06 +00:00
|
|
|
}
|
2012-04-19 21:33:25 +00:00
|
|
|
},
|
|
|
|
|
2012-08-07 19:11:48 +00:00
|
|
|
updateDataConnection: function updateDataConnection(newInfo) {
|
|
|
|
let dataInfo = this.rilContext.data;
|
|
|
|
dataInfo.state = newInfo.state;
|
|
|
|
dataInfo.roaming = newInfo.roaming;
|
|
|
|
dataInfo.emergencyCallsOnly = newInfo.emergencyCallsOnly;
|
|
|
|
dataInfo.type = newInfo.type;
|
|
|
|
// For the data connection, the `connected` flag indicates whether
|
|
|
|
// there's an active data call.
|
|
|
|
dataInfo.connected = RILNetworkInterface.connected;
|
|
|
|
|
|
|
|
// Make sure we also reset the operator and signal strength information
|
|
|
|
// if we drop off the network.
|
|
|
|
if (newInfo.regState == RIL.NETWORK_CREG_STATE_UNKNOWN) {
|
|
|
|
dataInfo.network = null;
|
|
|
|
dataInfo.signalStrength = null;
|
|
|
|
dataInfo.relSignalStrength = null;
|
|
|
|
}
|
|
|
|
|
2012-08-16 01:36:56 +00:00
|
|
|
let newCell = newInfo.cell;
|
|
|
|
if ((newCell.gsmLocationAreaCode < 0) || (newCell.gsmCellId < 0)) {
|
|
|
|
dataInfo.cell = null;
|
|
|
|
} else {
|
|
|
|
dataInfo.cell = newCell;
|
|
|
|
}
|
|
|
|
|
2012-08-07 19:11:48 +00:00
|
|
|
if (!newInfo.batch) {
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:DataInfoChanged", dataInfo);
|
2012-06-22 00:22:47 +00:00
|
|
|
}
|
2012-08-30 19:41:46 +00:00
|
|
|
this.updateRILNetworkInterface();
|
2012-04-19 21:33:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
handleSignalStrengthChange: function handleSignalStrengthChange(message) {
|
2012-08-07 19:11:48 +00:00
|
|
|
let voiceInfo = this.rilContext.voice;
|
2012-04-19 21:33:25 +00:00
|
|
|
// TODO CDMA, EVDO, LTE, etc. (see bug 726098)
|
2012-08-07 19:11:48 +00:00
|
|
|
if (voiceInfo.signalStrength != message.gsmDBM ||
|
|
|
|
voiceInfo.relSignalStrength != message.gsmRelative) {
|
|
|
|
voiceInfo.signalStrength = message.gsmDBM;
|
|
|
|
voiceInfo.relSignalStrength = message.gsmRelative;
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:VoiceInfoChanged", voiceInfo);
|
2012-08-07 19:11:48 +00:00
|
|
|
}
|
2012-04-19 21:33:25 +00:00
|
|
|
|
2012-08-07 19:11:48 +00:00
|
|
|
let dataInfo = this.rilContext.data;
|
|
|
|
if (dataInfo.signalStrength != message.gsmDBM ||
|
|
|
|
dataInfo.relSignalStrength != message.gsmRelative) {
|
|
|
|
dataInfo.signalStrength = message.gsmDBM;
|
|
|
|
dataInfo.relSignalStrength = message.gsmRelative;
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:DataInfoChanged", dataInfo);
|
2012-08-07 19:11:48 +00:00
|
|
|
}
|
2012-04-19 21:33:25 +00:00
|
|
|
},
|
|
|
|
|
2012-06-12 21:05:50 +00:00
|
|
|
networkChanged: function networkChanged(srcNetwork, destNetwork) {
|
|
|
|
return !destNetwork ||
|
|
|
|
destNetwork.longName != srcNetwork.longName ||
|
|
|
|
destNetwork.shortName != srcNetwork.shortName ||
|
|
|
|
destNetwork.mnc != srcNetwork.mnc ||
|
|
|
|
destNetwork.mcc != srcNetwork.mcc;
|
|
|
|
},
|
|
|
|
|
2012-04-19 21:33:25 +00:00
|
|
|
handleOperatorChange: function handleOperatorChange(message) {
|
2012-06-13 02:46:41 +00:00
|
|
|
let voice = this.rilContext.voice;
|
|
|
|
let data = this.rilContext.data;
|
2012-06-12 21:05:50 +00:00
|
|
|
|
|
|
|
if (this.networkChanged(message, voice.network)) {
|
|
|
|
voice.network = message;
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:VoiceInfoChanged", voice);
|
2012-04-19 21:33:25 +00:00
|
|
|
}
|
2012-06-12 21:05:50 +00:00
|
|
|
|
|
|
|
if (this.networkChanged(message, data.network)) {
|
|
|
|
data.network = message;
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:DataInfoChanged", data);
|
2012-04-19 21:33:25 +00:00
|
|
|
}
|
2012-03-12 23:46:08 +00:00
|
|
|
},
|
|
|
|
|
2012-05-24 05:12:07 +00:00
|
|
|
handleRadioStateChange: function handleRadioStateChange(message) {
|
|
|
|
let newState = message.radioState;
|
2012-06-13 02:46:41 +00:00
|
|
|
if (this.rilContext.radioState == newState) {
|
2012-05-24 05:12:07 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-06-13 02:46:41 +00:00
|
|
|
this.rilContext.radioState = newState;
|
2012-05-24 05:12:07 +00:00
|
|
|
//TODO Should we notify this change as a card state change?
|
|
|
|
|
2012-05-25 17:37:37 +00:00
|
|
|
this._ensureRadioState();
|
|
|
|
},
|
|
|
|
|
|
|
|
_ensureRadioState: function _ensureRadioState() {
|
2012-06-13 02:46:41 +00:00
|
|
|
debug("Reported radio state is " + this.rilContext.radioState +
|
2012-05-25 17:37:37 +00:00
|
|
|
", desired radio enabled state is " + this._radioEnabled);
|
|
|
|
if (this._radioEnabled == null) {
|
|
|
|
// We haven't read the initial value from the settings DB yet.
|
|
|
|
// Wait for that.
|
|
|
|
return;
|
|
|
|
}
|
2012-06-13 02:46:41 +00:00
|
|
|
if (this.rilContext.radioState == RIL.GECKO_RADIOSTATE_UNKNOWN) {
|
2012-05-25 17:37:37 +00:00
|
|
|
// We haven't received a radio state notification from the RIL
|
|
|
|
// yet. Wait for that.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-06-13 02:46:41 +00:00
|
|
|
if (this.rilContext.radioState == RIL.GECKO_RADIOSTATE_OFF &&
|
2012-05-24 05:12:07 +00:00
|
|
|
this._radioEnabled) {
|
|
|
|
this.setRadioEnabled(true);
|
|
|
|
}
|
2012-06-13 02:46:41 +00:00
|
|
|
if (this.rilContext.radioState == RIL.GECKO_RADIOSTATE_READY &&
|
2012-05-24 05:12:07 +00:00
|
|
|
!this._radioEnabled) {
|
|
|
|
this.setRadioEnabled(false);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-08-01 14:54:04 +00:00
|
|
|
updateRILNetworkInterface: function updateRILNetworkInterface() {
|
|
|
|
if (this._dataCallSettingsToRead.length) {
|
|
|
|
debug("We haven't read completely the APN data from the " +
|
|
|
|
"settings DB yet. Wait for that.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This check avoids data call connection if the radio is not ready
|
|
|
|
// yet after toggling off airplane mode.
|
|
|
|
if (this.rilContext.radioState != RIL.GECKO_RADIOSTATE_READY) {
|
2012-08-30 19:41:46 +00:00
|
|
|
debug("RIL is not ready for data connection: radio's not ready");
|
2012-08-01 14:54:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We only watch at "ril.data.enabled" flag changes for connecting or
|
|
|
|
// disconnecting the data call. If the value of "ril.data.enabled" is
|
|
|
|
// true and any of the remaining flags change the setting application
|
|
|
|
// should turn this flag to false and then to true in order to reload
|
|
|
|
// the new values and reconnect the data call.
|
|
|
|
if (this._oldRilDataEnabledState == this.dataCallSettings["enabled"]) {
|
|
|
|
debug("No changes for ril.data.enabled flag. Nothing to do.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.dataCallSettings["enabled"] && RILNetworkInterface.connected) {
|
|
|
|
debug("Data call settings: disconnect data call.");
|
|
|
|
RILNetworkInterface.disconnect();
|
2012-08-30 19:41:46 +00:00
|
|
|
return;
|
2012-08-01 14:54:04 +00:00
|
|
|
}
|
2012-08-30 19:41:46 +00:00
|
|
|
if (!this.dataCallSettings["enabled"] || RILNetworkInterface.connected) {
|
|
|
|
debug("Data call settings: nothing to do.");
|
|
|
|
return;
|
2012-08-01 14:54:04 +00:00
|
|
|
}
|
2012-08-30 19:41:46 +00:00
|
|
|
let dataInfo = this.rilContext.data;
|
|
|
|
let isRegistered =
|
|
|
|
dataInfo.state == RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED;
|
|
|
|
let haveDataConnection =
|
|
|
|
dataInfo.type != RIL.GECKO_MOBILE_CONNECTION_STATE_UNKNOWN;
|
|
|
|
if (!isRegistered || !haveDataConnection) {
|
|
|
|
debug("RIL is not ready for data connection: Phone's not registered " +
|
|
|
|
"or doesn't have data connection.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (dataInfo.roaming && !this.dataCallSettings["roaming_enabled"]) {
|
|
|
|
debug("We're roaming, but data roaming is disabled.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
debug("Data call settings: connect data call.");
|
|
|
|
RILNetworkInterface.connect(this.dataCallSettings);
|
2012-08-01 14:54:04 +00:00
|
|
|
},
|
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
/**
|
|
|
|
* Track the active call and update the audio system as its state changes.
|
|
|
|
*/
|
|
|
|
_activeCall: null,
|
2012-01-12 00:20:16 +00:00
|
|
|
updateCallAudioState: function updateCallAudioState() {
|
|
|
|
if (!this._activeCall) {
|
2012-01-09 22:28:47 +00:00
|
|
|
// Disable audio.
|
|
|
|
gAudioManager.phoneState = nsIAudioManager.PHONE_STATE_NORMAL;
|
2012-05-15 04:13:06 +00:00
|
|
|
debug("No active call, put audio system into PHONE_STATE_NORMAL: "
|
|
|
|
+ gAudioManager.phoneState);
|
2012-01-12 00:20:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch (this._activeCall.state) {
|
2012-01-19 20:53:32 +00:00
|
|
|
case nsIRadioInterfaceLayer.CALL_STATE_INCOMING:
|
2012-01-12 00:20:16 +00:00
|
|
|
gAudioManager.phoneState = nsIAudioManager.PHONE_STATE_RINGTONE;
|
2012-05-15 04:13:06 +00:00
|
|
|
debug("Incoming call, put audio system into PHONE_STATE_RINGTONE: "
|
|
|
|
+ gAudioManager.phoneState);
|
2012-01-12 00:20:16 +00:00
|
|
|
break;
|
2012-01-19 20:53:32 +00:00
|
|
|
case nsIRadioInterfaceLayer.CALL_STATE_DIALING: // Fall through...
|
|
|
|
case nsIRadioInterfaceLayer.CALL_STATE_CONNECTED:
|
2012-01-12 00:20:16 +00:00
|
|
|
gAudioManager.phoneState = nsIAudioManager.PHONE_STATE_IN_CALL;
|
2012-08-09 03:40:35 +00:00
|
|
|
let force = this.speakerEnabled ? nsIAudioManager.FORCE_SPEAKER
|
|
|
|
: nsIAudioManager.FORCE_NONE;
|
|
|
|
gAudioManager.setForceForUse(nsIAudioManager.USE_COMMUNICATION, force);
|
2012-05-15 04:13:06 +00:00
|
|
|
debug("Active call, put audio system into PHONE_STATE_IN_CALL: "
|
|
|
|
+ gAudioManager.phoneState);
|
2012-01-12 00:20:16 +00:00
|
|
|
break;
|
2012-01-09 22:28:47 +00:00
|
|
|
}
|
2011-12-05 07:58:27 +00:00
|
|
|
},
|
|
|
|
|
2011-12-12 18:22:26 +00:00
|
|
|
/**
|
2012-01-09 22:28:47 +00:00
|
|
|
* Handle call state changes by updating our current state and the audio
|
|
|
|
* system.
|
2011-12-12 18:22:26 +00:00
|
|
|
*/
|
2012-01-09 22:28:47 +00:00
|
|
|
handleCallStateChange: function handleCallStateChange(call) {
|
|
|
|
debug("handleCallStateChange: " + JSON.stringify(call));
|
|
|
|
call.state = convertRILCallState(call.state);
|
2012-08-31 03:06:42 +00:00
|
|
|
|
|
|
|
if (call.state == nsIRadioInterfaceLayer.CALL_STATE_INCOMING) {
|
|
|
|
gSystemMessenger.broadcastMessage("telephony-incoming", {number: call.number});
|
|
|
|
}
|
|
|
|
|
2012-05-15 04:13:06 +00:00
|
|
|
if (call.isActive) {
|
2012-01-12 00:20:16 +00:00
|
|
|
this._activeCall = call;
|
2012-05-15 04:13:06 +00:00
|
|
|
} else if (this._activeCall &&
|
|
|
|
this._activeCall.callIndex == call.callIndex) {
|
|
|
|
// Previously active call is not active now.
|
|
|
|
this._activeCall = null;
|
2012-01-09 22:28:47 +00:00
|
|
|
}
|
2012-01-12 00:20:16 +00:00
|
|
|
this.updateCallAudioState();
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:CallStateChanged", call);
|
2012-01-09 22:28:47 +00:00
|
|
|
},
|
2011-12-12 18:22:26 +00:00
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
/**
|
|
|
|
* Handle call disconnects by updating our current state and the audio system.
|
|
|
|
*/
|
2012-01-12 00:20:16 +00:00
|
|
|
handleCallDisconnected: function handleCallDisconnected(call) {
|
2012-01-09 22:28:47 +00:00
|
|
|
debug("handleCallDisconnected: " + JSON.stringify(call));
|
2012-05-15 04:13:06 +00:00
|
|
|
if (call.isActive) {
|
2012-01-12 00:20:16 +00:00
|
|
|
this._activeCall = null;
|
2011-12-12 18:22:26 +00:00
|
|
|
}
|
2012-01-12 00:20:16 +00:00
|
|
|
this.updateCallAudioState();
|
2012-04-24 15:44:42 +00:00
|
|
|
call.state = nsIRadioInterfaceLayer.CALL_STATE_DISCONNECTED;
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:CallStateChanged", call);
|
2012-01-09 22:28:47 +00:00
|
|
|
},
|
2011-12-12 18:22:26 +00:00
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
/**
|
|
|
|
* Handle calls delivered in response to a 'enumerateCalls' request.
|
|
|
|
*/
|
2012-08-17 03:46:34 +00:00
|
|
|
handleEnumerateCalls: function handleEnumerateCalls(options) {
|
|
|
|
debug("handleEnumerateCalls: " + JSON.stringify(options));
|
|
|
|
for (let i in options.calls) {
|
|
|
|
options.calls[i].state = convertRILCallState(options.calls[i].state);
|
2011-12-12 18:22:26 +00:00
|
|
|
}
|
2012-08-17 03:46:34 +00:00
|
|
|
this._sendRequestResults("RIL:EnumerateCalls", options);
|
2011-12-12 18:22:26 +00:00
|
|
|
},
|
|
|
|
|
2012-06-01 21:10:39 +00:00
|
|
|
/**
|
|
|
|
* Handle available networks returned by the 'getAvailableNetworks' request.
|
|
|
|
*/
|
|
|
|
handleGetAvailableNetworks: function handleGetAvailableNetworks(message) {
|
|
|
|
debug("handleGetAvailableNetworks: " + JSON.stringify(message));
|
|
|
|
|
2012-08-17 03:46:34 +00:00
|
|
|
this._sendRequestResults("RIL:GetAvailableNetworks", message);
|
2012-06-01 21:10:39 +00:00
|
|
|
},
|
|
|
|
|
2012-06-19 22:52:06 +00:00
|
|
|
/**
|
|
|
|
* Update network selection mode
|
|
|
|
*/
|
|
|
|
updateNetworkSelectionMode: function updateNetworkSelectionMode(message) {
|
|
|
|
debug("updateNetworkSelectionMode: " + JSON.stringify(message));
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:NetworkSelectionModeChanged", message);
|
2012-06-19 22:52:06 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle "manual" network selection request.
|
|
|
|
*/
|
|
|
|
handleSelectNetwork: function handleSelectNetwork(message) {
|
|
|
|
debug("handleSelectNetwork: " + JSON.stringify(message));
|
2012-08-17 03:46:34 +00:00
|
|
|
this._sendRequestResults("RIL:SelectNetwork", message);
|
2012-06-19 22:52:06 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle "automatic" network selection request.
|
|
|
|
*/
|
|
|
|
handleSelectNetworkAuto: function handleSelectNetworkAuto(message) {
|
|
|
|
debug("handleSelectNetworkAuto: " + JSON.stringify(message));
|
2012-08-17 03:46:34 +00:00
|
|
|
this._sendRequestResults("RIL:SelectNetworkAuto", message);
|
2012-06-19 22:52:06 +00:00
|
|
|
},
|
|
|
|
|
2012-05-15 04:13:06 +00:00
|
|
|
/**
|
|
|
|
* Handle call error.
|
|
|
|
*/
|
|
|
|
handleCallError: function handleCallError(message) {
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:CallError", message);
|
2012-05-15 04:13:06 +00:00
|
|
|
},
|
|
|
|
|
2012-06-04 05:04:28 +00:00
|
|
|
/**
|
|
|
|
* Handle WDP port push PDU. Constructor WDP bearer information and deliver
|
|
|
|
* to WapPushManager.
|
|
|
|
*
|
|
|
|
* @param message
|
|
|
|
* A SMS message.
|
|
|
|
*/
|
|
|
|
handleSmsWdpPortPush: function handleSmsWdpPortPush(message) {
|
|
|
|
if (message.encoding != RIL.PDU_DCS_MSG_CODING_8BITS_ALPHABET) {
|
|
|
|
debug("Got port addressed SMS but not encoded in 8-bit alphabet. Drop!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let options = {
|
|
|
|
bearer: WAP.WDP_BEARER_GSM_SMS_GSM_MSISDN,
|
|
|
|
sourceAddress: message.sender,
|
|
|
|
sourcePort: message.header.originatorPort,
|
2012-06-13 02:46:41 +00:00
|
|
|
destinationAddress: this.rilContext.icc.msisdn,
|
2012-06-04 05:04:28 +00:00
|
|
|
destinationPort: message.header.destinationPort,
|
|
|
|
};
|
|
|
|
WAP.WapPushManager.receiveWdpPDU(message.fullData, message.fullData.length,
|
|
|
|
0, options);
|
|
|
|
},
|
|
|
|
|
2012-04-23 23:43:32 +00:00
|
|
|
portAddressedSmsApps: null,
|
2011-12-24 05:02:52 +00:00
|
|
|
handleSmsReceived: function handleSmsReceived(message) {
|
2012-02-20 17:12:37 +00:00
|
|
|
debug("handleSmsReceived: " + JSON.stringify(message));
|
2012-04-23 23:43:32 +00:00
|
|
|
|
2012-06-04 05:04:28 +00:00
|
|
|
// FIXME: Bug 737202 - Typed arrays become normal arrays when sent to/from workers
|
|
|
|
if (message.encoding == RIL.PDU_DCS_MSG_CODING_8BITS_ALPHABET) {
|
|
|
|
message.fullData = new Uint8Array(message.fullData);
|
|
|
|
}
|
|
|
|
|
2012-04-23 23:43:32 +00:00
|
|
|
// Dispatch to registered handler if application port addressing is
|
|
|
|
// available. Note that the destination port can possibly be zero when
|
|
|
|
// representing a UDP/TCP port.
|
2012-04-26 02:34:18 +00:00
|
|
|
if (message.header && message.header.destinationPort != null) {
|
2012-04-23 23:43:32 +00:00
|
|
|
let handler = this.portAddressedSmsApps[message.header.destinationPort];
|
|
|
|
if (handler) {
|
|
|
|
handler(message);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-23 23:43:32 +00:00
|
|
|
if (message.encoding == RIL.PDU_DCS_MSG_CODING_8BITS_ALPHABET) {
|
|
|
|
// Don't know how to handle binary data yet.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-19 03:27:08 +00:00
|
|
|
// TODO: Bug #768441
|
|
|
|
// For now we don't store indicators persistently. When the mwi.discard
|
|
|
|
// flag is false, we'll need to persist the indicator to EFmwis.
|
|
|
|
// See TS 23.040 9.2.3.24.2
|
|
|
|
|
|
|
|
let mwi = message.mwi;
|
|
|
|
if (mwi) {
|
|
|
|
mwi.returnNumber = message.sender || null;
|
|
|
|
mwi.returnMessage = message.fullBody || null;
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:VoicemailNotification", mwi);
|
2012-07-19 03:27:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-02-20 17:12:37 +00:00
|
|
|
let id = gSmsDatabaseService.saveReceivedMessage(message.sender || null,
|
2012-03-17 00:02:06 +00:00
|
|
|
message.fullBody || null,
|
2012-02-20 17:12:37 +00:00
|
|
|
message.timestamp);
|
|
|
|
let sms = gSmsService.createSmsMessage(id,
|
2011-12-24 05:02:52 +00:00
|
|
|
DOM_SMS_DELIVERY_RECEIVED,
|
|
|
|
message.sender || null,
|
|
|
|
message.receiver || null,
|
2012-03-17 00:02:06 +00:00
|
|
|
message.fullBody || null,
|
2012-05-17 19:42:39 +00:00
|
|
|
message.timestamp,
|
|
|
|
false);
|
2012-07-19 03:27:08 +00:00
|
|
|
|
2011-12-24 05:02:52 +00:00
|
|
|
Services.obs.notifyObservers(sms, kSmsReceivedObserverTopic, null);
|
|
|
|
},
|
|
|
|
|
2012-04-05 21:16:56 +00:00
|
|
|
/**
|
|
|
|
* Local storage for sent SMS messages.
|
|
|
|
*/
|
|
|
|
_sentSmsEnvelopes: null,
|
|
|
|
createSmsEnvelope: function createSmsEnvelope(options) {
|
|
|
|
let i;
|
|
|
|
for (i = 1; this._sentSmsEnvelopes[i]; i++) {
|
|
|
|
// Do nothing.
|
|
|
|
}
|
|
|
|
|
|
|
|
debug("createSmsEnvelope: assigned " + i);
|
|
|
|
options.envelopeId = i;
|
|
|
|
this._sentSmsEnvelopes[i] = options;
|
|
|
|
},
|
|
|
|
|
2012-02-19 23:44:29 +00:00
|
|
|
handleSmsSent: function handleSmsSent(message) {
|
2012-02-20 17:12:37 +00:00
|
|
|
debug("handleSmsSent: " + JSON.stringify(message));
|
2012-04-05 21:16:56 +00:00
|
|
|
|
|
|
|
let options = this._sentSmsEnvelopes[message.envelopeId];
|
|
|
|
if (!options) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-02-20 17:12:37 +00:00
|
|
|
let timestamp = Date.now();
|
2012-04-05 21:16:56 +00:00
|
|
|
let id = gSmsDatabaseService.saveSentMessage(options.number,
|
|
|
|
options.fullBody,
|
2012-03-16 23:59:35 +00:00
|
|
|
timestamp);
|
2012-02-20 17:12:37 +00:00
|
|
|
let sms = gSmsService.createSmsMessage(id,
|
2012-02-20 14:57:38 +00:00
|
|
|
DOM_SMS_DELIVERY_SENT,
|
|
|
|
null,
|
2012-04-05 21:16:56 +00:00
|
|
|
options.number,
|
|
|
|
options.fullBody,
|
2012-05-17 19:42:39 +00:00
|
|
|
timestamp,
|
|
|
|
true);
|
2012-04-05 21:16:56 +00:00
|
|
|
|
|
|
|
if (!options.requestStatusReport) {
|
|
|
|
// No more used if STATUS-REPORT not requested.
|
|
|
|
delete this._sentSmsEnvelopes[message.envelopeId];
|
|
|
|
} else {
|
|
|
|
options.sms = sms;
|
|
|
|
}
|
|
|
|
|
|
|
|
gSmsRequestManager.notifySmsSent(options.requestId, sms);
|
|
|
|
},
|
|
|
|
|
|
|
|
handleSmsDelivered: function handleSmsDelivered(message) {
|
|
|
|
debug("handleSmsDelivered: " + JSON.stringify(message));
|
|
|
|
|
|
|
|
let options = this._sentSmsEnvelopes[message.envelopeId];
|
|
|
|
if (!options) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
delete this._sentSmsEnvelopes[message.envelopeId];
|
|
|
|
|
|
|
|
Services.obs.notifyObservers(options.sms, kSmsDeliveredObserverTopic, null);
|
2012-02-19 23:44:29 +00:00
|
|
|
},
|
|
|
|
|
2012-04-05 21:16:56 +00:00
|
|
|
handleSmsSendFailed: function handleSmsSendFailed(message) {
|
|
|
|
debug("handleSmsSendFailed: " + JSON.stringify(message));
|
|
|
|
|
|
|
|
let options = this._sentSmsEnvelopes[message.envelopeId];
|
|
|
|
if (!options) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
delete this._sentSmsEnvelopes[message.envelopeId];
|
|
|
|
|
|
|
|
let error = gSmsRequestManager.UNKNOWN_ERROR;
|
|
|
|
switch (message.error) {
|
|
|
|
case RIL.ERROR_RADIO_NOT_AVAILABLE:
|
|
|
|
error = gSmsRequestManager.NO_SIGNAL_ERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gSmsRequestManager.notifySmsSendFailed(options.requestId, error);
|
|
|
|
},
|
|
|
|
|
2012-01-18 01:34:09 +00:00
|
|
|
/**
|
|
|
|
* Handle data call state changes.
|
|
|
|
*/
|
2012-02-10 19:27:38 +00:00
|
|
|
handleDataCallState: function handleDataCallState(datacall) {
|
2012-06-22 00:22:47 +00:00
|
|
|
let data = this.rilContext.data;
|
|
|
|
|
|
|
|
if (datacall.ifname) {
|
|
|
|
data.connected = (datacall.state == RIL.GECKO_NETWORK_STATE_CONNECTED);
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:DataInfoChanged", data);
|
2012-06-22 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
2012-01-18 01:34:09 +00:00
|
|
|
this._deliverDataCallCallback("dataCallStateChanged",
|
2012-06-22 05:53:12 +00:00
|
|
|
[datacall]);
|
2012-01-18 01:34:09 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle data call list.
|
|
|
|
*/
|
|
|
|
handleDataCallList: function handleDataCallList(message) {
|
|
|
|
this._deliverDataCallCallback("receiveDataCallList",
|
2012-06-22 05:53:12 +00:00
|
|
|
[message.datacalls, message.datacalls.length]);
|
2012-01-18 01:34:09 +00:00
|
|
|
},
|
|
|
|
|
2012-08-15 16:49:12 +00:00
|
|
|
handleICCCardLockResult: function handleICCCardLockResult(message) {
|
2012-08-17 03:46:34 +00:00
|
|
|
this._sendRequestResults("RIL:CardLockResult", message);
|
2012-04-12 04:01:49 +00:00
|
|
|
},
|
|
|
|
|
2012-06-09 21:07:18 +00:00
|
|
|
handleUSSDReceived: function handleUSSDReceived(ussd) {
|
|
|
|
debug("handleUSSDReceived " + JSON.stringify(ussd));
|
2012-08-27 14:13:02 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:UssdReceived", ussd);
|
2012-06-09 21:07:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
handleSendUSSD: function handleSendUSSD(message) {
|
|
|
|
debug("handleSendUSSD " + JSON.stringify(message));
|
|
|
|
let messageType = message.success ? "RIL:SendUssd:Return:OK" :
|
|
|
|
"RIL:SendUssd:Return:KO";
|
2012-08-17 03:46:34 +00:00
|
|
|
this._sendRequestResults(messageType, message);
|
2012-06-09 21:07:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
handleCancelUSSD: function handleCancelUSSD(message) {
|
|
|
|
debug("handleCancelUSSD " + JSON.stringify(message));
|
|
|
|
let messageType = message.success ? "RIL:CancelUssd:Return:OK" :
|
|
|
|
"RIL:CancelUssd:Return:KO";
|
2012-08-17 03:46:34 +00:00
|
|
|
this._sendRequestResults(messageType, message);
|
2012-06-09 21:07:18 +00:00
|
|
|
},
|
|
|
|
|
2012-04-10 12:04:27 +00:00
|
|
|
handleStkProactiveCommand: function handleStkProactiveCommand(message) {
|
|
|
|
debug("handleStkProactiveCommand " + JSON.stringify(message));
|
2012-08-31 02:00:13 +00:00
|
|
|
gSystemMessenger.broadcastMessage("icc-stkcommand", message);
|
2012-04-10 12:04:27 +00:00
|
|
|
ppmm.broadcastAsyncMessage("RIL:StkCommand", message);
|
|
|
|
},
|
|
|
|
|
2012-04-19 21:33:25 +00:00
|
|
|
// nsIObserver
|
2012-03-12 23:45:57 +00:00
|
|
|
|
2012-04-19 21:33:25 +00:00
|
|
|
observe: function observe(subject, topic, data) {
|
2012-04-24 20:46:42 +00:00
|
|
|
switch (topic) {
|
|
|
|
case kMozSettingsChangedObserverTopic:
|
|
|
|
let setting = JSON.parse(data);
|
2012-08-01 14:54:04 +00:00
|
|
|
this.handle(setting.key, setting.value);
|
2012-04-24 20:46:42 +00:00
|
|
|
break;
|
|
|
|
case "xpcom-shutdown":
|
|
|
|
for each (let msgname in RIL_IPC_MSG_NAMES) {
|
|
|
|
ppmm.removeMessageListener(msgname, this);
|
|
|
|
}
|
2012-06-01 21:09:59 +00:00
|
|
|
RILNetworkInterface.shutdown();
|
2012-04-24 20:46:42 +00:00
|
|
|
ppmm = null;
|
|
|
|
Services.obs.removeObserver(this, "xpcom-shutdown");
|
|
|
|
Services.obs.removeObserver(this, kMozSettingsChangedObserverTopic);
|
|
|
|
break;
|
2012-04-19 21:33:25 +00:00
|
|
|
}
|
2012-03-12 23:45:57 +00:00
|
|
|
},
|
|
|
|
|
2012-05-24 05:12:07 +00:00
|
|
|
// nsISettingsServiceCallback
|
|
|
|
|
|
|
|
// Flag to determine the radio state to start with when we boot up. It
|
|
|
|
// corresponds to the 'ril.radio.disabled' setting from the UI.
|
|
|
|
_radioEnabled: null,
|
|
|
|
|
2012-08-01 14:54:04 +00:00
|
|
|
// APN data for making data calls.
|
|
|
|
dataCallSettings: {},
|
|
|
|
_dataCallSettingsToRead: [],
|
|
|
|
_oldRilDataEnabledState: null,
|
|
|
|
|
2012-05-24 05:12:07 +00:00
|
|
|
handle: function handle(aName, aResult) {
|
2012-08-01 14:54:04 +00:00
|
|
|
switch(aName) {
|
|
|
|
case "ril.radio.disabled":
|
|
|
|
debug("'ril.radio.disabled' is now " + aResult);
|
|
|
|
this._radioEnabled = !aResult;
|
|
|
|
this._ensureRadioState();
|
|
|
|
break;
|
|
|
|
case "ril.data.enabled":
|
|
|
|
this._oldRilDataEnabledState = this.dataCallSettings["enabled"];
|
|
|
|
// Fall through!
|
|
|
|
case "ril.data.roaming_enabled":
|
|
|
|
case "ril.data.apn":
|
|
|
|
case "ril.data.user":
|
|
|
|
case "ril.data.passwd":
|
2012-08-01 14:55:43 +00:00
|
|
|
case "ril.data.httpProxyHost":
|
|
|
|
case "ril.data.httpProxyPort":
|
2012-08-01 14:54:04 +00:00
|
|
|
let key = aName.slice(9);
|
|
|
|
this.dataCallSettings[key] = aResult;
|
|
|
|
debug("'" + aName + "'" + " is now " + this.dataCallSettings[key]);
|
|
|
|
let index = this._dataCallSettingsToRead.indexOf(aName);
|
|
|
|
if (index != -1) {
|
|
|
|
this._dataCallSettingsToRead.splice(index, 1);
|
|
|
|
}
|
|
|
|
this.updateRILNetworkInterface();
|
|
|
|
break;
|
|
|
|
};
|
2012-05-24 05:12:07 +00:00
|
|
|
},
|
2012-08-01 14:54:04 +00:00
|
|
|
|
2012-05-24 05:12:07 +00:00
|
|
|
handleError: function handleError(aErrorMessage) {
|
2012-08-01 14:54:04 +00:00
|
|
|
debug("There was an error while reading RIL settings.");
|
|
|
|
|
|
|
|
// Default radio to on.
|
2012-05-24 05:12:07 +00:00
|
|
|
this._radioEnabled = true;
|
2012-05-25 17:37:37 +00:00
|
|
|
this._ensureRadioState();
|
2012-08-01 14:54:04 +00:00
|
|
|
|
|
|
|
// Clean data call setting.
|
|
|
|
this.dataCallSettings = {};
|
|
|
|
this.dataCallSettings["enabled"] = false;
|
2012-05-24 05:12:07 +00:00
|
|
|
},
|
|
|
|
|
2011-12-06 08:47:35 +00:00
|
|
|
// nsIRadioWorker
|
2011-12-05 07:58:27 +00:00
|
|
|
|
|
|
|
worker: null,
|
|
|
|
|
2012-01-19 20:53:32 +00:00
|
|
|
// nsIRadioInterfaceLayer
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2012-05-24 05:12:07 +00:00
|
|
|
setRadioEnabled: function setRadioEnabled(value) {
|
|
|
|
debug("Setting radio power to " + value);
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: "setRadioPower", on: value});
|
2012-05-24 05:12:07 +00:00
|
|
|
},
|
|
|
|
|
2012-06-13 02:46:41 +00:00
|
|
|
rilContext: null,
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2012-04-24 15:44:42 +00:00
|
|
|
// Handle phone functions of nsIRILContentHelper
|
|
|
|
|
2012-08-17 03:46:34 +00:00
|
|
|
enumerateCalls: function enumerateCalls(message) {
|
2012-04-24 15:44:42 +00:00
|
|
|
debug("Requesting enumeration of calls for callback");
|
2012-08-17 03:46:34 +00:00
|
|
|
message.rilMessageType = "enumerateCalls";
|
|
|
|
this.worker.postMessage(message);
|
2012-04-24 15:44:42 +00:00
|
|
|
},
|
|
|
|
|
2011-12-05 07:58:27 +00:00
|
|
|
dial: function dial(number) {
|
|
|
|
debug("Dialing " + number);
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: "dial",
|
|
|
|
number: number,
|
|
|
|
isDialEmergency: false});
|
2012-07-20 12:08:24 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
dialEmergency: function dialEmergency(number) {
|
|
|
|
debug("Dialing emergency " + number);
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: "dial",
|
|
|
|
number: number,
|
|
|
|
isDialEmergency: true});
|
2011-12-05 07:58:27 +00:00
|
|
|
},
|
|
|
|
|
2011-12-07 06:57:19 +00:00
|
|
|
hangUp: function hangUp(callIndex) {
|
|
|
|
debug("Hanging up call no. " + callIndex);
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: "hangUp",
|
|
|
|
callIndex: callIndex});
|
2011-12-07 06:57:19 +00:00
|
|
|
},
|
2012-01-18 01:34:09 +00:00
|
|
|
|
2011-12-16 21:47:32 +00:00
|
|
|
startTone: function startTone(dtmfChar) {
|
|
|
|
debug("Sending Tone for " + dtmfChar);
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: "startTone",
|
|
|
|
dtmfChar: dtmfChar});
|
2011-12-16 21:47:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
stopTone: function stopTone() {
|
|
|
|
debug("Stopping Tone");
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: "stopTone"});
|
2011-12-16 21:47:32 +00:00
|
|
|
},
|
2011-12-07 06:57:19 +00:00
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
answerCall: function answerCall(callIndex) {
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: "answerCall",
|
|
|
|
callIndex: callIndex});
|
2011-12-07 06:57:19 +00:00
|
|
|
},
|
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
rejectCall: function rejectCall(callIndex) {
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: "rejectCall",
|
|
|
|
callIndex: callIndex});
|
2011-12-07 06:57:19 +00:00
|
|
|
},
|
2012-04-05 08:12:42 +00:00
|
|
|
|
|
|
|
holdCall: function holdCall(callIndex) {
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: "holdCall",
|
|
|
|
callIndex: callIndex});
|
2012-04-05 08:12:42 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
resumeCall: function resumeCall(callIndex) {
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: "resumeCall",
|
|
|
|
callIndex: callIndex});
|
2012-04-05 08:12:42 +00:00
|
|
|
},
|
2011-12-07 06:57:19 +00:00
|
|
|
|
2012-06-01 21:10:39 +00:00
|
|
|
getAvailableNetworks: function getAvailableNetworks(requestId) {
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: "getAvailableNetworks",
|
|
|
|
requestId: requestId});
|
2012-06-01 21:10:39 +00:00
|
|
|
},
|
|
|
|
|
2012-06-09 21:07:18 +00:00
|
|
|
sendUSSD: function sendUSSD(message) {
|
|
|
|
debug("SendUSSD " + JSON.stringify(message));
|
2012-08-06 21:28:03 +00:00
|
|
|
message.rilMessageType = "sendUSSD";
|
2012-06-09 21:07:18 +00:00
|
|
|
this.worker.postMessage(message);
|
|
|
|
},
|
|
|
|
|
|
|
|
cancelUSSD: function cancelUSSD(message) {
|
|
|
|
debug("Cancel pending USSD");
|
2012-08-06 21:28:03 +00:00
|
|
|
message.rilMessageType = "cancelUSSD";
|
2012-06-09 21:07:18 +00:00
|
|
|
this.worker.postMessage(message);
|
|
|
|
},
|
|
|
|
|
2012-06-19 22:52:06 +00:00
|
|
|
selectNetworkAuto: function selectNetworkAuto(requestId) {
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: "selectNetworkAuto",
|
|
|
|
requestId: requestId});
|
2012-06-19 22:52:06 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
selectNetwork: function selectNetwork(message) {
|
2012-08-06 21:28:03 +00:00
|
|
|
message.rilMessageType = "selectNetwork";
|
2012-06-19 22:52:06 +00:00
|
|
|
this.worker.postMessage(message);
|
|
|
|
},
|
|
|
|
|
2012-04-10 12:04:27 +00:00
|
|
|
sendStkResponse: function sendStkResponse(message) {
|
|
|
|
message.rilMessageType = "sendStkTerminalResponse";
|
|
|
|
this.worker.postMessage(message);
|
|
|
|
},
|
|
|
|
|
|
|
|
sendStkMenuSelection: function sendStkMenuSelection(message) {
|
|
|
|
message.rilMessageType = "sendStkMenuSelection";
|
|
|
|
this.worker.postMessage(message);
|
|
|
|
},
|
2012-06-19 22:52:06 +00:00
|
|
|
|
2011-12-12 18:30:43 +00:00
|
|
|
get microphoneMuted() {
|
|
|
|
return gAudioManager.microphoneMuted;
|
|
|
|
},
|
|
|
|
set microphoneMuted(value) {
|
|
|
|
if (value == this.microphoneMuted) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gAudioManager.phoneState = value ?
|
2012-01-09 22:28:47 +00:00
|
|
|
nsIAudioManager.PHONE_STATE_IN_COMMUNICATION :
|
|
|
|
nsIAudioManager.PHONE_STATE_IN_CALL; //XXX why is this needed?
|
2011-12-12 18:30:43 +00:00
|
|
|
gAudioManager.microphoneMuted = value;
|
2012-05-15 04:13:06 +00:00
|
|
|
|
|
|
|
if (!this._activeCall) {
|
|
|
|
gAudioManager.phoneState = nsIAudioManager.PHONE_STATE_NORMAL;
|
|
|
|
}
|
2011-12-12 18:30:43 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
get speakerEnabled() {
|
2012-01-09 22:28:47 +00:00
|
|
|
return (gAudioManager.getForceForUse(nsIAudioManager.USE_COMMUNICATION) ==
|
|
|
|
nsIAudioManager.FORCE_SPEAKER);
|
2011-12-12 18:30:43 +00:00
|
|
|
},
|
|
|
|
set speakerEnabled(value) {
|
|
|
|
if (value == this.speakerEnabled) {
|
|
|
|
return;
|
|
|
|
}
|
2012-01-09 22:28:47 +00:00
|
|
|
gAudioManager.phoneState = nsIAudioManager.PHONE_STATE_IN_CALL; // XXX why is this needed?
|
|
|
|
let force = value ? nsIAudioManager.FORCE_SPEAKER :
|
|
|
|
nsIAudioManager.FORCE_NONE;
|
2012-02-10 19:27:23 +00:00
|
|
|
gAudioManager.setForceForUse(nsIAudioManager.USE_COMMUNICATION, force);
|
2012-05-15 04:13:06 +00:00
|
|
|
|
|
|
|
if (!this._activeCall) {
|
|
|
|
gAudioManager.phoneState = nsIAudioManager.PHONE_STATE_NORMAL;
|
|
|
|
}
|
2011-12-12 18:30:43 +00:00
|
|
|
},
|
|
|
|
|
2012-03-16 23:47:21 +00:00
|
|
|
/**
|
|
|
|
* List of tuples of national language identifier pairs.
|
2012-03-16 23:57:41 +00:00
|
|
|
*
|
|
|
|
* TODO: Support static/runtime settings, see bug 733331.
|
2012-03-16 23:47:21 +00:00
|
|
|
*/
|
|
|
|
enabledGsmTableTuples: [
|
|
|
|
[RIL.PDU_NL_IDENTIFIER_DEFAULT, RIL.PDU_NL_IDENTIFIER_DEFAULT],
|
|
|
|
],
|
|
|
|
|
2012-03-16 23:57:41 +00:00
|
|
|
/**
|
|
|
|
* Use 16-bit reference number for concatenated outgoint messages.
|
|
|
|
*
|
|
|
|
* TODO: Support static/runtime settings, see bug 733331.
|
|
|
|
*/
|
|
|
|
segmentRef16Bit: false,
|
|
|
|
|
2012-03-16 23:59:35 +00:00
|
|
|
/**
|
|
|
|
* Get valid SMS concatenation reference number.
|
|
|
|
*/
|
|
|
|
_segmentRef: 0,
|
|
|
|
get nextSegmentRef() {
|
|
|
|
let ref = this._segmentRef++;
|
|
|
|
|
|
|
|
this._segmentRef %= (this.segmentRef16Bit ? 65535 : 255);
|
|
|
|
|
|
|
|
// 0 is not a valid SMS concatenation reference number.
|
|
|
|
return ref + 1;
|
|
|
|
},
|
|
|
|
|
2012-03-16 23:47:21 +00:00
|
|
|
/**
|
|
|
|
* Calculate encoded length using specified locking/single shift table
|
|
|
|
*
|
|
|
|
* @param message
|
|
|
|
* message string to be encoded.
|
|
|
|
* @param langTable
|
|
|
|
* locking shift table string.
|
|
|
|
* @param langShiftTable
|
|
|
|
* single shift table string.
|
|
|
|
*
|
|
|
|
* @return encoded length in septets.
|
|
|
|
*
|
|
|
|
* @note that the algorithm used in this function must match exactly with
|
|
|
|
* GsmPDUHelper#writeStringAsSeptets.
|
|
|
|
*/
|
2012-03-16 23:57:06 +00:00
|
|
|
_countGsm7BitSeptets: function _countGsm7BitSeptets(message, langTable, langShiftTable) {
|
2012-03-16 23:47:21 +00:00
|
|
|
let length = 0;
|
|
|
|
for (let msgIndex = 0; msgIndex < message.length; msgIndex++) {
|
|
|
|
let septet = langTable.indexOf(message.charAt(msgIndex));
|
|
|
|
|
|
|
|
// According to 3GPP TS 23.038, section 6.1.1 General notes, "The
|
|
|
|
// characters marked '1)' are not used but are displayed as a space."
|
|
|
|
if (septet == RIL.PDU_NL_EXTENDED_ESCAPE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (septet >= 0) {
|
|
|
|
length++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
septet = langShiftTable.indexOf(message.charAt(msgIndex));
|
2012-03-16 23:57:06 +00:00
|
|
|
if (septet < 0) {
|
2012-03-16 23:47:21 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// According to 3GPP TS 23.038 B.2, "This code represents a control
|
|
|
|
// character and therefore must not be used for language specific
|
|
|
|
// characters."
|
|
|
|
if (septet == RIL.PDU_NL_RESERVED_CONTROL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The character is not found in locking shfit table, but could be
|
|
|
|
// encoded as <escape><char> with single shift table. Note that it's
|
|
|
|
// still possible for septet to has the value of PDU_NL_EXTENDED_ESCAPE,
|
|
|
|
// but we can display it as a space in this case as said in previous
|
|
|
|
// comment.
|
|
|
|
length += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return length;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2012-03-16 23:57:06 +00:00
|
|
|
* Calculate user data length of specified message string encoded in GSM 7Bit
|
|
|
|
* alphabets.
|
2012-03-16 23:47:21 +00:00
|
|
|
*
|
2012-03-16 23:57:06 +00:00
|
|
|
* @param message
|
|
|
|
* a message string to be encoded.
|
2012-03-16 23:47:21 +00:00
|
|
|
*
|
2012-03-16 23:57:06 +00:00
|
|
|
* @return null or an options object with attributes `dcs`,
|
2012-03-16 23:59:35 +00:00
|
|
|
* `userDataHeaderLength`, `encodedFullBodyLength`, `langIndex`,
|
2012-03-16 23:57:41 +00:00
|
|
|
* `langShiftIndex`, `segmentMaxSeq` set.
|
2012-03-16 23:57:06 +00:00
|
|
|
*
|
|
|
|
* @see #_calculateUserDataLength().
|
2012-03-16 23:47:21 +00:00
|
|
|
*/
|
2012-03-16 23:57:06 +00:00
|
|
|
_calculateUserDataLength7Bit: function _calculateUserDataLength7Bit(message) {
|
|
|
|
let options = null;
|
2012-03-16 23:47:21 +00:00
|
|
|
let minUserDataSeptets = Number.MAX_VALUE;
|
|
|
|
for (let i = 0; i < this.enabledGsmTableTuples.length; i++) {
|
|
|
|
let [langIndex, langShiftIndex] = this.enabledGsmTableTuples[i];
|
|
|
|
|
|
|
|
const langTable = RIL.PDU_NL_LOCKING_SHIFT_TABLES[langIndex];
|
|
|
|
const langShiftTable = RIL.PDU_NL_SINGLE_SHIFT_TABLES[langShiftIndex];
|
|
|
|
|
2012-03-16 23:57:06 +00:00
|
|
|
let bodySeptets = this._countGsm7BitSeptets(message,
|
|
|
|
langTable,
|
|
|
|
langShiftTable);
|
2012-03-16 23:47:21 +00:00
|
|
|
if (bodySeptets < 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
let headerLen = 0;
|
|
|
|
if (langIndex != RIL.PDU_NL_IDENTIFIER_DEFAULT) {
|
|
|
|
headerLen += 3; // IEI + len + langIndex
|
|
|
|
}
|
|
|
|
if (langShiftIndex != RIL.PDU_NL_IDENTIFIER_DEFAULT) {
|
|
|
|
headerLen += 3; // IEI + len + langShiftIndex
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate full user data length, note the extra byte is for header len
|
|
|
|
let headerSeptets = Math.ceil((headerLen ? headerLen + 1 : 0) * 8 / 7);
|
|
|
|
let userDataSeptets = bodySeptets + headerSeptets;
|
2012-03-16 23:57:41 +00:00
|
|
|
let segments = bodySeptets ? 1 : 0;
|
|
|
|
if (userDataSeptets > RIL.PDU_MAX_USER_DATA_7BIT) {
|
|
|
|
if (this.segmentRef16Bit) {
|
|
|
|
headerLen += 6;
|
|
|
|
} else {
|
|
|
|
headerLen += 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
headerSeptets = Math.ceil((headerLen + 1) * 8 / 7);
|
|
|
|
let segmentSeptets = RIL.PDU_MAX_USER_DATA_7BIT - headerSeptets;
|
|
|
|
segments = Math.ceil(bodySeptets / segmentSeptets);
|
|
|
|
userDataSeptets = bodySeptets + headerSeptets * segments;
|
|
|
|
}
|
|
|
|
|
2012-03-16 23:47:21 +00:00
|
|
|
if (userDataSeptets >= minUserDataSeptets) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
minUserDataSeptets = userDataSeptets;
|
|
|
|
|
2012-03-16 23:57:06 +00:00
|
|
|
options = {
|
|
|
|
dcs: RIL.PDU_DCS_MSG_CODING_7BITS_ALPHABET,
|
2012-03-16 23:59:35 +00:00
|
|
|
encodedFullBodyLength: bodySeptets,
|
2012-03-16 23:57:06 +00:00
|
|
|
userDataHeaderLength: headerLen,
|
|
|
|
langIndex: langIndex,
|
|
|
|
langShiftIndex: langShiftIndex,
|
2012-03-16 23:57:41 +00:00
|
|
|
segmentMaxSeq: segments,
|
2012-03-16 23:57:06 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return options;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate user data length of specified message string encoded in UCS2.
|
|
|
|
*
|
|
|
|
* @param message
|
|
|
|
* a message string to be encoded.
|
|
|
|
*
|
|
|
|
* @return an options object with attributes `dcs`, `userDataHeaderLength`,
|
2012-03-16 23:59:35 +00:00
|
|
|
* `encodedFullBodyLength`, `segmentMaxSeq` set.
|
2012-03-16 23:57:06 +00:00
|
|
|
*
|
|
|
|
* @see #_calculateUserDataLength().
|
|
|
|
*/
|
|
|
|
_calculateUserDataLengthUCS2: function _calculateUserDataLengthUCS2(message) {
|
2012-03-16 23:57:41 +00:00
|
|
|
let bodyChars = message.length;
|
|
|
|
let headerLen = 0;
|
|
|
|
let headerChars = Math.ceil((headerLen ? headerLen + 1 : 0) / 2);
|
|
|
|
let segments = bodyChars ? 1 : 0;
|
|
|
|
if ((bodyChars + headerChars) > RIL.PDU_MAX_USER_DATA_UCS2) {
|
|
|
|
if (this.segmentRef16Bit) {
|
|
|
|
headerLen += 6;
|
|
|
|
} else {
|
|
|
|
headerLen += 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
headerChars = Math.ceil((headerLen + 1) / 2);
|
|
|
|
let segmentChars = RIL.PDU_MAX_USER_DATA_UCS2 - headerChars;
|
|
|
|
segments = Math.ceil(bodyChars / segmentChars);
|
|
|
|
}
|
|
|
|
|
2012-03-16 23:57:06 +00:00
|
|
|
return {
|
|
|
|
dcs: RIL.PDU_DCS_MSG_CODING_16BITS_ALPHABET,
|
2012-03-16 23:59:35 +00:00
|
|
|
encodedFullBodyLength: bodyChars * 2,
|
2012-03-16 23:57:41 +00:00
|
|
|
userDataHeaderLength: headerLen,
|
|
|
|
segmentMaxSeq: segments,
|
2012-03-16 23:57:06 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate user data length and its encoding.
|
|
|
|
*
|
|
|
|
* @param message
|
|
|
|
* a message string to be encoded.
|
|
|
|
*
|
|
|
|
* @return an options object with some or all of following attributes set:
|
|
|
|
*
|
|
|
|
* @param dcs
|
|
|
|
* Data coding scheme. One of the PDU_DCS_MSG_CODING_*BITS_ALPHABET
|
|
|
|
* constants.
|
2012-03-16 23:59:35 +00:00
|
|
|
* @param fullBody
|
|
|
|
* Original unfragmented text message.
|
2012-03-16 23:57:06 +00:00
|
|
|
* @param userDataHeaderLength
|
|
|
|
* Length of embedded user data header, in bytes. The whole header
|
|
|
|
* size will be userDataHeaderLength + 1; 0 for no header.
|
2012-03-16 23:59:35 +00:00
|
|
|
* @param encodedFullBodyLength
|
2012-03-16 23:57:06 +00:00
|
|
|
* Length of the message body when encoded with the given DCS. For
|
|
|
|
* UCS2, in bytes; for 7-bit, in septets.
|
|
|
|
* @param langIndex
|
|
|
|
* Table index used for normal 7-bit encoded character lookup.
|
|
|
|
* @param langShiftIndex
|
|
|
|
* Table index used for escaped 7-bit encoded character lookup.
|
2012-03-16 23:57:41 +00:00
|
|
|
* @param segmentMaxSeq
|
|
|
|
* Max sequence number of a multi-part messages, or 1 for single one.
|
|
|
|
* This number might not be accurate for a multi-part message until
|
|
|
|
* it's processed by #_fragmentText() again.
|
2012-03-16 23:57:06 +00:00
|
|
|
*/
|
|
|
|
_calculateUserDataLength: function _calculateUserDataLength(message) {
|
|
|
|
let options = this._calculateUserDataLength7Bit(message);
|
|
|
|
if (!options) {
|
|
|
|
options = this._calculateUserDataLengthUCS2(message);
|
2012-03-16 23:47:21 +00:00
|
|
|
}
|
|
|
|
|
2012-03-16 23:57:06 +00:00
|
|
|
if (options) {
|
2012-03-16 23:59:35 +00:00
|
|
|
options.fullBody = message;
|
2012-03-16 23:47:21 +00:00
|
|
|
}
|
2012-03-16 23:57:06 +00:00
|
|
|
|
|
|
|
debug("_calculateUserDataLength: " + JSON.stringify(options));
|
|
|
|
return options;
|
2012-03-16 23:47:21 +00:00
|
|
|
},
|
|
|
|
|
2012-03-16 23:57:41 +00:00
|
|
|
/**
|
|
|
|
* Fragment GSM 7-Bit encodable string for transmission.
|
|
|
|
*
|
|
|
|
* @param text
|
|
|
|
* text string to be fragmented.
|
|
|
|
* @param langTable
|
|
|
|
* locking shift table string.
|
|
|
|
* @param langShiftTable
|
|
|
|
* single shift table string.
|
|
|
|
* @param headerLen
|
|
|
|
* Length of prepended user data header.
|
|
|
|
*
|
|
|
|
* @return an array of objects. See #_fragmentText() for detailed definition.
|
|
|
|
*/
|
|
|
|
_fragmentText7Bit: function _fragmentText7Bit(text, langTable, langShiftTable, headerLen) {
|
|
|
|
const headerSeptets = Math.ceil((headerLen ? headerLen + 1 : 0) * 8 / 7);
|
|
|
|
const segmentSeptets = RIL.PDU_MAX_USER_DATA_7BIT - headerSeptets;
|
|
|
|
let ret = [];
|
|
|
|
let begin = 0, len = 0;
|
|
|
|
for (let i = 0, inc = 0; i < text.length; i++) {
|
|
|
|
let septet = langTable.indexOf(text.charAt(i));
|
|
|
|
if (septet == RIL.PDU_NL_EXTENDED_ESCAPE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (septet >= 0) {
|
|
|
|
inc = 1;
|
|
|
|
} else {
|
|
|
|
septet = langShiftTable.indexOf(text.charAt(i));
|
|
|
|
if (septet < 0) {
|
|
|
|
throw new Error("Given text cannot be encoded with GSM 7-bit Alphabet!");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (septet == RIL.PDU_NL_RESERVED_CONTROL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
inc = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((len + inc) > segmentSeptets) {
|
|
|
|
ret.push({
|
|
|
|
body: text.substring(begin, i),
|
|
|
|
encodedBodyLength: len,
|
|
|
|
});
|
|
|
|
begin = i;
|
|
|
|
len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
len += inc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len) {
|
|
|
|
ret.push({
|
|
|
|
body: text.substring(begin),
|
|
|
|
encodedBodyLength: len,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fragment UCS2 encodable string for transmission.
|
|
|
|
*
|
|
|
|
* @param text
|
|
|
|
* text string to be fragmented.
|
|
|
|
* @param headerLen
|
|
|
|
* Length of prepended user data header.
|
|
|
|
*
|
|
|
|
* @return an array of objects. See #_fragmentText() for detailed definition.
|
|
|
|
*/
|
|
|
|
_fragmentTextUCS2: function _fragmentTextUCS2(text, headerLen) {
|
|
|
|
const headerChars = Math.ceil((headerLen ? headerLen + 1 : 0) / 2);
|
|
|
|
const segmentChars = RIL.PDU_MAX_USER_DATA_UCS2 - headerChars;
|
|
|
|
let ret = [];
|
|
|
|
for (let offset = 0; offset < text.length; offset += segmentChars) {
|
|
|
|
let str = text.substr(offset, segmentChars);
|
|
|
|
ret.push({
|
|
|
|
body: str,
|
|
|
|
encodedBodyLength: str.length * 2,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fragment string for transmission.
|
|
|
|
*
|
|
|
|
* Fragment input text string into an array of objects that contains
|
|
|
|
* attributes `body`, substring for this segment, `encodedBodyLength`,
|
|
|
|
* length of the encoded segment body in septets.
|
|
|
|
*
|
|
|
|
* @param text
|
|
|
|
* Text string to be fragmented.
|
|
|
|
* @param options
|
|
|
|
* Optional pre-calculated option object. The output array will be
|
|
|
|
* stored at options.segments if there are multiple segments.
|
|
|
|
*
|
|
|
|
* @return Populated options object.
|
|
|
|
*/
|
|
|
|
_fragmentText: function _fragmentText(text, options) {
|
|
|
|
if (!options) {
|
|
|
|
options = this._calculateUserDataLength(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.segmentMaxSeq <= 1) {
|
|
|
|
options.segments = null;
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.dcs == RIL.PDU_DCS_MSG_CODING_7BITS_ALPHABET) {
|
|
|
|
const langTable = RIL.PDU_NL_LOCKING_SHIFT_TABLES[options.langIndex];
|
|
|
|
const langShiftTable = RIL.PDU_NL_SINGLE_SHIFT_TABLES[options.langShiftIndex];
|
2012-03-16 23:59:35 +00:00
|
|
|
options.segments = this._fragmentText7Bit(options.fullBody,
|
2012-03-16 23:57:41 +00:00
|
|
|
langTable, langShiftTable,
|
|
|
|
options.userDataHeaderLength);
|
|
|
|
} else {
|
2012-03-16 23:59:35 +00:00
|
|
|
options.segments = this._fragmentTextUCS2(options.fullBody,
|
2012-03-16 23:57:41 +00:00
|
|
|
options.userDataHeaderLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Re-sync options.segmentMaxSeq with actual length of returning array.
|
|
|
|
options.segmentMaxSeq = options.segments.length;
|
|
|
|
|
|
|
|
return options;
|
|
|
|
},
|
|
|
|
|
2011-12-24 05:02:52 +00:00
|
|
|
getNumberOfMessagesForText: function getNumberOfMessagesForText(text) {
|
2012-03-16 23:57:41 +00:00
|
|
|
return this._fragmentText(text).segmentMaxSeq;
|
2011-12-24 05:02:52 +00:00
|
|
|
},
|
|
|
|
|
2012-02-19 23:44:29 +00:00
|
|
|
sendSMS: function sendSMS(number, message, requestId, processId) {
|
2012-03-16 23:57:06 +00:00
|
|
|
let options = this._calculateUserDataLength(message);
|
2012-08-06 21:28:03 +00:00
|
|
|
options.rilMessageType = "sendSMS";
|
2012-03-16 23:57:06 +00:00
|
|
|
options.number = number;
|
|
|
|
options.requestId = requestId;
|
|
|
|
options.processId = processId;
|
2012-04-05 21:16:56 +00:00
|
|
|
options.requestStatusReport = true;
|
2012-03-16 23:47:21 +00:00
|
|
|
|
2012-03-16 23:59:35 +00:00
|
|
|
this._fragmentText(message, options);
|
|
|
|
if (options.segmentMaxSeq > 1) {
|
|
|
|
options.segmentRef16Bit = this.segmentRef16Bit;
|
|
|
|
options.segmentRef = this.nextSegmentRef;
|
|
|
|
}
|
|
|
|
|
2012-04-05 21:16:56 +00:00
|
|
|
// Keep current SMS message info for sent/delivered notifications
|
|
|
|
this.createSmsEnvelope(options);
|
|
|
|
|
2012-03-16 23:47:21 +00:00
|
|
|
this.worker.postMessage(options);
|
2011-12-24 05:02:52 +00:00
|
|
|
},
|
|
|
|
|
2012-01-18 01:34:09 +00:00
|
|
|
registerDataCallCallback: function registerDataCallCallback(callback) {
|
|
|
|
if (this._datacall_callbacks) {
|
|
|
|
if (this._datacall_callbacks.indexOf(callback) != -1) {
|
|
|
|
throw new Error("Already registered this callback!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this._datacall_callbacks = [];
|
|
|
|
}
|
|
|
|
this._datacall_callbacks.push(callback);
|
|
|
|
debug("Registering callback: " + callback);
|
|
|
|
},
|
|
|
|
|
|
|
|
unregisterDataCallCallback: function unregisterDataCallCallback(callback) {
|
|
|
|
if (!this._datacall_callbacks) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let index = this._datacall_callbacks.indexOf(callback);
|
|
|
|
if (index != -1) {
|
|
|
|
this._datacall_callbacks.splice(index, 1);
|
|
|
|
debug("Unregistering callback: " + callback);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_deliverDataCallCallback: function _deliverDataCallCallback(name, args) {
|
|
|
|
// We need to worry about callback registration state mutations during the
|
|
|
|
// callback firing. The behaviour we want is to *not* call any callbacks
|
|
|
|
// that are added during the firing and to *not* call any callbacks that are
|
|
|
|
// removed during the firing. To address this, we make a copy of the
|
|
|
|
// callback list before dispatching and then double-check that each callback
|
|
|
|
// is still registered before calling it.
|
|
|
|
if (!this._datacall_callbacks) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let callbacks = this._datacall_callbacks.slice();
|
|
|
|
for each (let callback in callbacks) {
|
|
|
|
if (this._datacall_callbacks.indexOf(callback) == -1) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
let handler = callback[name];
|
|
|
|
if (typeof handler != "function") {
|
|
|
|
throw new Error("No handler for " + name);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
handler.apply(callback, args);
|
|
|
|
} catch (e) {
|
|
|
|
debug("callback handler for " + name + " threw an exception: " + e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-02-10 19:27:38 +00:00
|
|
|
setupDataCall: function setupDataCall(radioTech, apn, user, passwd, chappap, pdptype) {
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: "setupDataCall",
|
2012-01-18 01:34:09 +00:00
|
|
|
radioTech: radioTech,
|
|
|
|
apn: apn,
|
|
|
|
user: user,
|
|
|
|
passwd: passwd,
|
|
|
|
chappap: chappap,
|
|
|
|
pdptype: pdptype});
|
|
|
|
},
|
|
|
|
|
2012-02-10 19:27:38 +00:00
|
|
|
deactivateDataCall: function deactivateDataCall(cid, reason) {
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: "deactivateDataCall",
|
2012-01-18 01:34:09 +00:00
|
|
|
cid: cid,
|
|
|
|
reason: reason});
|
|
|
|
},
|
|
|
|
|
|
|
|
getDataCallList: function getDataCallList() {
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: "getDataCallList"});
|
2012-01-18 01:34:09 +00:00
|
|
|
},
|
|
|
|
|
2012-04-12 04:01:49 +00:00
|
|
|
getCardLock: function getCardLock(message) {
|
2012-08-15 16:49:12 +00:00
|
|
|
message.rilMessageType = "iccGetCardLock";
|
2012-04-12 04:01:49 +00:00
|
|
|
this.worker.postMessage(message);
|
|
|
|
},
|
|
|
|
|
|
|
|
unlockCardLock: function unlockCardLock(message) {
|
2012-08-15 16:49:12 +00:00
|
|
|
message.rilMessageType = "iccUnlockCardLock";
|
2012-04-12 04:01:49 +00:00
|
|
|
this.worker.postMessage(message);
|
|
|
|
},
|
2011-12-05 07:58:27 +00:00
|
|
|
|
2012-04-12 04:01:49 +00:00
|
|
|
setCardLock: function setCardLock(message) {
|
2012-08-15 16:49:12 +00:00
|
|
|
message.rilMessageType = "iccSetCardLock";
|
2012-04-12 04:01:49 +00:00
|
|
|
this.worker.postMessage(message);
|
2012-05-07 18:53:42 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_contactsCallbacks: null,
|
|
|
|
getICCContacts: function getICCContacts(type, callback) {
|
|
|
|
if (!this._contactsCallbacks) {
|
|
|
|
this._contactsCallbacks = {};
|
|
|
|
}
|
|
|
|
let requestId = Math.floor(Math.random() * 1000);
|
|
|
|
this._contactsCallbacks[requestId] = callback;
|
|
|
|
|
|
|
|
let msgType;
|
|
|
|
switch (type) {
|
|
|
|
case "ADN":
|
|
|
|
msgType = "getPBR";
|
|
|
|
break;
|
|
|
|
case "FDN":
|
|
|
|
msgType = "getFDN";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
debug("Unknown contact type. " + type);
|
|
|
|
return;
|
|
|
|
}
|
2012-08-06 21:28:03 +00:00
|
|
|
this.worker.postMessage({rilMessageType: msgType, requestId: requestId});
|
2012-04-12 04:01:49 +00:00
|
|
|
}
|
|
|
|
};
|
2012-03-12 23:46:08 +00:00
|
|
|
|
|
|
|
let RILNetworkInterface = {
|
|
|
|
|
2012-04-19 21:33:25 +00:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInterface,
|
|
|
|
Ci.nsIRILDataCallback]),
|
2012-03-12 23:46:08 +00:00
|
|
|
|
2012-04-19 21:33:25 +00:00
|
|
|
// nsINetworkInterface
|
2012-03-12 23:46:08 +00:00
|
|
|
|
2012-04-19 21:33:25 +00:00
|
|
|
NETWORK_STATE_UNKNOWN: Ci.nsINetworkInterface.NETWORK_STATE_UNKNOWN,
|
|
|
|
NETWORK_STATE_CONNECTING: Ci.nsINetworkInterface.CONNECTING,
|
|
|
|
NETWORK_STATE_CONNECTED: Ci.nsINetworkInterface.CONNECTED,
|
|
|
|
NETWORK_STATE_DISCONNECTING: Ci.nsINetworkInterface.DISCONNECTING,
|
|
|
|
NETWORK_STATE_DISCONNECTED: Ci.nsINetworkInterface.DISCONNECTED,
|
2012-03-12 23:46:08 +00:00
|
|
|
|
2012-04-19 21:33:25 +00:00
|
|
|
state: Ci.nsINetworkInterface.NETWORK_STATE_UNKNOWN,
|
|
|
|
|
2012-08-30 16:57:33 +00:00
|
|
|
NETWORK_TYPE_WIFI: Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
|
|
|
|
NETWORK_TYPE_MOBILE: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE,
|
|
|
|
NETWORK_TYPE_MOBILE_MMS: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS,
|
|
|
|
NETWORK_TYPE_MOBILE_SUPL: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL,
|
2012-04-19 21:33:25 +00:00
|
|
|
|
2012-06-01 21:09:59 +00:00
|
|
|
/**
|
|
|
|
* Standard values for the APN connection retry process
|
|
|
|
* Retry funcion: time(secs) = A * numer_of_retries^2 + B
|
|
|
|
*/
|
|
|
|
NETWORK_APNRETRY_FACTOR: 8,
|
|
|
|
NETWORK_APNRETRY_ORIGIN: 3,
|
|
|
|
NETWORK_APNRETRY_MAXRETRIES: 10,
|
|
|
|
|
|
|
|
// Event timer for connection retries
|
|
|
|
timer: null,
|
|
|
|
|
2012-04-19 21:33:25 +00:00
|
|
|
type: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE,
|
|
|
|
|
|
|
|
name: null,
|
|
|
|
|
|
|
|
dhcp: false,
|
2012-03-12 23:46:08 +00:00
|
|
|
|
2012-08-14 01:54:42 +00:00
|
|
|
ip: null,
|
|
|
|
|
|
|
|
netmask: null,
|
|
|
|
|
|
|
|
broadcast: null,
|
|
|
|
|
|
|
|
dns1: null,
|
|
|
|
|
|
|
|
dns2: null,
|
|
|
|
|
2012-08-01 14:55:43 +00:00
|
|
|
httpProxyHost: null,
|
|
|
|
|
|
|
|
httpProxyPort: null,
|
|
|
|
|
2012-03-12 23:46:08 +00:00
|
|
|
// nsIRILDataCallback
|
|
|
|
|
2012-06-22 05:53:12 +00:00
|
|
|
dataCallStateChanged: function dataCallStateChanged(datacall) {
|
|
|
|
debug("Data call ID: " + datacall.cid + ", interface name: " + datacall.ifname);
|
2012-03-12 23:46:08 +00:00
|
|
|
if (this.connecting &&
|
2012-06-22 05:53:12 +00:00
|
|
|
(datacall.state == RIL.GECKO_NETWORK_STATE_CONNECTING ||
|
|
|
|
datacall.state == RIL.GECKO_NETWORK_STATE_CONNECTED)) {
|
2012-03-12 23:46:08 +00:00
|
|
|
this.connecting = false;
|
2012-06-22 05:53:12 +00:00
|
|
|
this.cid = datacall.cid;
|
|
|
|
this.name = datacall.ifname;
|
2012-08-14 01:54:42 +00:00
|
|
|
this.ip = datacall.ip;
|
|
|
|
this.netmask = datacall.netmask;
|
|
|
|
this.broadcast = datacall.broadcast;
|
|
|
|
this.gateway = datacall.gw;
|
2012-08-26 02:29:07 +00:00
|
|
|
if (datacall.dns) {
|
|
|
|
this.dns1 = datacall.dns[0];
|
|
|
|
this.dns2 = datacall.dns[1];
|
|
|
|
}
|
2012-04-19 21:33:25 +00:00
|
|
|
if (!this.registeredAsNetworkInterface) {
|
|
|
|
let networkManager = Cc["@mozilla.org/network/manager;1"]
|
|
|
|
.getService(Ci.nsINetworkManager);
|
|
|
|
networkManager.registerNetworkInterface(this);
|
|
|
|
this.registeredAsNetworkInterface = true;
|
|
|
|
}
|
2012-03-12 23:46:08 +00:00
|
|
|
}
|
2012-06-22 05:53:12 +00:00
|
|
|
if (this.cid != datacall.cid) {
|
2012-03-12 23:46:08 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-06-22 05:53:12 +00:00
|
|
|
if (this.state == datacall.state) {
|
2012-03-12 23:46:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-06-22 05:53:12 +00:00
|
|
|
this.state = datacall.state;
|
2012-04-19 21:33:25 +00:00
|
|
|
Services.obs.notifyObservers(this,
|
|
|
|
kNetworkInterfaceStateChangedTopic,
|
|
|
|
null);
|
2012-03-12 23:46:08 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
receiveDataCallList: function receiveDataCallList(dataCalls, length) {
|
|
|
|
},
|
|
|
|
|
|
|
|
// Helpers
|
|
|
|
|
2012-04-19 21:33:25 +00:00
|
|
|
cid: null,
|
|
|
|
registeredAsDataCallCallback: false,
|
|
|
|
registeredAsNetworkInterface: false,
|
|
|
|
connecting: false,
|
2012-08-01 14:54:04 +00:00
|
|
|
dataCallSettings: {},
|
2012-04-19 21:33:25 +00:00
|
|
|
|
2012-06-01 21:09:59 +00:00
|
|
|
// APN failed connections. Retry counter
|
|
|
|
apnRetryCounter: 0,
|
|
|
|
|
2012-03-12 23:46:08 +00:00
|
|
|
get mRIL() {
|
|
|
|
delete this.mRIL;
|
|
|
|
return this.mRIL = Cc["@mozilla.org/telephony/system-worker-manager;1"]
|
|
|
|
.getService(Ci.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Ci.nsIRadioInterfaceLayer);
|
|
|
|
},
|
|
|
|
|
2012-04-24 20:46:42 +00:00
|
|
|
get connected() {
|
|
|
|
return this.state == RIL.GECKO_NETWORK_STATE_CONNECTED;
|
|
|
|
},
|
|
|
|
|
2012-08-01 14:54:04 +00:00
|
|
|
connect: function connect(options) {
|
2012-08-28 14:37:43 +00:00
|
|
|
if (this.connecting || this.connected) {
|
2012-03-12 23:46:08 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-08-01 14:54:04 +00:00
|
|
|
|
2012-03-12 23:46:08 +00:00
|
|
|
if (!this.registeredAsDataCallCallback) {
|
|
|
|
this.mRIL.registerDataCallCallback(this);
|
|
|
|
this.registeredAsDataCallCallback = true;
|
|
|
|
}
|
|
|
|
|
2012-08-01 14:54:04 +00:00
|
|
|
if (options) {
|
|
|
|
// Save the APN data locally for using them in connection retries.
|
|
|
|
this.dataCallSettings = options;
|
2012-03-12 23:46:08 +00:00
|
|
|
}
|
2012-08-01 14:54:04 +00:00
|
|
|
|
2012-08-01 14:55:43 +00:00
|
|
|
this.httpProxyHost = this.dataCallSettings["httpProxyHost"];
|
|
|
|
this.httpProxyPort = this.dataCallSettings["httpProxyPort"];
|
|
|
|
|
2012-08-01 14:54:04 +00:00
|
|
|
debug("Going to set up data connection with APN " + this.dataCallSettings["apn"]);
|
2012-03-12 23:46:08 +00:00
|
|
|
this.mRIL.setupDataCall(RIL.DATACALL_RADIOTECHNOLOGY_GSM,
|
2012-08-01 14:54:04 +00:00
|
|
|
this.dataCallSettings["apn"],
|
|
|
|
this.dataCallSettings["user"],
|
|
|
|
this.dataCallSettings["passwd"],
|
2012-03-12 23:46:08 +00:00
|
|
|
RIL.DATACALL_AUTH_PAP_OR_CHAP, "IP");
|
|
|
|
this.connecting = true;
|
|
|
|
},
|
|
|
|
|
2012-06-01 21:09:59 +00:00
|
|
|
reset: function reset() {
|
|
|
|
let apnRetryTimer;
|
|
|
|
this.connecting = false;
|
|
|
|
// We will retry the connection in increasing times
|
|
|
|
// based on the function: time = A * numer_of_retries^2 + B
|
|
|
|
if (this.apnRetryCounter >= this.NETWORK_APNRETRY_MAXRETRIES) {
|
|
|
|
this.apnRetryCounter = 0;
|
|
|
|
this.timer = null;
|
|
|
|
debug("Too many APN Connection retries - STOP retrying");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
apnRetryTimer = this.NETWORK_APNRETRY_FACTOR *
|
|
|
|
(this.apnRetryCounter * this.apnRetryCounter) +
|
|
|
|
this.NETWORK_APNRETRY_ORIGIN;
|
|
|
|
this.apnRetryCounter++;
|
|
|
|
debug("Data call - APN Connection Retry Timer (secs-counter): " +
|
|
|
|
apnRetryTimer + "-" + this.apnRetryCounter);
|
|
|
|
|
|
|
|
if (this.timer == null) {
|
|
|
|
// Event timer for connection retries
|
|
|
|
this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
|
|
|
}
|
|
|
|
this.timer.initWithCallback(this, apnRetryTimer * 1000,
|
|
|
|
Ci.nsITimer.TYPE_ONE_SHOT);
|
|
|
|
},
|
|
|
|
|
2012-03-12 23:46:08 +00:00
|
|
|
disconnect: function disconnect() {
|
2012-04-24 20:46:42 +00:00
|
|
|
if (this.state == RIL.GECKO_NETWORK_STATE_DISCONNECTING ||
|
|
|
|
this.state == RIL.GECKO_NETWORK_STATE_DISCONNECTED) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let reason = RIL.DATACALL_DEACTIVATE_NO_REASON;
|
|
|
|
debug("Going to disconnet data connection " + this.cid);
|
|
|
|
this.mRIL.deactivateDataCall(this.cid, reason);
|
2012-03-12 23:46:08 +00:00
|
|
|
},
|
|
|
|
|
2012-06-01 21:09:59 +00:00
|
|
|
// Entry method for timer events. Used to reconnect to a failed APN
|
|
|
|
notify: function(timer) {
|
|
|
|
RILNetworkInterface.connect();
|
|
|
|
},
|
|
|
|
|
|
|
|
shutdown: function() {
|
|
|
|
this.timer = null;
|
|
|
|
}
|
|
|
|
|
2012-03-12 23:46:08 +00:00
|
|
|
};
|
|
|
|
|
2012-01-19 20:53:32 +00:00
|
|
|
const NSGetFactory = XPCOMUtils.generateNSGetFactory([RadioInterfaceLayer]);
|
2011-12-05 07:58:27 +00:00
|
|
|
|
|
|
|
let debug;
|
|
|
|
if (DEBUG) {
|
|
|
|
debug = function (s) {
|
2012-01-19 20:53:32 +00:00
|
|
|
dump("-*- RadioInterfaceLayer: " + s + "\n");
|
2011-12-05 07:58:27 +00:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
debug = function (s) {};
|
|
|
|
}
|