2014-06-25 05:12:07 +00:00
|
|
|
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
2013-09-07 06:19:57 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
|
|
|
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
2013-10-31 12:05:51 +00:00
|
|
|
Cu.import("resource://gre/modules/Promise.jsm");
|
2013-09-07 06:19:57 +00:00
|
|
|
|
2015-03-02 07:21:03 +00:00
|
|
|
/* global RIL */
|
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;
|
|
|
|
});
|
2013-09-07 06:19:57 +00:00
|
|
|
|
2014-06-03 14:15:25 +00:00
|
|
|
const GONK_TELEPHONYSERVICE_CONTRACTID =
|
|
|
|
"@mozilla.org/telephony/gonktelephonyservice;1";
|
2015-01-08 08:33:51 +00:00
|
|
|
|
2014-06-03 14:15:25 +00:00
|
|
|
const GONK_TELEPHONYSERVICE_CID =
|
2013-09-07 06:19:57 +00:00
|
|
|
Components.ID("{67d26434-d063-4d28-9f48-5b3189788155}");
|
2015-01-08 08:33:51 +00:00
|
|
|
const TELEPHONYCALLINFO_CID =
|
|
|
|
Components.ID("{d9e8b358-a02c-4cf3-9fc7-816c2e8d46e4}");
|
2013-09-07 06:19:57 +00:00
|
|
|
|
2014-08-11 06:48:00 +00:00
|
|
|
const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown";
|
2013-10-24 08:14:59 +00:00
|
|
|
|
|
|
|
const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
|
|
|
|
|
2013-10-24 08:15:06 +00:00
|
|
|
const kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
|
2013-10-24 08:14:59 +00:00
|
|
|
const kPrefRilDebuggingEnabled = "ril.debugging.enabled";
|
2013-10-24 08:15:06 +00:00
|
|
|
const kPrefDefaultServiceId = "dom.telephony.defaultServiceId";
|
2013-09-07 06:19:57 +00:00
|
|
|
|
2014-11-14 07:20:44 +00:00
|
|
|
const nsITelephonyAudioService = Ci.nsITelephonyAudioService;
|
2014-06-03 14:15:25 +00:00
|
|
|
const nsITelephonyService = Ci.nsITelephonyService;
|
2015-02-03 04:18:20 +00:00
|
|
|
const nsIMobileConnection = Ci.nsIMobileConnection;
|
2013-09-07 06:19:57 +00:00
|
|
|
|
|
|
|
const CALL_WAKELOCK_TIMEOUT = 5000;
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
// In CDMA, RIL only hold one call index. We need to fake a second call index
|
|
|
|
// in TelephonyService for 3-way calling.
|
|
|
|
const CDMA_FIRST_CALL_INDEX = 1;
|
2014-02-21 09:46:58 +00:00
|
|
|
const CDMA_SECOND_CALL_INDEX = 2;
|
|
|
|
|
2014-04-01 12:58:55 +00:00
|
|
|
const DIAL_ERROR_INVALID_STATE_ERROR = "InvalidStateError";
|
|
|
|
const DIAL_ERROR_OTHER_CONNECTION_IN_USE = "OtherConnectionInUse";
|
2014-08-11 06:48:00 +00:00
|
|
|
const DIAL_ERROR_BAD_NUMBER = RIL.GECKO_CALL_ERROR_BAD_NUMBER;
|
2015-02-03 04:18:20 +00:00
|
|
|
const DIAL_ERROR_RADIO_NOT_AVAILABLE = RIL.GECKO_ERROR_RADIO_NOT_AVAILABLE;
|
2014-06-24 10:32:41 +00:00
|
|
|
|
2015-01-07 06:37:03 +00:00
|
|
|
const TONES_GAP_DURATION = 70;
|
|
|
|
|
2015-10-24 11:57:20 +00:00
|
|
|
const EMERGENCY_CALL_DEFAULT_CLIENT_ID = 0;
|
|
|
|
|
2015-04-29 07:05:06 +00:00
|
|
|
// Consts for MMI.
|
2015-05-05 11:27:23 +00:00
|
|
|
// MMI procedure as defined in TS.22.030 6.5.2
|
|
|
|
const MMI_PROCEDURE_ACTIVATION = "*";
|
|
|
|
const MMI_PROCEDURE_DEACTIVATION = "#";
|
|
|
|
const MMI_PROCEDURE_INTERROGATION = "*#";
|
|
|
|
const MMI_PROCEDURE_REGISTRATION = "**";
|
|
|
|
const MMI_PROCEDURE_ERASURE = "##";
|
|
|
|
|
2015-10-07 12:03:21 +00:00
|
|
|
XPCOMUtils.defineConstant(this, "MMI_PROCEDURE_ACTIVATION", MMI_PROCEDURE_ACTIVATION);
|
|
|
|
XPCOMUtils.defineConstant(this, "MMI_PROCEDURE_DEACTIVATION", MMI_PROCEDURE_DEACTIVATION);
|
|
|
|
XPCOMUtils.defineConstant(this, "MMI_PROCEDURE_INTERROGATION", MMI_PROCEDURE_INTERROGATION);
|
|
|
|
XPCOMUtils.defineConstant(this, "MMI_PROCEDURE_REGISTRATION", MMI_PROCEDURE_REGISTRATION);
|
|
|
|
XPCOMUtils.defineConstant(this, "MMI_PROCEDURE_ERASURE", MMI_PROCEDURE_ERASURE);
|
|
|
|
|
2015-05-05 11:27:23 +00:00
|
|
|
// MMI call forwarding service codes as defined in TS.22.030 Annex B
|
|
|
|
const MMI_SC_CFU = "21";
|
|
|
|
const MMI_SC_CF_BUSY = "67";
|
|
|
|
const MMI_SC_CF_NO_REPLY = "61";
|
|
|
|
const MMI_SC_CF_NOT_REACHABLE = "62";
|
|
|
|
const MMI_SC_CF_ALL = "002";
|
|
|
|
const MMI_SC_CF_ALL_CONDITIONAL = "004";
|
|
|
|
|
|
|
|
// MMI service codes for PIN/PIN2/PUK/PUK2 management as defined in TS.22.030
|
|
|
|
// sec 6.6
|
|
|
|
const MMI_SC_PIN = "04";
|
|
|
|
const MMI_SC_PIN2 = "042";
|
|
|
|
const MMI_SC_PUK = "05";
|
|
|
|
const MMI_SC_PUK2 = "052";
|
|
|
|
|
|
|
|
// MMI service code for IMEI presentation as defined in TS.22.030 sec 6.7
|
|
|
|
const MMI_SC_IMEI = "06";
|
|
|
|
|
|
|
|
// MMI call waiting service code
|
|
|
|
const MMI_SC_CALL_WAITING = "43";
|
|
|
|
|
|
|
|
// MMI service code for registration new password as defined in TS 22.030 6.5.4
|
|
|
|
const MMI_SC_CHANGE_PASSWORD = "03";
|
|
|
|
const MMI_ZZ_BARRING_SERVICE = "330";
|
|
|
|
|
|
|
|
// MMI call barring service codes
|
|
|
|
const MMI_SC_BAOC = "33";
|
|
|
|
const MMI_SC_BAOIC = "331";
|
|
|
|
const MMI_SC_BAOICxH = "332";
|
|
|
|
const MMI_SC_BAIC = "35";
|
|
|
|
const MMI_SC_BAICr = "351";
|
|
|
|
const MMI_SC_BA_ALL = "330";
|
|
|
|
const MMI_SC_BA_MO = "333";
|
|
|
|
const MMI_SC_BA_MT = "353";
|
|
|
|
|
|
|
|
// MMI called line presentation service codes
|
|
|
|
const MMI_SC_CLIP = "30";
|
|
|
|
const MMI_SC_CLIR = "31";
|
|
|
|
|
|
|
|
// MMI service code key strings.
|
|
|
|
const MMI_KS_SC_CALL_BARRING = "scCallBarring";
|
|
|
|
const MMI_KS_SC_CALL_FORWARDING = "scCallForwarding";
|
|
|
|
const MMI_KS_SC_CLIP = "scClip";
|
|
|
|
const MMI_KS_SC_CLIR = "scClir";
|
|
|
|
const MMI_KS_SC_PWD = "scPwd";
|
|
|
|
const MMI_KS_SC_CALL_WAITING = "scCallWaiting";
|
|
|
|
const MMI_KS_SC_PIN = "scPin";
|
|
|
|
const MMI_KS_SC_PIN2 = "scPin2";
|
|
|
|
const MMI_KS_SC_PUK = "scPuk";
|
|
|
|
const MMI_KS_SC_PUK2 = "scPuk2";
|
|
|
|
const MMI_KS_SC_CHANGE_PASSWORD = "scChangePassword";
|
|
|
|
const MMI_KS_SC_IMEI = "scImei";
|
|
|
|
const MMI_KS_SC_USSD = "scUssd";
|
|
|
|
const MMI_KS_SC_CALL = "scCall";
|
|
|
|
|
|
|
|
// MMI error messages key strings.
|
|
|
|
const MMI_ERROR_KS_ERROR = "emMmiError";
|
|
|
|
const MMI_ERROR_KS_NOT_SUPPORTED = "emMmiErrorNotSupported";
|
|
|
|
const MMI_ERROR_KS_INVALID_ACTION = "emMmiErrorInvalidAction";
|
|
|
|
const MMI_ERROR_KS_MISMATCH_PIN = "emMmiErrorMismatchPin";
|
|
|
|
const MMI_ERROR_KS_MISMATCH_PASSWORD = "emMmiErrorMismatchPassword";
|
|
|
|
const MMI_ERROR_KS_BAD_PIN = "emMmiErrorBadPin";
|
|
|
|
const MMI_ERROR_KS_BAD_PUK = "emMmiErrorBadPuk";
|
|
|
|
const MMI_ERROR_KS_INVALID_PIN = "emMmiErrorInvalidPin";
|
|
|
|
const MMI_ERROR_KS_INVALID_PASSWORD = "emMmiErrorInvalidPassword";
|
|
|
|
const MMI_ERROR_KS_NEEDS_PUK = "emMmiErrorNeedsPuk";
|
|
|
|
const MMI_ERROR_KS_SIM_BLOCKED = "emMmiErrorSimBlocked";
|
|
|
|
|
|
|
|
// MMI status message.
|
|
|
|
const MMI_SM_KS_PASSWORD_CHANGED = "smPasswordChanged";
|
|
|
|
const MMI_SM_KS_PIN_CHANGED = "smPinChanged";
|
|
|
|
const MMI_SM_KS_PIN2_CHANGED = "smPin2Changed";
|
|
|
|
const MMI_SM_KS_PIN_UNBLOCKED = "smPinUnblocked";
|
|
|
|
const MMI_SM_KS_PIN2_UNBLOCKED = "smPin2Unblocked";
|
|
|
|
const MMI_SM_KS_SERVICE_ENABLED = "smServiceEnabled";
|
|
|
|
const MMI_SM_KS_SERVICE_ENABLED_FOR = "smServiceEnabledFor";
|
|
|
|
const MMI_SM_KS_SERVICE_DISABLED = "smServiceDisabled";
|
|
|
|
const MMI_SM_KS_SERVICE_REGISTERED = "smServiceRegistered";
|
|
|
|
const MMI_SM_KS_SERVICE_ERASED = "smServiceErased";
|
|
|
|
const MMI_SM_KS_SERVICE_INTERROGATED = "smServiceInterrogated";
|
|
|
|
const MMI_SM_KS_SERVICE_NOT_PROVISIONED = "smServiceNotProvisioned";
|
|
|
|
const MMI_SM_KS_CLIR_PERMANENT = "smClirPermanent";
|
|
|
|
const MMI_SM_KS_CLIR_DEFAULT_ON_NEXT_CALL_ON = "smClirDefaultOnNextCallOn";
|
|
|
|
const MMI_SM_KS_CLIR_DEFAULT_ON_NEXT_CALL_OFF = "smClirDefaultOnNextCallOff";
|
|
|
|
const MMI_SM_KS_CLIR_DEFAULT_OFF_NEXT_CALL_ON = "smClirDefaultOffNextCallOn";
|
|
|
|
const MMI_SM_KS_CLIR_DEFAULT_OFF_NEXT_CALL_OFF = "smClirDefaultOffNextCallOff";
|
|
|
|
const MMI_SM_KS_CALL_CONTROL = "smCallControl";
|
|
|
|
|
|
|
|
// MMI Service class
|
|
|
|
const MMI_KS_SERVICE_CLASS_VOICE = "serviceClassVoice";
|
|
|
|
const MMI_KS_SERVICE_CLASS_DATA = "serviceClassData";
|
|
|
|
const MMI_KS_SERVICE_CLASS_FAX = "serviceClassFax";
|
|
|
|
const MMI_KS_SERVICE_CLASS_SMS = "serviceClassSms";
|
|
|
|
const MMI_KS_SERVICE_CLASS_DATA_SYNC = "serviceClassDataSync";
|
|
|
|
const MMI_KS_SERVICE_CLASS_DATA_ASYNC = "serviceClassDataAsync";
|
|
|
|
const MMI_KS_SERVICE_CLASS_PACKET = "serviceClassPacket";
|
|
|
|
const MMI_KS_SERVICE_CLASS_PAD = "serviceClassPad";
|
|
|
|
|
2015-08-28 08:39:57 +00:00
|
|
|
// States of USSD Session : DONE -> ONGOING [-> CANCELLING] -> DONE
|
|
|
|
const USSD_SESSION_DONE = "DONE";
|
|
|
|
const USSD_SESSION_ONGOING = "ONGOING";
|
|
|
|
const USSD_SESSION_CANCELLING = "CANCELLING";
|
|
|
|
|
2015-05-05 11:27:23 +00:00
|
|
|
const MMI_PROC_TO_CF_ACTION = {};
|
|
|
|
MMI_PROC_TO_CF_ACTION[MMI_PROCEDURE_ACTIVATION] = Ci.nsIMobileConnection.CALL_FORWARD_ACTION_ENABLE;
|
|
|
|
MMI_PROC_TO_CF_ACTION[MMI_PROCEDURE_DEACTIVATION] = Ci.nsIMobileConnection.CALL_FORWARD_ACTION_DISABLE;
|
|
|
|
MMI_PROC_TO_CF_ACTION[MMI_PROCEDURE_INTERROGATION] = Ci.nsIMobileConnection.CALL_FORWARD_ACTION_QUERY_STATUS;
|
|
|
|
MMI_PROC_TO_CF_ACTION[MMI_PROCEDURE_REGISTRATION] = Ci.nsIMobileConnection.CALL_FORWARD_ACTION_REGISTRATION;
|
|
|
|
MMI_PROC_TO_CF_ACTION[MMI_PROCEDURE_ERASURE] = Ci.nsIMobileConnection.CALL_FORWARD_ACTION_ERASURE;
|
|
|
|
|
|
|
|
const MMI_SC_TO_CF_REASON = {};
|
|
|
|
MMI_SC_TO_CF_REASON[MMI_SC_CFU] = Ci.nsIMobileConnection.CALL_FORWARD_REASON_UNCONDITIONAL;
|
|
|
|
MMI_SC_TO_CF_REASON[MMI_SC_CF_BUSY] = Ci.nsIMobileConnection.CALL_FORWARD_REASON_MOBILE_BUSY;
|
|
|
|
MMI_SC_TO_CF_REASON[MMI_SC_CF_NO_REPLY] = Ci.nsIMobileConnection.CALL_FORWARD_REASON_NO_REPLY;
|
|
|
|
MMI_SC_TO_CF_REASON[MMI_SC_CF_NOT_REACHABLE] = Ci.nsIMobileConnection.CALL_FORWARD_REASON_NOT_REACHABLE;
|
|
|
|
MMI_SC_TO_CF_REASON[MMI_SC_CF_ALL] = Ci.nsIMobileConnection.CALL_FORWARD_REASON_ALL_CALL_FORWARDING;
|
|
|
|
MMI_SC_TO_CF_REASON[MMI_SC_CF_ALL_CONDITIONAL] = Ci.nsIMobileConnection.CALL_FORWARD_REASON_ALL_CONDITIONAL_CALL_FORWARDING;
|
|
|
|
|
2015-04-29 10:01:16 +00:00
|
|
|
const MMI_SC_TO_LOCK_TYPE = {};
|
2015-05-05 11:27:23 +00:00
|
|
|
MMI_SC_TO_LOCK_TYPE[MMI_SC_PIN] = Ci.nsIIcc.CARD_LOCK_TYPE_PIN;
|
|
|
|
MMI_SC_TO_LOCK_TYPE[MMI_SC_PIN2] = Ci.nsIIcc.CARD_LOCK_TYPE_PIN2;
|
|
|
|
MMI_SC_TO_LOCK_TYPE[MMI_SC_PUK] = Ci.nsIIcc.CARD_LOCK_TYPE_PUK;
|
|
|
|
MMI_SC_TO_LOCK_TYPE[MMI_SC_PUK2] = Ci.nsIIcc.CARD_LOCK_TYPE_PUK2;
|
2015-04-29 10:01:16 +00:00
|
|
|
|
2015-04-30 04:20:40 +00:00
|
|
|
const MMI_PROC_TO_CLIR_ACTION = {};
|
2015-05-05 11:27:23 +00:00
|
|
|
MMI_PROC_TO_CLIR_ACTION[MMI_PROCEDURE_ACTIVATION] = Ci.nsIMobileConnection.CLIR_INVOCATION;
|
|
|
|
MMI_PROC_TO_CLIR_ACTION[MMI_PROCEDURE_DEACTIVATION] = Ci.nsIMobileConnection.CLIR_SUPPRESSION;
|
2015-04-30 04:20:40 +00:00
|
|
|
|
2015-04-30 10:58:30 +00:00
|
|
|
const MMI_SC_TO_CB_PROGRAM = {};
|
2015-05-05 11:27:23 +00:00
|
|
|
MMI_SC_TO_CB_PROGRAM[MMI_SC_BAOC] = Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_ALL_OUTGOING;
|
|
|
|
MMI_SC_TO_CB_PROGRAM[MMI_SC_BAOIC] = Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL;
|
|
|
|
MMI_SC_TO_CB_PROGRAM[MMI_SC_BAOICxH] = Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL_EXCEPT_HOME;
|
|
|
|
MMI_SC_TO_CB_PROGRAM[MMI_SC_BAIC] = Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_ALL_INCOMING;
|
|
|
|
MMI_SC_TO_CB_PROGRAM[MMI_SC_BAICr] = Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_INCOMING_ROAMING;
|
|
|
|
MMI_SC_TO_CB_PROGRAM[MMI_SC_BA_ALL] = Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_ALL_SERVICE;
|
|
|
|
MMI_SC_TO_CB_PROGRAM[MMI_SC_BA_MO] = Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_OUTGOING_SERVICE;
|
|
|
|
MMI_SC_TO_CB_PROGRAM[MMI_SC_BA_MT] = Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_INCOMING_SERVICE;
|
2015-04-30 10:58:30 +00:00
|
|
|
|
2015-04-29 07:05:06 +00:00
|
|
|
const CF_ACTION_TO_STATUS_MESSAGE = {};
|
2015-05-05 11:27:23 +00:00
|
|
|
CF_ACTION_TO_STATUS_MESSAGE[Ci.nsIMobileConnection.CALL_FORWARD_ACTION_ENABLE] = MMI_SM_KS_SERVICE_ENABLED;
|
|
|
|
CF_ACTION_TO_STATUS_MESSAGE[Ci.nsIMobileConnection.CALL_FORWARD_ACTION_DISABLE] = MMI_SM_KS_SERVICE_DISABLED;
|
|
|
|
CF_ACTION_TO_STATUS_MESSAGE[Ci.nsIMobileConnection.CALL_FORWARD_ACTION_REGISTRATION] = MMI_SM_KS_SERVICE_REGISTERED;
|
|
|
|
CF_ACTION_TO_STATUS_MESSAGE[Ci.nsIMobileConnection.CALL_FORWARD_ACTION_ERASURE] = MMI_SM_KS_SERVICE_ERASED;
|
2015-04-29 07:05:06 +00:00
|
|
|
|
2015-04-29 10:01:16 +00:00
|
|
|
const LOCK_TYPE_TO_STATUS_MESSAGE = {};
|
2015-05-05 11:27:23 +00:00
|
|
|
LOCK_TYPE_TO_STATUS_MESSAGE[Ci.nsIIcc.CARD_LOCK_TYPE_PIN] = MMI_SM_KS_PIN_CHANGED;
|
|
|
|
LOCK_TYPE_TO_STATUS_MESSAGE[Ci.nsIIcc.CARD_LOCK_TYPE_PIN2] = MMI_SM_KS_PIN2_CHANGED;
|
|
|
|
LOCK_TYPE_TO_STATUS_MESSAGE[Ci.nsIIcc.CARD_LOCK_TYPE_PUK] = MMI_SM_KS_PIN_UNBLOCKED;
|
|
|
|
LOCK_TYPE_TO_STATUS_MESSAGE[Ci.nsIIcc.CARD_LOCK_TYPE_PUK2] = MMI_SM_KS_PIN2_UNBLOCKED;
|
2015-04-29 10:01:16 +00:00
|
|
|
|
2015-04-30 04:20:40 +00:00
|
|
|
const CLIR_ACTION_TO_STATUS_MESSAGE = {};
|
2015-05-05 11:27:23 +00:00
|
|
|
CLIR_ACTION_TO_STATUS_MESSAGE[Ci.nsIMobileConnection.CLIR_INVOCATION] = MMI_SM_KS_SERVICE_ENABLED;
|
|
|
|
CLIR_ACTION_TO_STATUS_MESSAGE[Ci.nsIMobileConnection.CLIR_SUPPRESSION] = MMI_SM_KS_SERVICE_DISABLED;
|
|
|
|
|
|
|
|
const MMI_KS_SERVICE_CLASS_MAPPING = {};
|
|
|
|
MMI_KS_SERVICE_CLASS_MAPPING[Ci.nsIMobileConnection.ICC_SERVICE_CLASS_VOICE] = MMI_KS_SERVICE_CLASS_VOICE;
|
|
|
|
MMI_KS_SERVICE_CLASS_MAPPING[Ci.nsIMobileConnection.ICC_SERVICE_CLASS_DATA] = MMI_KS_SERVICE_CLASS_DATA;
|
|
|
|
MMI_KS_SERVICE_CLASS_MAPPING[Ci.nsIMobileConnection.ICC_SERVICE_CLASS_FAX] = MMI_KS_SERVICE_CLASS_FAX;
|
|
|
|
MMI_KS_SERVICE_CLASS_MAPPING[Ci.nsIMobileConnection.ICC_SERVICE_CLASS_SMS] = MMI_KS_SERVICE_CLASS_SMS;
|
|
|
|
MMI_KS_SERVICE_CLASS_MAPPING[Ci.nsIMobileConnection.ICC_SERVICE_CLASS_DATA_SYNC] = MMI_KS_SERVICE_CLASS_DATA_SYNC;
|
|
|
|
MMI_KS_SERVICE_CLASS_MAPPING[Ci.nsIMobileConnection.ICC_SERVICE_CLASS_DATA_ASYNC] = MMI_KS_SERVICE_CLASS_DATA_ASYNC;
|
|
|
|
MMI_KS_SERVICE_CLASS_MAPPING[Ci.nsIMobileConnection.ICC_SERVICE_CLASS_PACKET] = MMI_KS_SERVICE_CLASS_PACKET;
|
|
|
|
MMI_KS_SERVICE_CLASS_MAPPING[Ci.nsIMobileConnection.ICC_SERVICE_CLASS_PAD] = MMI_KS_SERVICE_CLASS_PAD;
|
2015-04-30 04:20:40 +00:00
|
|
|
|
2015-09-15 18:19:45 +00:00
|
|
|
var DEBUG;
|
2013-09-07 06:19:57 +00:00
|
|
|
function debug(s) {
|
2014-06-03 14:15:25 +00:00
|
|
|
dump("TelephonyService: " + s + "\n");
|
2013-09-07 06:19:57 +00:00
|
|
|
}
|
|
|
|
|
2015-03-02 07:21:03 +00:00
|
|
|
/* global gRadioInterfaceLayer */
|
2015-02-26 21:51:20 +00:00
|
|
|
XPCOMUtils.defineLazyGetter(this, "gRadioInterfaceLayer", function() {
|
|
|
|
let ril = { numRadioInterfaces: 0 };
|
|
|
|
try {
|
|
|
|
ril = Cc["@mozilla.org/ril;1"].getService(Ci.nsIRadioInterfaceLayer);
|
|
|
|
} catch(e) {}
|
|
|
|
return ril;
|
|
|
|
});
|
2013-10-31 12:05:51 +00:00
|
|
|
|
2015-03-02 07:21:03 +00:00
|
|
|
/* global gPowerManagerService */
|
2013-09-07 06:19:57 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gPowerManagerService",
|
|
|
|
"@mozilla.org/power/powermanagerservice;1",
|
|
|
|
"nsIPowerManagerService");
|
|
|
|
|
2015-03-02 07:21:03 +00:00
|
|
|
/* global gTelephonyMessenger */
|
2014-10-20 08:50:57 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gTelephonyMessenger",
|
|
|
|
"@mozilla.org/ril/system-messenger-helper;1",
|
|
|
|
"nsITelephonyMessenger");
|
2013-09-07 06:19:57 +00:00
|
|
|
|
2015-03-02 07:21:03 +00:00
|
|
|
/* global gAudioService */
|
2014-11-14 07:20:44 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gAudioService",
|
|
|
|
"@mozilla.org/telephony/audio-service;1",
|
|
|
|
"nsITelephonyAudioService");
|
|
|
|
|
2015-03-02 07:21:03 +00:00
|
|
|
/* global gGonkMobileConnectionService */
|
2014-09-22 05:36:00 +00:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gGonkMobileConnectionService",
|
|
|
|
"@mozilla.org/mobileconnection/mobileconnectionservice;1",
|
|
|
|
"nsIGonkMobileConnectionService");
|
|
|
|
|
2015-04-29 10:01:16 +00:00
|
|
|
/* global gIccService */
|
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gIccService",
|
|
|
|
"@mozilla.org/icc/iccservice;1",
|
|
|
|
"nsIIccService");
|
|
|
|
|
|
|
|
|
2015-05-12 09:41:46 +00:00
|
|
|
/* global PhoneNumberUtils */
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "PhoneNumberUtils",
|
|
|
|
"resource://gre/modules/PhoneNumberUtils.jsm");
|
2013-09-07 06:19:57 +00:00
|
|
|
|
2015-05-12 09:41:46 +00:00
|
|
|
/* global DialNumberUtils */
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "DialNumberUtils",
|
|
|
|
"resource://gre/modules/DialNumberUtils.jsm");
|
2015-01-23 10:34:13 +00:00
|
|
|
|
2015-01-08 08:33:51 +00:00
|
|
|
function TelephonyCallInfo(aCall) {
|
|
|
|
this.clientId = aCall.clientId;
|
|
|
|
this.callIndex = aCall.callIndex;
|
|
|
|
this.callState = aCall.state;
|
2015-05-18 05:03:00 +00:00
|
|
|
this.disconnectedReason = aCall.disconnectedReason || "";
|
|
|
|
|
2015-01-08 08:33:51 +00:00
|
|
|
this.number = aCall.number;
|
|
|
|
this.numberPresentation = aCall.numberPresentation;
|
|
|
|
this.name = aCall.name;
|
|
|
|
this.namePresentation = aCall.namePresentation;
|
2015-05-18 05:03:00 +00:00
|
|
|
|
2015-01-08 08:33:51 +00:00
|
|
|
this.isOutgoing = aCall.isOutgoing;
|
|
|
|
this.isEmergency = aCall.isEmergency;
|
|
|
|
this.isConference = aCall.isConference;
|
|
|
|
this.isSwitchable = aCall.isSwitchable;
|
|
|
|
this.isMergeable = aCall.isMergeable;
|
|
|
|
}
|
|
|
|
TelephonyCallInfo.prototype = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsITelephonyCallInfo]),
|
|
|
|
classID: TELEPHONYCALLINFO_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({
|
|
|
|
classID: TELEPHONYCALLINFO_CID,
|
|
|
|
classDescription: "TelephonyCallInfo",
|
|
|
|
interfaces: [Ci.nsITelephonyCallInfo]
|
|
|
|
}),
|
|
|
|
|
|
|
|
// nsITelephonyCallInfo
|
|
|
|
|
|
|
|
clientId: 0,
|
|
|
|
callIndex: 0,
|
|
|
|
callState: nsITelephonyService.CALL_STATE_UNKNOWN,
|
2015-05-18 05:03:00 +00:00
|
|
|
disconnectedReason: "",
|
|
|
|
|
2015-01-08 08:33:51 +00:00
|
|
|
number: "",
|
|
|
|
numberPresentation: nsITelephonyService.CALL_PRESENTATION_ALLOWED,
|
|
|
|
name: "",
|
|
|
|
namePresentation: nsITelephonyService.CALL_PRESENTATION_ALLOWED,
|
2015-05-18 05:03:00 +00:00
|
|
|
|
2015-01-08 08:33:51 +00:00
|
|
|
isOutgoing: true,
|
|
|
|
isEmergency: false,
|
|
|
|
isConference: false,
|
|
|
|
isSwitchable: true,
|
|
|
|
isMergeable: true
|
|
|
|
};
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
function Call(aClientId, aCallIndex) {
|
|
|
|
this.clientId = aClientId;
|
|
|
|
this.callIndex = aCallIndex;
|
|
|
|
}
|
|
|
|
Call.prototype = {
|
|
|
|
clientId: 0,
|
|
|
|
callIndex: 0,
|
|
|
|
state: nsITelephonyService.CALL_STATE_UNKNOWN,
|
|
|
|
number: "",
|
|
|
|
numberPresentation: nsITelephonyService.CALL_PRESENTATION_ALLOWED,
|
|
|
|
name: "",
|
|
|
|
namePresentation: nsITelephonyService.CALL_PRESENTATION_ALLOWED,
|
|
|
|
isOutgoing: true,
|
|
|
|
isEmergency: false,
|
|
|
|
isConference: false,
|
|
|
|
isSwitchable: true,
|
|
|
|
isMergeable: true,
|
|
|
|
started: null
|
|
|
|
};
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
function MobileConnectionListener() {}
|
|
|
|
MobileConnectionListener.prototype = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionListener]),
|
|
|
|
|
|
|
|
// nsIMobileConnectionListener
|
|
|
|
|
|
|
|
notifyVoiceChanged: function() {},
|
|
|
|
notifyDataChanged: function() {},
|
|
|
|
notifyDataError: function(message) {},
|
|
|
|
notifyCFStateChanged: function(action, reason, number, timeSeconds, serviceClass) {},
|
|
|
|
notifyEmergencyCbModeChanged: function(active, timeoutMs) {},
|
|
|
|
notifyOtaStatusChanged: function(status) {},
|
|
|
|
notifyRadioStateChanged: function() {},
|
|
|
|
notifyClirModeChanged: function(mode) {},
|
|
|
|
notifyLastKnownNetworkChanged: function() {},
|
|
|
|
notifyLastKnownHomeNetworkChanged: function() {},
|
2015-11-10 07:30:48 +00:00
|
|
|
notifyNetworkSelectionModeChanged: function() {},
|
|
|
|
notifyDeviceIdentitiesChanged: function() {}
|
2015-03-24 10:04:49 +00:00
|
|
|
};
|
|
|
|
|
2014-06-03 14:15:25 +00:00
|
|
|
function TelephonyService() {
|
2013-10-31 12:05:51 +00:00
|
|
|
this._numClients = gRadioInterfaceLayer.numRadioInterfaces;
|
2013-09-07 06:19:57 +00:00
|
|
|
this._listeners = [];
|
2014-09-22 05:36:00 +00:00
|
|
|
|
|
|
|
this._isDialing = false;
|
|
|
|
this._cachedDialRequest = null;
|
2014-02-21 09:46:58 +00:00
|
|
|
this._currentCalls = {};
|
2015-03-24 10:04:49 +00:00
|
|
|
this._audioStates = [];
|
2015-04-30 14:45:40 +00:00
|
|
|
this._ussdSessions = [];
|
2014-06-09 06:47:00 +00:00
|
|
|
|
2014-07-17 11:18:28 +00:00
|
|
|
this._cdmaCallWaitingNumber = null;
|
|
|
|
|
2013-09-07 06:19:57 +00:00
|
|
|
this._updateDebugFlag();
|
2013-10-24 08:15:06 +00:00
|
|
|
this.defaultServiceId = this._getDefaultServiceId();
|
2013-09-07 06:19:57 +00:00
|
|
|
|
2013-10-24 08:14:59 +00:00
|
|
|
Services.prefs.addObserver(kPrefRilDebuggingEnabled, this, false);
|
2013-10-24 08:15:06 +00:00
|
|
|
Services.prefs.addObserver(kPrefDefaultServiceId, this, false);
|
2013-10-24 08:14:59 +00:00
|
|
|
|
|
|
|
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
2014-02-21 09:46:58 +00:00
|
|
|
|
|
|
|
for (let i = 0; i < this._numClients; ++i) {
|
2015-03-24 10:04:49 +00:00
|
|
|
this._audioStates[i] = nsITelephonyAudioService.PHONE_STATE_NORMAL;
|
2015-08-28 08:39:57 +00:00
|
|
|
this._ussdSessions[i] = USSD_SESSION_DONE;
|
2015-03-24 10:04:49 +00:00
|
|
|
this._currentCalls[i] = {};
|
2014-02-21 09:46:58 +00:00
|
|
|
this._enumerateCallsForClient(i);
|
|
|
|
}
|
2013-09-07 06:19:57 +00:00
|
|
|
}
|
2014-06-03 14:15:25 +00:00
|
|
|
TelephonyService.prototype = {
|
|
|
|
classID: GONK_TELEPHONYSERVICE_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({classID: GONK_TELEPHONYSERVICE_CID,
|
|
|
|
contractID: GONK_TELEPHONYSERVICE_CONTRACTID,
|
|
|
|
classDescription: "TelephonyService",
|
|
|
|
interfaces: [Ci.nsITelephonyService,
|
|
|
|
Ci.nsIGonkTelephonyService],
|
2013-09-07 06:19:57 +00:00
|
|
|
flags: Ci.nsIClassInfo.SINGLETON}),
|
2014-06-03 14:15:25 +00:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsITelephonyService,
|
|
|
|
Ci.nsIGonkTelephonyService,
|
2013-09-07 06:19:57 +00:00
|
|
|
Ci.nsIObserver]),
|
|
|
|
|
2013-10-28 06:07:28 +00:00
|
|
|
// The following attributes/functions are used for acquiring/releasing the
|
|
|
|
// CPU wake lock when the RIL handles the incoming call. Note that we need
|
|
|
|
// a timer to bound the lock's life cycle to avoid exhausting the battery.
|
2013-09-07 06:19:57 +00:00
|
|
|
_callRingWakeLock: null,
|
|
|
|
_callRingWakeLockTimer: null,
|
2013-10-28 06:07:28 +00:00
|
|
|
|
2015-04-30 14:45:40 +00:00
|
|
|
/**
|
|
|
|
* USSD session flags.
|
|
|
|
* Only one USSD session may exist at a time, and the session is assumed
|
|
|
|
* to exist until:
|
|
|
|
* a) There's a call to cancelUSSD()
|
|
|
|
* b) Receiving a session end unsolicited event.
|
|
|
|
*/
|
|
|
|
_ussdSessions: null,
|
|
|
|
|
2014-01-13 02:44:40 +00:00
|
|
|
_acquireCallRingWakeLock: function() {
|
2013-10-28 06:07:28 +00:00
|
|
|
if (!this._callRingWakeLock) {
|
|
|
|
if (DEBUG) debug("Acquiring a CPU wake lock for handling incoming call.");
|
|
|
|
this._callRingWakeLock = gPowerManagerService.newWakeLock("cpu");
|
|
|
|
}
|
|
|
|
if (!this._callRingWakeLockTimer) {
|
|
|
|
if (DEBUG) debug("Creating a timer for releasing the CPU wake lock.");
|
|
|
|
this._callRingWakeLockTimer =
|
|
|
|
Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
|
|
|
}
|
|
|
|
if (DEBUG) debug("Setting the timer for releasing the CPU wake lock.");
|
|
|
|
this._callRingWakeLockTimer
|
|
|
|
.initWithCallback(this._releaseCallRingWakeLock.bind(this),
|
|
|
|
CALL_WAKELOCK_TIMEOUT, Ci.nsITimer.TYPE_ONE_SHOT);
|
|
|
|
},
|
|
|
|
|
2014-01-13 02:44:40 +00:00
|
|
|
_releaseCallRingWakeLock: function() {
|
2013-10-28 06:07:28 +00:00
|
|
|
if (DEBUG) debug("Releasing the CPU wake lock for handling incoming call.");
|
2013-09-07 06:19:57 +00:00
|
|
|
if (this._callRingWakeLockTimer) {
|
|
|
|
this._callRingWakeLockTimer.cancel();
|
|
|
|
}
|
|
|
|
if (this._callRingWakeLock) {
|
|
|
|
this._callRingWakeLock.unlock();
|
|
|
|
this._callRingWakeLock = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-01-13 02:44:40 +00:00
|
|
|
_getClient: function(aClientId) {
|
2013-10-31 12:05:51 +00:00
|
|
|
return gRadioInterfaceLayer.getRadioInterface(aClientId);
|
|
|
|
},
|
|
|
|
|
2014-08-19 04:23:00 +00:00
|
|
|
_sendToRilWorker: function(aClientId, aType, aMessage, aCallback) {
|
|
|
|
this._getClient(aClientId).sendWorkerMessage(aType, aMessage, aCallback);
|
|
|
|
},
|
|
|
|
|
2015-02-03 04:18:19 +00:00
|
|
|
_isGsmTechGroup: function(aType) {
|
|
|
|
switch (aType) {
|
|
|
|
case null: // Handle unknown as gsm.
|
|
|
|
case "gsm":
|
|
|
|
case "gprs":
|
|
|
|
case "edge":
|
|
|
|
case "umts":
|
|
|
|
case "hsdpa":
|
|
|
|
case "hsupa":
|
|
|
|
case "hspa":
|
|
|
|
case "hspa+":
|
|
|
|
case "lte":
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_isCdmaClient: function(aClientId) {
|
|
|
|
let type = gGonkMobileConnectionService.getItemByServiceId(aClientId).voice.type;
|
|
|
|
return !this._isGsmTechGroup(type);
|
|
|
|
},
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
_isEmergencyOnly: function(aClientId) {
|
|
|
|
return gGonkMobileConnectionService.getItemByServiceId(aClientId).voice.emergencyCallsOnly;
|
|
|
|
},
|
|
|
|
|
|
|
|
_isRadioOn: function(aClientId) {
|
2015-03-24 10:04:49 +00:00
|
|
|
let connection = gGonkMobileConnectionService.getItemByServiceId(aClientId);
|
|
|
|
return connection.radioState === nsIMobileConnection.MOBILE_RADIO_STATE_ENABLED;
|
2015-02-03 04:18:20 +00:00
|
|
|
},
|
|
|
|
|
2013-09-07 06:19:57 +00:00
|
|
|
// An array of nsITelephonyListener instances.
|
|
|
|
_listeners: null,
|
2014-01-13 02:44:40 +00:00
|
|
|
_notifyAllListeners: function(aMethodName, aArgs) {
|
2013-09-07 06:19:57 +00:00
|
|
|
let listeners = this._listeners.slice();
|
|
|
|
for (let listener of listeners) {
|
|
|
|
if (this._listeners.indexOf(listener) == -1) {
|
|
|
|
// Listener has been unregistered in previous run.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
let handler = listener[aMethodName];
|
|
|
|
try {
|
|
|
|
handler.apply(listener, aArgs);
|
|
|
|
} catch (e) {
|
|
|
|
debug("listener for " + aMethodName + " threw an exception: " + e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
_computeAudioStateForClient: function(aClientId) {
|
|
|
|
let indexes = Object.keys(this._currentCalls[aClientId]);
|
|
|
|
if (!indexes.length) {
|
|
|
|
return nsITelephonyAudioService.PHONE_STATE_NORMAL;
|
2014-06-09 06:47:00 +00:00
|
|
|
}
|
2015-03-24 10:04:49 +00:00
|
|
|
|
|
|
|
let firstCall = this._currentCalls[aClientId][indexes[0]];
|
|
|
|
if (indexes.length === 1 &&
|
|
|
|
firstCall.state === nsITelephonyService.CALL_STATE_INCOMING) {
|
|
|
|
return nsITelephonyAudioService.PHONE_STATE_RINGTONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsITelephonyAudioService.PHONE_STATE_IN_CALL;
|
|
|
|
},
|
|
|
|
|
|
|
|
_updateAudioState: function(aClientId) {
|
|
|
|
this._audioStates[aClientId] = this._computeAudioStateForClient(aClientId);
|
|
|
|
|
|
|
|
if (this._audioStates.some(state => state === nsITelephonyAudioService.PHONE_STATE_IN_CALL)) {
|
|
|
|
gAudioService.setPhoneState(nsITelephonyAudioService.PHONE_STATE_IN_CALL);
|
|
|
|
} else if (this._audioStates.some(state => state === nsITelephonyAudioService.PHONE_STATE_RINGTONE)) {
|
|
|
|
gAudioService.setPhoneState(nsITelephonyAudioService.PHONE_STATE_RINGTONE);
|
|
|
|
} else {
|
|
|
|
gAudioService.setPhoneState(nsITelephonyAudioService.PHONE_STATE_NORMAL);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_formatInternationalNumber: function(aNumber, aToa) {
|
|
|
|
if (aNumber && aToa == RIL.TOA_INTERNATIONAL && aNumber[0] != "+") {
|
|
|
|
return "+" + aNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aNumber;
|
2014-05-06 01:01:00 +00:00
|
|
|
},
|
|
|
|
|
2014-01-13 02:44:40 +00:00
|
|
|
_convertRILCallState: function(aState) {
|
2013-09-07 06:19:57 +00:00
|
|
|
switch (aState) {
|
2013-09-12 13:00:18 +00:00
|
|
|
case RIL.CALL_STATE_UNKNOWN:
|
2014-06-03 14:15:25 +00:00
|
|
|
return nsITelephonyService.CALL_STATE_UNKNOWN;
|
2013-09-07 06:19:57 +00:00
|
|
|
case RIL.CALL_STATE_ACTIVE:
|
2014-06-03 14:15:25 +00:00
|
|
|
return nsITelephonyService.CALL_STATE_CONNECTED;
|
2013-09-07 06:19:57 +00:00
|
|
|
case RIL.CALL_STATE_HOLDING:
|
2014-06-03 14:15:25 +00:00
|
|
|
return nsITelephonyService.CALL_STATE_HELD;
|
2013-09-07 06:19:57 +00:00
|
|
|
case RIL.CALL_STATE_DIALING:
|
2014-06-03 14:15:25 +00:00
|
|
|
return nsITelephonyService.CALL_STATE_DIALING;
|
2013-09-07 06:19:57 +00:00
|
|
|
case RIL.CALL_STATE_ALERTING:
|
2014-06-03 14:15:25 +00:00
|
|
|
return nsITelephonyService.CALL_STATE_ALERTING;
|
2013-09-07 06:19:57 +00:00
|
|
|
case RIL.CALL_STATE_INCOMING:
|
|
|
|
case RIL.CALL_STATE_WAITING:
|
2014-06-03 14:15:25 +00:00
|
|
|
return nsITelephonyService.CALL_STATE_INCOMING;
|
2013-09-07 06:19:57 +00:00
|
|
|
default:
|
|
|
|
throw new Error("Unknown rilCallState: " + aState);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-01-13 02:44:40 +00:00
|
|
|
_convertRILSuppSvcNotification: function(aNotification) {
|
2013-09-07 06:19:57 +00:00
|
|
|
switch (aNotification) {
|
|
|
|
case RIL.GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD:
|
2014-06-03 14:15:25 +00:00
|
|
|
return nsITelephonyService.NOTIFICATION_REMOTE_HELD;
|
2013-09-07 06:19:57 +00:00
|
|
|
case RIL.GECKO_SUPP_SVC_NOTIFICATION_REMOTE_RESUMED:
|
2014-06-03 14:15:25 +00:00
|
|
|
return nsITelephonyService.NOTIFICATION_REMOTE_RESUMED;
|
2013-09-07 06:19:57 +00:00
|
|
|
default:
|
2014-02-06 10:58:46 +00:00
|
|
|
if (DEBUG) {
|
|
|
|
debug("Unknown rilSuppSvcNotification: " + aNotification);
|
|
|
|
}
|
|
|
|
return;
|
2013-09-07 06:19:57 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-01-13 02:44:40 +00:00
|
|
|
_updateDebugFlag: function() {
|
2013-09-07 06:19:57 +00:00
|
|
|
try {
|
|
|
|
DEBUG = RIL.DEBUG_RIL ||
|
2013-10-24 08:14:59 +00:00
|
|
|
Services.prefs.getBoolPref(kPrefRilDebuggingEnabled);
|
2013-09-07 06:19:57 +00:00
|
|
|
} catch (e) {}
|
|
|
|
},
|
|
|
|
|
2014-01-13 02:44:40 +00:00
|
|
|
_getDefaultServiceId: function() {
|
2013-10-24 08:15:06 +00:00
|
|
|
let id = Services.prefs.getIntPref(kPrefDefaultServiceId);
|
|
|
|
let numRil = Services.prefs.getIntPref(kPrefRilNumRadioInterfaces);
|
|
|
|
|
|
|
|
if (id >= numRil || id < 0) {
|
|
|
|
id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return id;
|
|
|
|
},
|
|
|
|
|
2014-02-21 09:46:58 +00:00
|
|
|
_currentCalls: null,
|
|
|
|
_enumerateCallsForClient: function(aClientId) {
|
|
|
|
if (DEBUG) debug("Enumeration of calls for client " + aClientId);
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
this._sendToRilWorker(aClientId, "getCurrentCalls", null, response => {
|
|
|
|
if (response.errorMsg) {
|
|
|
|
return;
|
2014-02-21 09:46:58 +00:00
|
|
|
}
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
// Clear all.
|
|
|
|
this._currentCalls[aClientId] = {};
|
|
|
|
|
|
|
|
for (let i in response.calls) {
|
|
|
|
let call = this._currentCalls[aClientId][i] = new Call(aClientId, i);
|
|
|
|
this._updateCallFromRil(call, response.calls[i]);
|
2014-02-21 09:46:58 +00:00
|
|
|
}
|
2014-08-19 04:23:00 +00:00
|
|
|
});
|
2014-02-21 09:46:58 +00:00
|
|
|
},
|
|
|
|
|
2014-08-19 04:24:00 +00:00
|
|
|
/**
|
|
|
|
* Checks whether to temporarily suppress caller id for the call.
|
|
|
|
*
|
|
|
|
* @param aMmi
|
|
|
|
* MMI full object.
|
|
|
|
*/
|
|
|
|
_isTemporaryCLIR: function(aMmi) {
|
2015-05-05 11:27:23 +00:00
|
|
|
return (aMmi && aMmi.serviceCode === MMI_SC_CLIR) && aMmi.dialNumber;
|
2014-08-19 04:24:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Map MMI procedure to CLIR MODE.
|
|
|
|
*
|
|
|
|
* @param aProcedure
|
|
|
|
* MMI procedure
|
|
|
|
*/
|
2015-02-03 04:18:20 +00:00
|
|
|
_procedureToCLIRMode: function(aProcedure) {
|
2014-08-19 04:24:00 +00:00
|
|
|
// In temporary mode, MMI_PROCEDURE_ACTIVATION means allowing CLI
|
|
|
|
// presentation, i.e. CLIR_SUPPRESSION. See TS 22.030, Annex B.
|
|
|
|
switch (aProcedure) {
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_PROCEDURE_ACTIVATION:
|
2015-04-30 04:20:40 +00:00
|
|
|
return Ci.nsIMobileConnection.CLIR_SUPPRESSION;
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_PROCEDURE_DEACTIVATION:
|
2015-04-30 04:20:40 +00:00
|
|
|
return Ci.nsIMobileConnection.CLIR_INVOCATION;
|
2014-08-19 04:24:00 +00:00
|
|
|
default:
|
2015-04-30 04:20:40 +00:00
|
|
|
return Ci.nsIMobileConnection.CLIR_DEFAULT;
|
2014-08-19 04:24:00 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-09-07 06:19:57 +00:00
|
|
|
/**
|
2014-06-03 14:15:25 +00:00
|
|
|
* nsITelephonyService interface.
|
2013-09-07 06:19:57 +00:00
|
|
|
*/
|
|
|
|
|
2013-10-24 08:15:06 +00:00
|
|
|
defaultServiceId: 0,
|
|
|
|
|
2013-09-07 06:19:57 +00:00
|
|
|
registerListener: function(aListener) {
|
|
|
|
if (this._listeners.indexOf(aListener) >= 0) {
|
|
|
|
throw Cr.NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._listeners.push(aListener);
|
|
|
|
},
|
|
|
|
|
|
|
|
unregisterListener: function(aListener) {
|
|
|
|
let index = this._listeners.indexOf(aListener);
|
|
|
|
if (index < 0) {
|
|
|
|
throw Cr.NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._listeners.splice(index, 1);
|
|
|
|
},
|
|
|
|
|
2014-02-21 09:46:58 +00:00
|
|
|
enumerateCalls: function(aListener) {
|
|
|
|
if (DEBUG) debug("Requesting enumeration of calls for callback");
|
2013-09-07 06:19:57 +00:00
|
|
|
|
2014-02-21 09:46:58 +00:00
|
|
|
for (let cid = 0; cid < this._numClients; ++cid) {
|
|
|
|
let calls = this._currentCalls[cid];
|
|
|
|
if (!calls) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
for (let i = 0, indexes = Object.keys(calls); i < indexes.length; ++i) {
|
|
|
|
let call = calls[indexes[i]];
|
2015-01-08 08:33:51 +00:00
|
|
|
let callInfo = new TelephonyCallInfo(call);
|
|
|
|
aListener.enumerateCallState(callInfo);
|
2013-09-07 06:19:57 +00:00
|
|
|
}
|
2013-10-31 12:05:51 +00:00
|
|
|
}
|
2014-02-21 09:46:58 +00:00
|
|
|
aListener.enumerateCallStateComplete();
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2014-09-22 05:36:00 +00:00
|
|
|
_hasCalls: function(aClientId) {
|
|
|
|
return Object.keys(this._currentCalls[aClientId]).length !== 0;
|
|
|
|
},
|
|
|
|
|
2014-07-02 07:47:00 +00:00
|
|
|
_hasCallsOnOtherClient: function(aClientId) {
|
|
|
|
for (let cid = 0; cid < this._numClients; ++cid) {
|
2014-09-22 05:36:00 +00:00
|
|
|
if (cid !== aClientId && this._hasCalls(cid)) {
|
2014-07-02 07:47:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
// All calls in the conference is regarded as one conference call.
|
|
|
|
_numCallsOnLine: function(aClientId) {
|
|
|
|
let numCalls = 0;
|
|
|
|
let hasConference = false;
|
|
|
|
|
|
|
|
for (let cid in this._currentCalls[aClientId]) {
|
|
|
|
let call = this._currentCalls[aClientId][cid];
|
|
|
|
if (call.isConference) {
|
|
|
|
hasConference = true;
|
|
|
|
} else {
|
|
|
|
numCalls++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hasConference ? numCalls + 1 : numCalls;
|
|
|
|
},
|
|
|
|
|
2014-08-22 07:26:00 +00:00
|
|
|
/**
|
2015-03-24 10:04:49 +00:00
|
|
|
* Is there an active call?
|
2014-08-22 07:26:00 +00:00
|
|
|
*/
|
2015-03-24 10:04:49 +00:00
|
|
|
_isActive: function(aClientId) {
|
2014-08-22 07:26:00 +00:00
|
|
|
for (let index in this._currentCalls[aClientId]) {
|
|
|
|
let call = this._currentCalls[aClientId][index];
|
|
|
|
if (call.state === nsITelephonyService.CALL_STATE_CONNECTED) {
|
2015-03-24 10:04:49 +00:00
|
|
|
return true;
|
2014-08-22 07:26:00 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-24 10:04:49 +00:00
|
|
|
return false;
|
2014-08-22 07:26:00 +00:00
|
|
|
},
|
|
|
|
|
2015-10-24 11:57:20 +00:00
|
|
|
/**
|
|
|
|
* Select a proper client for dialing emergency call.
|
|
|
|
*
|
|
|
|
* @return clientId
|
|
|
|
*/
|
|
|
|
_getClientIdForEmergencyCall: function() {
|
|
|
|
// Select the client with sim card first.
|
|
|
|
for (let cid = 0; cid < this._numClients; ++cid) {
|
|
|
|
let icc = gIccService.getIccByServiceId(cid);
|
|
|
|
let cardState = icc ? icc.cardState : Ci.nsIIcc.CARD_STATE_UNKONWN;
|
|
|
|
if (cardState !== Ci.nsIIcc.CARD_STATE_UNDETECTED &&
|
|
|
|
cardState !== Ci.nsIIcc.CARD_STATE_UNKNOWN) {
|
|
|
|
return cid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use the defualt client if no card presents.
|
|
|
|
return EMERGENCY_CALL_DEFAULT_CLIENT_ID;
|
|
|
|
},
|
|
|
|
|
2015-03-02 06:46:43 +00:00
|
|
|
/**
|
|
|
|
* Dial number. Perform call setup or SS procedure accordingly.
|
|
|
|
*
|
|
|
|
* @see 3GPP TS 22.030 Figure 3.5.3.2
|
|
|
|
*/
|
2014-08-11 06:48:00 +00:00
|
|
|
dial: function(aClientId, aNumber, aIsDialEmergency, aCallback) {
|
2015-03-26 03:11:12 +00:00
|
|
|
if (DEBUG) debug("Dialing " + (aIsDialEmergency ? "emergency " : "")
|
|
|
|
+ aNumber + ", clientId: " + aClientId);
|
2014-02-12 06:31:13 +00:00
|
|
|
|
2014-09-22 05:36:00 +00:00
|
|
|
// We don't try to be too clever here, as the phone is probably in the
|
|
|
|
// locked state. Let's just check if it's a number without normalizing
|
|
|
|
if (!aIsDialEmergency) {
|
2015-05-12 09:41:46 +00:00
|
|
|
aNumber = PhoneNumberUtils.normalize(aNumber);
|
2014-09-22 05:36:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Validate the number.
|
|
|
|
// Note: isPlainPhoneNumber also accepts USSD and SS numbers
|
2015-05-12 09:41:46 +00:00
|
|
|
if (!PhoneNumberUtils.isPlainPhoneNumber(aNumber)) {
|
2014-09-22 05:36:00 +00:00
|
|
|
if (DEBUG) debug("Error: Number '" + aNumber + "' is not viable. Drop.");
|
2014-10-15 06:50:00 +00:00
|
|
|
aCallback.notifyError(DIAL_ERROR_BAD_NUMBER);
|
2014-09-22 05:36:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-12 09:41:46 +00:00
|
|
|
let isEmergencyNumber = DialNumberUtils.isEmergency(aNumber);
|
2015-02-03 04:18:20 +00:00
|
|
|
|
2015-02-06 06:56:43 +00:00
|
|
|
// DialEmergency accepts only emergency number.
|
|
|
|
if (aIsDialEmergency && !isEmergencyNumber) {
|
2015-03-02 06:46:43 +00:00
|
|
|
if (!this._isRadioOn(aClientId)) {
|
|
|
|
if (DEBUG) debug("Error: Radio is off. Drop.");
|
|
|
|
aCallback.notifyError(DIAL_ERROR_RADIO_NOT_AVAILABLE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DEBUG) debug("Error: Dial a non-emergency by dialEmergency. Drop.");
|
2015-02-03 04:18:20 +00:00
|
|
|
aCallback.notifyError(DIAL_ERROR_BAD_NUMBER);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-02 06:46:43 +00:00
|
|
|
if (isEmergencyNumber) {
|
2015-02-03 04:18:20 +00:00
|
|
|
this._dialCall(aClientId, aNumber, undefined, aCallback);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-02 06:46:43 +00:00
|
|
|
// In cdma, we should always handle the request as a call.
|
|
|
|
if (this._isCdmaClient(aClientId)) {
|
|
|
|
this._dialCall(aClientId, aNumber, undefined, aCallback);
|
2015-02-03 04:18:20 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-12-11 08:27:45 +00:00
|
|
|
|
2015-05-12 09:41:46 +00:00
|
|
|
let mmi = DialNumberUtils.parseMMI(aNumber);
|
2015-03-02 06:46:43 +00:00
|
|
|
if (mmi) {
|
|
|
|
if (this._isTemporaryCLIR(mmi)) {
|
|
|
|
this._dialCall(aClientId, mmi.dialNumber,
|
|
|
|
this._procedureToCLIRMode(mmi.procedure), aCallback);
|
|
|
|
} else {
|
|
|
|
this._dialMMI(aClientId, mmi, aCallback);
|
|
|
|
}
|
2014-12-11 08:27:45 +00:00
|
|
|
} else {
|
2015-03-02 06:46:43 +00:00
|
|
|
if (aNumber[aNumber.length - 1] === "#") { // # string
|
|
|
|
this._dialMMI(aClientId, {fullMMI: aNumber}, aCallback);
|
|
|
|
} else if (aNumber.length <= 2) { // short string
|
|
|
|
if (this._hasCalls(aClientId)) {
|
|
|
|
this._dialInCallMMI(aClientId, aNumber, aCallback);
|
|
|
|
} else if (aNumber.length === 2 && aNumber[0] === "1") {
|
|
|
|
this._dialCall(aClientId, aNumber, undefined, aCallback);
|
|
|
|
} else {
|
|
|
|
this._dialMMI(aClientId, {fullMMI: aNumber}, aCallback);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this._dialCall(aClientId, aNumber, undefined, aCallback);
|
|
|
|
}
|
2015-02-03 04:18:20 +00:00
|
|
|
}
|
|
|
|
},
|
2014-12-10 12:34:11 +00:00
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
// Handling of supplementary services within a call as 3GPP TS 22.030 6.5.5
|
|
|
|
_dialInCallMMI: function(aClientId, aNumber, aCallback) {
|
2015-03-24 10:04:49 +00:00
|
|
|
let mmiCallback = {
|
2015-05-05 11:27:23 +00:00
|
|
|
notifyError: () => aCallback.notifyDialMMIError(MMI_ERROR_KS_ERROR),
|
|
|
|
notifySuccess: () => aCallback.notifyDialMMISuccess(MMI_SM_KS_CALL_CONTROL)
|
2015-02-03 04:18:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (aNumber === "0") {
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMI(MMI_KS_SC_CALL);
|
2015-03-24 10:04:49 +00:00
|
|
|
this._hangUpBackground(aClientId, mmiCallback);
|
2015-02-03 04:18:20 +00:00
|
|
|
} else if (aNumber === "1") {
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMI(MMI_KS_SC_CALL);
|
2015-03-24 10:04:49 +00:00
|
|
|
this._hangUpForeground(aClientId, mmiCallback);
|
2015-02-03 04:18:20 +00:00
|
|
|
} else if (aNumber[0] === "1" && aNumber.length === 2) {
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMI(MMI_KS_SC_CALL);
|
2015-03-24 10:04:49 +00:00
|
|
|
this.hangUpCall(aClientId, parseInt(aNumber[1]), mmiCallback);
|
2015-02-03 04:18:20 +00:00
|
|
|
} else if (aNumber === "2") {
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMI(MMI_KS_SC_CALL);
|
2015-03-24 10:04:49 +00:00
|
|
|
this._switchActiveCall(aClientId, mmiCallback);
|
2015-02-03 04:18:20 +00:00
|
|
|
} else if (aNumber[0] === "2" && aNumber.length === 2) {
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMI(MMI_KS_SC_CALL);
|
2015-03-24 10:04:49 +00:00
|
|
|
this._separateCallGsm(aClientId, parseInt(aNumber[1]), mmiCallback);
|
2015-02-03 04:18:20 +00:00
|
|
|
} else if (aNumber === "3") {
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMI(MMI_KS_SC_CALL);
|
2015-03-24 10:04:49 +00:00
|
|
|
this._conferenceCallGsm(aClientId, mmiCallback);
|
2015-02-03 04:18:20 +00:00
|
|
|
} else {
|
|
|
|
this._dialCall(aClientId, aNumber, undefined, aCallback);
|
2014-09-22 05:36:00 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
_dialCall: function(aClientId, aNumber, aClirMode = RIL.CLIR_DEFAULT,
|
|
|
|
aCallback) {
|
2014-09-22 05:36:00 +00:00
|
|
|
if (this._isDialing) {
|
2014-07-02 07:47:00 +00:00
|
|
|
if (DEBUG) debug("Error: Already has a dialing call.");
|
2014-10-15 06:50:00 +00:00
|
|
|
aCallback.notifyError(DIAL_ERROR_INVALID_STATE_ERROR);
|
2014-04-01 12:58:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-14 07:55:00 +00:00
|
|
|
// We can only have at most two calls on the same line (client).
|
|
|
|
if (this._numCallsOnLine(aClientId) >= 2) {
|
|
|
|
if (DEBUG) debug("Error: Already has more than 2 calls on line.");
|
2014-10-15 06:50:00 +00:00
|
|
|
aCallback.notifyError(DIAL_ERROR_INVALID_STATE_ERROR);
|
2014-08-14 07:55:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-04-16 14:26:50 +00:00
|
|
|
// For DSDS, if there is aleady a call on SIM 'aClientId', we cannot place
|
|
|
|
// any new call on other SIM.
|
2014-07-02 07:47:00 +00:00
|
|
|
if (this._hasCallsOnOtherClient(aClientId)) {
|
|
|
|
if (DEBUG) debug("Error: Already has a call on other sim.");
|
2014-10-15 06:50:00 +00:00
|
|
|
aCallback.notifyError(DIAL_ERROR_OTHER_CONNECTION_IN_USE);
|
2014-02-27 06:12:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-12 09:41:46 +00:00
|
|
|
let isEmergency = DialNumberUtils.isEmergency(aNumber);
|
2015-03-02 06:46:43 +00:00
|
|
|
|
|
|
|
if (!isEmergency) {
|
|
|
|
if (!this._isRadioOn(aClientId)) {
|
|
|
|
if (DEBUG) debug("Error: Dial a normal call when radio off. Drop");
|
|
|
|
aCallback.notifyError(DIAL_ERROR_RADIO_NOT_AVAILABLE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-26 03:11:12 +00:00
|
|
|
if (this._isEmergencyOnly(aClientId)) {
|
2015-03-02 06:46:43 +00:00
|
|
|
if (DEBUG) debug("Error: Dial a normal call when emergencyCallsOnly. Drop");
|
|
|
|
aCallback.notifyError(DIAL_ERROR_BAD_NUMBER);
|
|
|
|
return;
|
|
|
|
}
|
2015-02-06 06:56:43 +00:00
|
|
|
}
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
if (isEmergency) {
|
2014-09-22 05:36:00 +00:00
|
|
|
// Automatically select a proper clientId for emergency call.
|
2015-10-24 11:57:20 +00:00
|
|
|
aClientId = this._getClientIdForEmergencyCall() ;
|
2014-09-22 05:36:00 +00:00
|
|
|
if (aClientId === -1) {
|
|
|
|
if (DEBUG) debug("Error: No client is avaialble for emergency call.");
|
2014-10-15 06:50:00 +00:00
|
|
|
aCallback.notifyError(DIAL_ERROR_INVALID_STATE_ERROR);
|
2014-09-22 05:36:00 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-03-24 10:04:49 +00:00
|
|
|
|
|
|
|
// Radio is off. Turn it on first.
|
|
|
|
if (!this._isRadioOn(aClientId)) {
|
|
|
|
let connection = gGonkMobileConnectionService.getItemByServiceId(aClientId);
|
|
|
|
let listener = new MobileConnectionListener();
|
|
|
|
|
|
|
|
listener.notifyRadioStateChanged = () => {
|
|
|
|
if (this._isRadioOn(aClientId)) {
|
|
|
|
this._dialCall(aClientId, aNumber, undefined, aCallback);
|
|
|
|
connection.unregisterListener(listener);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
connection.registerListener(listener);
|
|
|
|
|
|
|
|
// Turn on radio.
|
|
|
|
connection.setRadioEnabled(true, {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionCallback]),
|
|
|
|
notifySuccess: () => {},
|
|
|
|
notifyError: aErrorMsg => {
|
|
|
|
connection.unregisterListener(listener);
|
|
|
|
aCallback.notifyError(DIAL_ERROR_RADIO_NOT_AVAILABLE);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2013-09-07 06:19:57 +00:00
|
|
|
}
|
2014-02-12 06:31:13 +00:00
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
let options = {
|
|
|
|
isEmergency: isEmergency,
|
|
|
|
number: aNumber,
|
|
|
|
clirMode: aClirMode
|
|
|
|
};
|
|
|
|
|
|
|
|
// No active call. Dial it out directly.
|
2015-03-24 10:04:49 +00:00
|
|
|
if (!this._isActive(aClientId)) {
|
2015-02-03 04:18:20 +00:00
|
|
|
this._sendDialCallRequest(aClientId, options, aCallback);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CDMA 3-way calling.
|
|
|
|
if (this._isCdmaClient(aClientId)) {
|
|
|
|
this._dialCdmaThreeWayCall(aClientId, aNumber, aCallback);
|
2015-01-20 02:32:00 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-08-19 04:24:00 +00:00
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
// GSM. Hold the active call before dialing.
|
2015-01-20 02:32:00 +00:00
|
|
|
if (DEBUG) debug("There is an active call. Hold it first before dial.");
|
2014-02-21 09:46:58 +00:00
|
|
|
|
2015-01-20 02:32:00 +00:00
|
|
|
if (this._cachedDialRequest) {
|
|
|
|
if (DEBUG) debug("Error: There already is a pending dial request.");
|
|
|
|
aCallback.notifyError(DIAL_ERROR_INVALID_STATE_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
this._switchActiveCall(aClientId, {
|
2015-01-20 02:32:00 +00:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsITelephonyCallback]),
|
|
|
|
|
|
|
|
notifySuccess: () => {
|
|
|
|
this._cachedDialRequest = {
|
|
|
|
clientId: aClientId,
|
2015-02-03 04:18:20 +00:00
|
|
|
options: options,
|
2015-01-20 02:32:00 +00:00
|
|
|
callback: aCallback
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
notifyError: (aErrorMsg) => {
|
|
|
|
if (DEBUG) debug("Error: Fail to automatically hold the active call.");
|
|
|
|
aCallback.notifyError(aErrorMsg);
|
2014-08-22 07:26:00 +00:00
|
|
|
}
|
2015-03-24 10:04:49 +00:00
|
|
|
});
|
2014-08-19 04:24:00 +00:00
|
|
|
},
|
2014-08-14 07:55:00 +00:00
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
_dialCdmaThreeWayCall: function(aClientId, aNumber, aCallback) {
|
|
|
|
this._sendToRilWorker(aClientId, "cdmaFlash", { featureStr: aNumber },
|
|
|
|
response => {
|
2014-05-12 10:29:53 +00:00
|
|
|
if (response.errorMsg) {
|
2015-02-03 04:18:20 +00:00
|
|
|
aCallback.notifyError(response.errorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// RIL doesn't hold the 2nd call. We create one by ourselves.
|
|
|
|
aCallback.notifyDialCallSuccess(aClientId, CDMA_SECOND_CALL_INDEX,
|
|
|
|
aNumber);
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
let childCall = this._currentCalls[aClientId][CDMA_SECOND_CALL_INDEX] =
|
|
|
|
new Call(aClientId, CDMA_SECOND_CALL_INDEX);
|
|
|
|
|
|
|
|
childCall.parentId = CDMA_FIRST_CALL_INDEX;
|
|
|
|
childCall.state = nsITelephonyService.CALL_STATE_DIALING;
|
|
|
|
childCall.number = aNumber;
|
|
|
|
childCall.isOutgoing = true;
|
2015-05-12 09:41:46 +00:00
|
|
|
childCall.isEmergency = DialNumberUtils.isEmergency(aNumber);
|
2015-03-24 10:04:49 +00:00
|
|
|
childCall.isConference = false;
|
|
|
|
childCall.isSwitchable = false;
|
|
|
|
childCall.isMergeable = true;
|
2015-02-03 04:18:20 +00:00
|
|
|
|
|
|
|
// Manual update call state according to the request response.
|
2015-04-24 10:10:37 +00:00
|
|
|
this._handleCallStateChanged(aClientId, [childCall]);
|
2015-02-03 04:18:20 +00:00
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
childCall.state = nsITelephonyService.CALL_STATE_CONNECTED;
|
2015-02-03 04:18:20 +00:00
|
|
|
|
|
|
|
let parentCall = this._currentCalls[aClientId][childCall.parentId];
|
|
|
|
parentCall.childId = CDMA_SECOND_CALL_INDEX;
|
2015-03-24 10:04:49 +00:00
|
|
|
parentCall.state = nsITelephonyService.CALL_STATE_HELD;
|
2015-02-03 04:18:20 +00:00
|
|
|
parentCall.isSwitchable = false;
|
|
|
|
parentCall.isMergeable = true;
|
2015-04-24 10:10:37 +00:00
|
|
|
this._handleCallStateChanged(aClientId, [childCall, parentCall]);
|
2015-02-03 04:18:20 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-09-22 05:36:00 +00:00
|
|
|
_sendDialCallRequest: function(aClientId, aOptions, aCallback) {
|
|
|
|
this._isDialing = true;
|
2014-08-14 07:55:00 +00:00
|
|
|
|
2014-08-19 04:24:00 +00:00
|
|
|
this._sendToRilWorker(aClientId, "dial", aOptions, response => {
|
2014-09-22 05:36:00 +00:00
|
|
|
this._isDialing = false;
|
2014-08-19 04:23:00 +00:00
|
|
|
|
2014-05-12 10:29:53 +00:00
|
|
|
if (response.errorMsg) {
|
2015-03-24 10:04:49 +00:00
|
|
|
this._sendToRilWorker(aClientId, "getFailCause", null, response => {
|
|
|
|
aCallback.notifyError(response.failCause);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this._ongoingDial = {
|
|
|
|
clientId: aClientId,
|
|
|
|
callback: aCallback
|
|
|
|
};
|
2014-02-21 09:46:58 +00:00
|
|
|
}
|
2014-08-19 04:23:00 +00:00
|
|
|
});
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2014-09-22 05:36:00 +00:00
|
|
|
/**
|
2014-10-15 06:51:00 +00:00
|
|
|
* @param aClientId
|
|
|
|
* Client id.
|
2014-09-22 05:36:00 +00:00
|
|
|
* @param aMmi
|
|
|
|
* Parsed MMI structure.
|
2014-10-15 06:51:00 +00:00
|
|
|
* @param aCallback
|
|
|
|
* A nsITelephonyDialCallback object.
|
2014-09-22 05:36:00 +00:00
|
|
|
*/
|
2014-12-21 16:35:00 +00:00
|
|
|
_dialMMI: function(aClientId, aMmi, aCallback) {
|
2014-09-22 05:36:00 +00:00
|
|
|
let mmiServiceCode = aMmi ?
|
2015-05-05 11:27:23 +00:00
|
|
|
this._serviceCodeToKeyString(aMmi.serviceCode) : MMI_KS_SC_USSD;
|
2014-09-22 05:36:00 +00:00
|
|
|
|
|
|
|
aCallback.notifyDialMMI(mmiServiceCode);
|
|
|
|
|
2015-11-11 05:10:51 +00:00
|
|
|
if (mmiServiceCode !== MMI_KS_SC_IMEI && !this._isRadioOn(aClientId)) {
|
2015-07-10 07:27:38 +00:00
|
|
|
aCallback.notifyDialMMIError(DIAL_ERROR_RADIO_NOT_AVAILABLE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-04-29 07:05:06 +00:00
|
|
|
// We check if the MMI service code is supported and in that case we
|
|
|
|
// trigger the appropriate RIL request if possible.
|
|
|
|
switch (mmiServiceCode) {
|
|
|
|
// Call Forwarding
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_KS_SC_CALL_FORWARDING:
|
2015-04-29 07:05:06 +00:00
|
|
|
this._callForwardingMMI(aClientId, aMmi, aCallback);
|
|
|
|
break;
|
|
|
|
|
2015-04-29 10:01:16 +00:00
|
|
|
// Change the current ICC PIN number.
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_KS_SC_PIN:
|
2015-04-29 10:01:16 +00:00
|
|
|
// Change the current ICC PIN2 number.
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_KS_SC_PIN2:
|
2015-04-29 10:01:16 +00:00
|
|
|
this._iccChangeLockMMI(aClientId, aMmi, aCallback);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Unblock ICC PUK.
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_KS_SC_PUK:
|
2015-04-29 10:01:16 +00:00
|
|
|
// Unblock ICC PUN2.
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_KS_SC_PUK2:
|
2015-04-29 10:01:16 +00:00
|
|
|
this._iccUnlockMMI(aClientId, aMmi, aCallback);
|
|
|
|
break;
|
|
|
|
|
2015-04-29 15:44:36 +00:00
|
|
|
// IMEI
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_KS_SC_IMEI:
|
2015-04-29 15:44:36 +00:00
|
|
|
this._getImeiMMI(aClientId, aMmi, aCallback);
|
|
|
|
break;
|
|
|
|
|
2015-04-30 02:53:25 +00:00
|
|
|
// CLIP
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_KS_SC_CLIP:
|
2015-04-30 02:53:25 +00:00
|
|
|
this._clipMMI(aClientId, aMmi, aCallback);
|
|
|
|
break;
|
|
|
|
|
2015-04-30 04:20:40 +00:00
|
|
|
// CLIR (non-temporary ones)
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_KS_SC_CLIR:
|
2015-04-30 04:20:40 +00:00
|
|
|
this._clirMMI(aClientId, aMmi, aCallback);
|
|
|
|
break;
|
|
|
|
|
2015-04-30 04:35:55 +00:00
|
|
|
// Change call barring password
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_KS_SC_CHANGE_PASSWORD:
|
2015-04-30 04:35:55 +00:00
|
|
|
this._callBarringPasswordMMI(aClientId, aMmi, aCallback);
|
|
|
|
break;
|
|
|
|
|
2015-04-30 10:58:30 +00:00
|
|
|
// Call barring
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_KS_SC_CALL_BARRING:
|
2015-04-30 10:58:30 +00:00
|
|
|
this._callBarringMMI(aClientId, aMmi, aCallback);
|
|
|
|
break;
|
|
|
|
|
2015-04-30 11:58:16 +00:00
|
|
|
// Call waiting
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_KS_SC_CALL_WAITING:
|
2015-04-30 11:58:16 +00:00
|
|
|
this._callWaitingMMI(aClientId, aMmi, aCallback);
|
|
|
|
break;
|
|
|
|
|
2015-04-30 14:45:40 +00:00
|
|
|
// Handle unknown MMI code as USSD.
|
2015-04-29 07:05:06 +00:00
|
|
|
default:
|
2015-08-28 08:39:57 +00:00
|
|
|
if (this._ussdSessions[aClientId] == USSD_SESSION_ONGOING) {
|
2015-08-23 17:29:00 +00:00
|
|
|
// Cancel the previous ussd session first.
|
|
|
|
this._cancelUSSDInternal(aClientId, aResponse => {
|
|
|
|
// Fail to cancel ussd session, report error instead of sending ussd
|
|
|
|
// request.
|
|
|
|
if (aResponse.errorMsg) {
|
|
|
|
aCallback.notifyDialMMIError(aResponse.errorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this._sendUSSDInternal(aClientId, aMmi.fullMMI,
|
|
|
|
this._defaultMMICallbackHandler.bind(this, aCallback));
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this._sendUSSDInternal(aClientId, aMmi.fullMMI,
|
|
|
|
this._defaultMMICallbackHandler.bind(this, aCallback));
|
2015-04-30 14:45:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-09-22 05:36:00 +00:00
|
|
|
},
|
|
|
|
|
2015-04-29 07:05:06 +00:00
|
|
|
/**
|
|
|
|
* Handle call forwarding MMI code.
|
|
|
|
*
|
|
|
|
* @param aClientId
|
|
|
|
* Client id.
|
|
|
|
* @param aMmi
|
|
|
|
* Parsed MMI structure.
|
|
|
|
* @param aCallback
|
|
|
|
* A nsITelephonyDialCallback object.
|
|
|
|
*/
|
|
|
|
_callForwardingMMI: function(aClientId, aMmi, aCallback) {
|
|
|
|
let connection = gGonkMobileConnectionService.getItemByServiceId(aClientId);
|
2015-05-05 11:27:23 +00:00
|
|
|
let action = MMI_PROC_TO_CF_ACTION[aMmi.procedure];
|
|
|
|
let reason = MMI_SC_TO_CF_REASON[aMmi.serviceCode];
|
2015-04-29 07:05:06 +00:00
|
|
|
|
|
|
|
if (action === Ci.nsIMobileConnection.CALL_FORWARD_ACTION_QUERY_STATUS) {
|
|
|
|
connection.getCallForwarding(reason, {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionCallback]),
|
|
|
|
notifyGetCallForwardingSuccess: function(aCount, aResults) {
|
|
|
|
aCallback.notifyDialMMISuccessWithCallForwardingOptions(
|
2015-05-05 11:27:23 +00:00
|
|
|
MMI_SM_KS_SERVICE_INTERROGATED, aCount, aResults);
|
2015-04-29 07:05:06 +00:00
|
|
|
},
|
|
|
|
notifyError: function(aErrorMsg) {
|
|
|
|
aCallback.notifyDialMMIError(aErrorMsg);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
let number = aMmi.sia;
|
|
|
|
let serviceClass = this._siToServiceClass(aMmi.sib);
|
|
|
|
let timeSeconds = aMmi.sic;
|
|
|
|
connection.setCallForwarding(action, reason, number, timeSeconds,
|
|
|
|
serviceClass, {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionCallback]),
|
|
|
|
notifySuccess: function() {
|
|
|
|
aCallback.notifyDialMMISuccess(CF_ACTION_TO_STATUS_MESSAGE[action]);
|
|
|
|
},
|
|
|
|
notifyError: function(aErrorMsg) {
|
|
|
|
aCallback.notifyDialMMIError(aErrorMsg);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-04-29 10:01:16 +00:00
|
|
|
/**
|
|
|
|
* Handle icc change lock MMI code.
|
|
|
|
*
|
|
|
|
* @param aClientId
|
|
|
|
* Client id.
|
|
|
|
* @param aMmi
|
|
|
|
* Parsed MMI structure.
|
|
|
|
* @param aCallback
|
|
|
|
* A nsITelephonyDialCallback object.
|
|
|
|
*/
|
|
|
|
_iccChangeLockMMI: function(aClientId, aMmi, aCallback) {
|
|
|
|
let errorMsg = this._getIccLockMMIError(aMmi);
|
|
|
|
if (errorMsg) {
|
|
|
|
aCallback.notifyDialMMIError(errorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let icc = gIccService.getIccByServiceId(aClientId);
|
|
|
|
let lockType = MMI_SC_TO_LOCK_TYPE[aMmi.serviceCode];
|
|
|
|
|
|
|
|
icc.changeCardLockPassword(lockType, aMmi.sia, aMmi.sib, {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIIccCallback]),
|
|
|
|
notifySuccess: function() {
|
|
|
|
aCallback.notifyDialMMISuccess(LOCK_TYPE_TO_STATUS_MESSAGE[lockType]);
|
|
|
|
},
|
|
|
|
notifyCardLockError: function(aErrorMsg, aRetryCount) {
|
|
|
|
if (aRetryCount <= 0) {
|
|
|
|
if (lockType === Ci.nsIIcc.CARD_LOCK_TYPE_PIN) {
|
2015-05-05 11:27:23 +00:00
|
|
|
aErrorMsg = MMI_ERROR_KS_NEEDS_PUK;
|
2015-04-29 10:01:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aCallback.notifyDialMMIError(aErrorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMIErrorWithInfo(MMI_ERROR_KS_BAD_PIN,
|
2015-04-29 10:01:16 +00:00
|
|
|
aRetryCount);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle icc unlock lock MMI code.
|
|
|
|
*
|
|
|
|
* @param aClientId
|
|
|
|
* Client id.
|
|
|
|
* @param aMmi
|
|
|
|
* Parsed MMI structure.
|
|
|
|
* @param aCallback
|
|
|
|
* A nsITelephonyDialCallback object.
|
|
|
|
*/
|
|
|
|
_iccUnlockMMI: function(aClientId, aMmi, aCallback) {
|
|
|
|
let errorMsg = this._getIccLockMMIError(aMmi);
|
|
|
|
if (errorMsg) {
|
|
|
|
aCallback.notifyDialMMIError(errorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let icc = gIccService.getIccByServiceId(aClientId);
|
|
|
|
let lockType = MMI_SC_TO_LOCK_TYPE[aMmi.serviceCode];
|
|
|
|
|
|
|
|
icc.unlockCardLock(lockType, aMmi.sia, aMmi.sib, {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIIccCallback]),
|
|
|
|
notifySuccess: function() {
|
|
|
|
aCallback.notifyDialMMISuccess(LOCK_TYPE_TO_STATUS_MESSAGE[lockType]);
|
|
|
|
},
|
|
|
|
notifyCardLockError: function(aErrorMsg, aRetryCount) {
|
|
|
|
if (aRetryCount <= 0) {
|
|
|
|
if (lockType === Ci.nsIIcc.CARD_LOCK_TYPE_PUK) {
|
2015-05-05 11:27:23 +00:00
|
|
|
aErrorMsg = MMI_ERROR_KS_SIM_BLOCKED;
|
2015-04-29 10:01:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aCallback.notifyDialMMIError(aErrorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMIErrorWithInfo(MMI_ERROR_KS_BAD_PUK,
|
2015-04-29 10:01:16 +00:00
|
|
|
aRetryCount);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2015-04-29 15:44:36 +00:00
|
|
|
/**
|
|
|
|
* Handle IMEI MMI code.
|
|
|
|
*
|
|
|
|
* @param aClientId
|
|
|
|
* Client id.
|
|
|
|
* @param aMmi
|
|
|
|
* Parsed MMI structure.
|
|
|
|
* @param aCallback
|
|
|
|
* A nsITelephonyDialCallback object.
|
|
|
|
*/
|
|
|
|
_getImeiMMI: function(aClientId, aMmi, aCallback) {
|
2015-11-10 07:30:48 +00:00
|
|
|
let connection = gGonkMobileConnectionService.getItemByServiceId(aClientId);
|
|
|
|
if (!connection.deviceIdentities || !connection.deviceIdentities.imei) {
|
|
|
|
aCallback.notifyDialMMIError(RIL.GECKO_ERROR_GENERIC_FAILURE);
|
|
|
|
return;
|
|
|
|
}
|
2015-04-29 15:44:36 +00:00
|
|
|
|
2015-11-10 07:30:48 +00:00
|
|
|
aCallback.notifyDialMMISuccess(connection.deviceIdentities.imei);
|
2015-04-29 15:44:36 +00:00
|
|
|
},
|
|
|
|
|
2015-04-30 02:53:25 +00:00
|
|
|
/**
|
|
|
|
* Handle CLIP MMI code.
|
|
|
|
*
|
|
|
|
* @param aClientId
|
|
|
|
* Client id.
|
|
|
|
* @param aMmi
|
|
|
|
* Parsed MMI structure.
|
|
|
|
* @param aCallback
|
|
|
|
* A nsITelephonyDialCallback object.
|
|
|
|
*/
|
|
|
|
_clipMMI: function(aClientId, aMmi, aCallback) {
|
2015-05-05 11:27:23 +00:00
|
|
|
if (aMmi.procedure !== MMI_PROCEDURE_INTERROGATION) {
|
|
|
|
aCallback.notifyDialMMIError(MMI_ERROR_KS_NOT_SUPPORTED);
|
2015-04-30 02:53:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._sendToRilWorker(aClientId, "queryCLIP", {}, aResponse => {
|
|
|
|
if (aResponse.errorMsg) {
|
|
|
|
aCallback.notifyDialMMIError(aResponse.errorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// aResponse.provisioned informs about the called party receives the
|
|
|
|
// calling party's address information:
|
|
|
|
// 0 for CLIP not provisioned
|
|
|
|
// 1 for CLIP provisioned
|
|
|
|
// 2 for unknown
|
|
|
|
switch (aResponse.provisioned) {
|
|
|
|
case 0:
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMISuccess(MMI_SM_KS_SERVICE_DISABLED);
|
2015-04-30 02:53:25 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMISuccess(MMI_SM_KS_SERVICE_ENABLED);
|
2015-04-30 02:53:25 +00:00
|
|
|
break;
|
|
|
|
default:
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMIError(MMI_ERROR_KS_ERROR);
|
2015-04-30 02:53:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2015-04-30 04:20:40 +00:00
|
|
|
/**
|
|
|
|
* Handle CLIR MMI code.
|
|
|
|
*
|
|
|
|
* @param aClientId
|
|
|
|
* Client id.
|
|
|
|
* @param aMmi
|
|
|
|
* Parsed MMI structure.
|
|
|
|
* @param aCallback
|
|
|
|
* A nsITelephonyDialCallback object.
|
|
|
|
*/
|
|
|
|
_clirMMI: function(aClientId, aMmi, aCallback) {
|
|
|
|
let connection = gGonkMobileConnectionService.getItemByServiceId(aClientId);
|
|
|
|
switch (aMmi.procedure) {
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_PROCEDURE_INTERROGATION:
|
2015-04-30 04:20:40 +00:00
|
|
|
connection.getCallingLineIdRestriction({
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionCallback]),
|
|
|
|
notifyGetClirStatusSuccess: function(aN, aM) {
|
|
|
|
let errorMsg;
|
|
|
|
let statusMessage;
|
|
|
|
// TS 27.007 +CLIR parameter 'm'.
|
|
|
|
switch (aM) {
|
|
|
|
// CLIR not provisioned.
|
|
|
|
case 0:
|
2015-05-05 11:27:23 +00:00
|
|
|
statusMessage = MMI_SM_KS_SERVICE_NOT_PROVISIONED;
|
2015-04-30 04:20:40 +00:00
|
|
|
break;
|
|
|
|
// CLIR provisioned in permanent mode.
|
|
|
|
case 1:
|
2015-05-05 11:27:23 +00:00
|
|
|
statusMessage = MMI_SM_KS_CLIR_PERMANENT;
|
2015-04-30 04:20:40 +00:00
|
|
|
break;
|
|
|
|
// Unknown (e.g. no network, etc.).
|
|
|
|
case 2:
|
2015-05-05 11:27:23 +00:00
|
|
|
errorMsg = MMI_ERROR_KS_ERROR;
|
2015-04-30 04:20:40 +00:00
|
|
|
break;
|
|
|
|
// CLIR temporary mode presentation restricted.
|
|
|
|
case 3:
|
|
|
|
// TS 27.007 +CLIR parameter 'n'.
|
|
|
|
switch (aN) {
|
|
|
|
// Default.
|
|
|
|
case 0:
|
|
|
|
// CLIR invocation.
|
|
|
|
case 1:
|
2015-05-05 11:27:23 +00:00
|
|
|
statusMessage = MMI_SM_KS_CLIR_DEFAULT_ON_NEXT_CALL_ON;
|
2015-04-30 04:20:40 +00:00
|
|
|
break;
|
|
|
|
// CLIR suppression.
|
|
|
|
case 2:
|
2015-05-05 11:27:23 +00:00
|
|
|
statusMessage = MMI_SM_KS_CLIR_DEFAULT_ON_NEXT_CALL_OFF;
|
2015-04-30 04:20:40 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
errorMsg = RIL.GECKO_ERROR_GENERIC_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
// CLIR temporary mode presentation allowed.
|
|
|
|
case 4:
|
|
|
|
// TS 27.007 +CLIR parameter 'n'.
|
|
|
|
switch (aN) {
|
|
|
|
// Default.
|
|
|
|
case 0:
|
|
|
|
// CLIR suppression.
|
|
|
|
case 2:
|
2015-05-05 11:27:23 +00:00
|
|
|
statusMessage = MMI_SM_KS_CLIR_DEFAULT_OFF_NEXT_CALL_OFF;
|
2015-04-30 04:20:40 +00:00
|
|
|
break;
|
|
|
|
// CLIR invocation.
|
|
|
|
case 1:
|
2015-05-05 11:27:23 +00:00
|
|
|
statusMessage = MMI_SM_KS_CLIR_DEFAULT_OFF_NEXT_CALL_ON;
|
2015-04-30 04:20:40 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
errorMsg = RIL.GECKO_ERROR_GENERIC_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
errorMsg = RIL.GECKO_ERROR_GENERIC_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (errorMsg) {
|
|
|
|
aCallback.notifyDialMMIError(errorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
aCallback.notifyDialMMISuccess(statusMessage);
|
|
|
|
},
|
|
|
|
notifyError: function(aErrorMsg) {
|
|
|
|
aCallback.notifyDialMMIError(aErrorMsg);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
break;
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_PROCEDURE_ACTIVATION:
|
|
|
|
case MMI_PROCEDURE_DEACTIVATION: {
|
2015-04-30 04:20:40 +00:00
|
|
|
let clirMode = MMI_PROC_TO_CLIR_ACTION[aMmi.procedure];
|
|
|
|
connection.setCallingLineIdRestriction(clirMode, {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionCallback]),
|
|
|
|
notifySuccess: function() {
|
|
|
|
aCallback.notifyDialMMISuccess(CLIR_ACTION_TO_STATUS_MESSAGE[clirMode]);
|
|
|
|
},
|
|
|
|
notifyError: function(aErrorMsg) {
|
|
|
|
aCallback.notifyDialMMIError(aErrorMsg);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMIError(MMI_ERROR_KS_NOT_SUPPORTED);
|
2015-04-30 04:20:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-04-30 04:35:55 +00:00
|
|
|
/**
|
|
|
|
* Handle change call barring password MMI code.
|
|
|
|
*
|
|
|
|
* @param aClientId
|
|
|
|
* Client id.
|
|
|
|
* @param aMmi
|
|
|
|
* Parsed MMI structure.
|
|
|
|
* @param aCallback
|
|
|
|
* A nsITelephonyDialCallback object.
|
|
|
|
*/
|
|
|
|
_callBarringPasswordMMI: function(aClientId, aMmi, aCallback) {
|
2015-05-05 11:27:23 +00:00
|
|
|
if (aMmi.procedure !== MMI_PROCEDURE_REGISTRATION &&
|
|
|
|
aMmi.procedure !== MMI_PROCEDURE_ACTIVATION) {
|
|
|
|
aCallback.notifyDialMMIError(MMI_ERROR_KS_INVALID_ACTION);
|
2015-04-30 04:35:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-05 11:27:23 +00:00
|
|
|
if (aMmi.sia !== "" && aMmi.sia !== MMI_ZZ_BARRING_SERVICE) {
|
|
|
|
aCallback.notifyDialMMIError(MMI_ERROR_KS_NOT_SUPPORTED);
|
2015-04-30 04:35:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let validPassword = aSi => /^[0-9]{4}$/.test(aSi);
|
|
|
|
if (!validPassword(aMmi.sib) || !validPassword(aMmi.sic) ||
|
|
|
|
!validPassword(aMmi.pwd)) {
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMIError(MMI_ERROR_KS_INVALID_PASSWORD);
|
2015-04-30 04:35:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aMmi.sic !== aMmi.pwd) {
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMIError(MMI_ERROR_KS_MISMATCH_PASSWORD);
|
2015-04-30 04:35:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let connection = gGonkMobileConnectionService.getItemByServiceId(aClientId);
|
|
|
|
connection.changeCallBarringPassword(aMmi.sib, aMmi.sic, {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionCallback]),
|
|
|
|
notifySuccess: function() {
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMISuccess(MMI_SM_KS_PASSWORD_CHANGED);
|
2015-04-30 04:35:55 +00:00
|
|
|
},
|
|
|
|
notifyError: function(aErrorMsg) {
|
|
|
|
aCallback.notifyDialMMIError(aErrorMsg);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2015-04-30 10:58:30 +00:00
|
|
|
/**
|
|
|
|
* Handle call barring MMI code.
|
|
|
|
*
|
|
|
|
* @param aClientId
|
|
|
|
* Client id.
|
|
|
|
* @param aMmi
|
|
|
|
* Parsed MMI structure.
|
|
|
|
* @param aCallback
|
|
|
|
* A nsITelephonyDialCallback object.
|
|
|
|
*/
|
|
|
|
_callBarringMMI: function(aClientId, aMmi, aCallback) {
|
|
|
|
let connection = gGonkMobileConnectionService.getItemByServiceId(aClientId);
|
|
|
|
let program = MMI_SC_TO_CB_PROGRAM[aMmi.serviceCode];
|
|
|
|
let password = aMmi.sia || "";
|
|
|
|
let serviceClass = this._siToServiceClass(aMmi.sib);
|
|
|
|
|
|
|
|
switch (aMmi.procedure) {
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_PROCEDURE_INTERROGATION:
|
2015-04-30 10:58:30 +00:00
|
|
|
connection.getCallBarring(program, password, serviceClass, {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionCallback]),
|
|
|
|
notifyGetCallBarringSuccess: function(aProgram, aEnabled, aServiceClass) {
|
|
|
|
if (!aEnabled) {
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMISuccess(MMI_SM_KS_SERVICE_DISABLED);
|
2015-04-30 10:58:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-04-30 11:58:16 +00:00
|
|
|
let services = this._serviceClassToStringArray(aServiceClass);
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMISuccessWithStrings(MMI_SM_KS_SERVICE_ENABLED_FOR,
|
2015-04-30 11:58:16 +00:00
|
|
|
services.length, services);
|
|
|
|
}.bind(this),
|
|
|
|
notifyError: function(aErrorMsg) {
|
|
|
|
aCallback.notifyDialMMIError(aErrorMsg);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
break;
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_PROCEDURE_ACTIVATION:
|
|
|
|
case MMI_PROCEDURE_DEACTIVATION: {
|
|
|
|
let enabled = (aMmi.procedure === MMI_PROCEDURE_ACTIVATION);
|
2015-04-30 11:58:16 +00:00
|
|
|
connection.setCallBarring(program, enabled, password, serviceClass, {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionCallback]),
|
|
|
|
notifySuccess: function() {
|
|
|
|
aCallback.notifyDialMMISuccess(
|
2015-05-05 11:27:23 +00:00
|
|
|
enabled ? MMI_SM_KS_SERVICE_ENABLED
|
|
|
|
: MMI_SM_KS_SERVICE_DISABLED
|
2015-04-30 11:58:16 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
notifyError: function(aErrorMsg) {
|
|
|
|
aCallback.notifyDialMMIError(aErrorMsg);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMIError(MMI_ERROR_KS_NOT_SUPPORTED);
|
2015-04-30 11:58:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle call waiting MMI code.
|
|
|
|
*
|
|
|
|
* @param aClientId
|
|
|
|
* Client id.
|
|
|
|
* @param aMmi
|
|
|
|
* Parsed MMI structure.
|
|
|
|
* @param aCallback
|
|
|
|
* A nsITelephonyDialCallback object.
|
|
|
|
*/
|
|
|
|
_callWaitingMMI: function(aClientId, aMmi, aCallback) {
|
|
|
|
let connection = gGonkMobileConnectionService.getItemByServiceId(aClientId);
|
|
|
|
|
|
|
|
switch (aMmi.procedure) {
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_PROCEDURE_INTERROGATION:
|
2015-04-30 11:58:16 +00:00
|
|
|
connection.getCallWaiting({
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionCallback]),
|
|
|
|
notifyGetCallWaitingSuccess: function(aServiceClass) {
|
|
|
|
if (aServiceClass === Ci.nsIMobileConnection.ICC_SERVICE_CLASS_NONE) {
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMISuccess(MMI_SM_KS_SERVICE_DISABLED);
|
2015-04-30 11:58:16 +00:00
|
|
|
return;
|
2015-04-30 10:58:30 +00:00
|
|
|
}
|
|
|
|
|
2015-04-30 11:58:16 +00:00
|
|
|
let services = this._serviceClassToStringArray(aServiceClass);
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMISuccessWithStrings(MMI_SM_KS_SERVICE_ENABLED_FOR,
|
2015-04-30 10:58:30 +00:00
|
|
|
services.length, services);
|
2015-04-30 11:58:16 +00:00
|
|
|
}.bind(this),
|
2015-04-30 10:58:30 +00:00
|
|
|
notifyError: function(aErrorMsg) {
|
|
|
|
aCallback.notifyDialMMIError(aErrorMsg);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
break;
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_PROCEDURE_ACTIVATION:
|
|
|
|
case MMI_PROCEDURE_DEACTIVATION: {
|
|
|
|
let enabled = (aMmi.procedure === MMI_PROCEDURE_ACTIVATION);
|
2015-04-30 11:58:16 +00:00
|
|
|
let serviceClass = this._siToServiceClass(aMmi.sia);
|
|
|
|
connection.setCallWaiting(enabled, serviceClass, {
|
2015-04-30 10:58:30 +00:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionCallback]),
|
|
|
|
notifySuccess: function() {
|
|
|
|
aCallback.notifyDialMMISuccess(
|
2015-05-05 11:27:23 +00:00
|
|
|
enabled ? MMI_SM_KS_SERVICE_ENABLED
|
|
|
|
: MMI_SM_KS_SERVICE_DISABLED
|
2015-04-30 10:58:30 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
notifyError: function(aErrorMsg) {
|
|
|
|
aCallback.notifyDialMMIError(aErrorMsg);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2015-05-05 11:27:23 +00:00
|
|
|
aCallback.notifyDialMMIError(MMI_ERROR_KS_NOT_SUPPORTED);
|
2015-04-30 10:58:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-09-22 05:36:00 +00:00
|
|
|
_serviceCodeToKeyString: function(aServiceCode) {
|
|
|
|
switch (aServiceCode) {
|
2015-05-05 11:27:23 +00:00
|
|
|
case MMI_SC_CFU:
|
|
|
|
case MMI_SC_CF_BUSY:
|
|
|
|
case MMI_SC_CF_NO_REPLY:
|
|
|
|
case MMI_SC_CF_NOT_REACHABLE:
|
|
|
|
case MMI_SC_CF_ALL:
|
|
|
|
case MMI_SC_CF_ALL_CONDITIONAL:
|
|
|
|
return MMI_KS_SC_CALL_FORWARDING;
|
|
|
|
case MMI_SC_PIN:
|
|
|
|
return MMI_KS_SC_PIN;
|
|
|
|
case MMI_SC_PIN2:
|
|
|
|
return MMI_KS_SC_PIN2;
|
|
|
|
case MMI_SC_PUK:
|
|
|
|
return MMI_KS_SC_PUK;
|
|
|
|
case MMI_SC_PUK2:
|
|
|
|
return MMI_KS_SC_PUK2;
|
|
|
|
case MMI_SC_IMEI:
|
|
|
|
return MMI_KS_SC_IMEI;
|
|
|
|
case MMI_SC_CLIP:
|
|
|
|
return MMI_KS_SC_CLIP;
|
|
|
|
case MMI_SC_CLIR:
|
|
|
|
return MMI_KS_SC_CLIR;
|
|
|
|
case MMI_SC_BAOC:
|
|
|
|
case MMI_SC_BAOIC:
|
|
|
|
case MMI_SC_BAOICxH:
|
|
|
|
case MMI_SC_BAIC:
|
|
|
|
case MMI_SC_BAICr:
|
|
|
|
case MMI_SC_BA_ALL:
|
|
|
|
case MMI_SC_BA_MO:
|
|
|
|
case MMI_SC_BA_MT:
|
|
|
|
return MMI_KS_SC_CALL_BARRING;
|
|
|
|
case MMI_SC_CALL_WAITING:
|
|
|
|
return MMI_KS_SC_CALL_WAITING;
|
|
|
|
case MMI_SC_CHANGE_PASSWORD:
|
|
|
|
return MMI_KS_SC_CHANGE_PASSWORD;
|
2014-09-22 05:36:00 +00:00
|
|
|
default:
|
2015-05-05 11:27:23 +00:00
|
|
|
return MMI_KS_SC_USSD;
|
2014-09-22 05:36:00 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-04-29 07:05:06 +00:00
|
|
|
/**
|
|
|
|
* Helper for translating basic service group to service class parameter.
|
|
|
|
*/
|
|
|
|
_siToServiceClass: function(aSi) {
|
|
|
|
if (!aSi) {
|
|
|
|
return Ci.nsIMobileConnection.ICC_SERVICE_CLASS_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
let serviceCode = parseInt(aSi, 10);
|
|
|
|
switch (serviceCode) {
|
|
|
|
case 10:
|
|
|
|
return Ci.nsIMobileConnection.ICC_SERVICE_CLASS_SMS +
|
|
|
|
Ci.nsIMobileConnection.ICC_SERVICE_CLASS_FAX +
|
|
|
|
Ci.nsIMobileConnection.ICC_SERVICE_CLASS_VOICE;
|
|
|
|
case 11:
|
|
|
|
return Ci.nsIMobileConnection.ICC_SERVICE_CLASS_VOICE;
|
|
|
|
case 12:
|
|
|
|
return Ci.nsIMobileConnection.ICC_SERVICE_CLASS_SMS +
|
|
|
|
Ci.nsIMobileConnection.ICC_SERVICE_CLASS_FAX;
|
|
|
|
case 13:
|
|
|
|
return Ci.nsIMobileConnection.ICC_SERVICE_CLASS_FAX;
|
|
|
|
case 16:
|
|
|
|
return Ci.nsIMobileConnection.ICC_SERVICE_CLASS_SMS;
|
|
|
|
case 19:
|
|
|
|
return Ci.nsIMobileConnection.ICC_SERVICE_CLASS_FAX +
|
|
|
|
Ci.nsIMobileConnection.ICC_SERVICE_CLASS_VOICE;
|
|
|
|
case 21:
|
|
|
|
return Ci.nsIMobileConnection.ICC_SERVICE_CLASS_PAD +
|
|
|
|
Ci.nsIMobileConnection.ICC_SERVICE_CLASS_DATA_ASYNC;
|
|
|
|
case 22:
|
|
|
|
return Ci.nsIMobileConnection.ICC_SERVICE_CLASS_PACKET +
|
|
|
|
Ci.nsIMobileConnection.ICC_SERVICE_CLASS_DATA_SYNC;
|
|
|
|
case 25:
|
|
|
|
return Ci.nsIMobileConnection.ICC_SERVICE_CLASS_DATA_ASYNC;
|
|
|
|
case 26:
|
|
|
|
return Ci.nsIMobileConnection.ICC_SERVICE_CLASS_DATA_SYNC +
|
|
|
|
Ci.nsIMobileConnection.ICC_SERVICE_CLASS_VOICE;
|
|
|
|
case 99:
|
|
|
|
return Ci.nsIMobileConnection.ICC_SERVICE_CLASS_PACKET;
|
|
|
|
default:
|
|
|
|
return Ci.nsIMobileConnection.ICC_SERVICE_CLASS_NONE;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-04-30 11:58:16 +00:00
|
|
|
_serviceClassToStringArray: function(aServiceClass) {
|
|
|
|
let services = [];
|
|
|
|
for (let mask = Ci.nsIMobileConnection.ICC_SERVICE_CLASS_VOICE;
|
|
|
|
mask <= Ci.nsIMobileConnection.ICC_SERVICE_CLASS_MAX;
|
|
|
|
mask <<= 1) {
|
|
|
|
if (mask & aServiceClass) {
|
2015-05-05 11:27:23 +00:00
|
|
|
services.push(MMI_KS_SERVICE_CLASS_MAPPING[mask]);
|
2015-04-30 11:58:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return services;
|
|
|
|
},
|
|
|
|
|
2015-04-29 10:01:16 +00:00
|
|
|
_getIccLockMMIError: function(aMmi) {
|
|
|
|
// As defined in TS.122.030 6.6.2 to change the ICC PIN we should expect
|
|
|
|
// an MMI code of the form **04*OLD_PIN*NEW_PIN*NEW_PIN#, where old PIN
|
|
|
|
// should be entered as the SIA parameter and the new PIN as SIB and
|
|
|
|
// SIC.
|
2015-05-05 11:27:23 +00:00
|
|
|
if (aMmi.procedure !== MMI_PROCEDURE_REGISTRATION) {
|
|
|
|
return MMI_ERROR_KS_INVALID_ACTION;
|
2015-04-29 10:01:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!aMmi.sia || !aMmi.sib || !aMmi.sic) {
|
2015-05-05 11:27:23 +00:00
|
|
|
return MMI_ERROR_KS_ERROR;
|
2015-04-29 10:01:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aMmi.sia.length < 4 || aMmi.sia.length > 8 ||
|
|
|
|
aMmi.sib.length < 4 || aMmi.sib.length > 8 ||
|
|
|
|
aMmi.sic.length < 4 || aMmi.sic.length > 8) {
|
2015-05-05 11:27:23 +00:00
|
|
|
return MMI_ERROR_KS_INVALID_PIN;
|
2015-04-29 10:01:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aMmi.sib != aMmi.sic) {
|
2015-05-05 11:27:23 +00:00
|
|
|
return MMI_ERROR_KS_MISMATCH_PIN;
|
2015-04-29 10:01:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
2014-12-24 00:06:00 +00:00
|
|
|
/**
|
|
|
|
* The default callback handler for call operations.
|
|
|
|
*
|
|
|
|
* @param aCallback
|
|
|
|
* An callback object including notifySuccess() and notifyError(aMsg)
|
|
|
|
* @param aResponse
|
|
|
|
* The response from ril_worker.
|
|
|
|
*/
|
|
|
|
_defaultCallbackHandler: function(aCallback, aResponse) {
|
2014-05-12 10:29:53 +00:00
|
|
|
if (aResponse.errorMsg) {
|
2014-12-24 00:06:00 +00:00
|
|
|
aCallback.notifyError(aResponse.errorMsg);
|
2014-02-21 09:46:58 +00:00
|
|
|
} else {
|
2014-12-24 00:06:00 +00:00
|
|
|
aCallback.notifySuccess();
|
2014-02-21 09:46:58 +00:00
|
|
|
}
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2015-08-23 17:29:00 +00:00
|
|
|
_defaultMMICallbackHandler: function(aCallback, aResponse) {
|
|
|
|
if (aResponse.errorMsg) {
|
|
|
|
aCallback.notifyDialMMIError(aResponse.errorMsg);
|
|
|
|
} else {
|
|
|
|
aCallback.notifyDialMMISuccess("");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
_getCallsWithState: function(aClientId, aState) {
|
|
|
|
let calls = [];
|
|
|
|
for (let i in this._currentCalls[aClientId]) {
|
|
|
|
let call = this._currentCalls[aClientId][i];
|
|
|
|
if (call.state === aState) {
|
|
|
|
calls.push(call);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return calls;
|
|
|
|
},
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
/**
|
|
|
|
* Update call information from RIL.
|
|
|
|
*
|
|
|
|
* @return Boolean to indicate whether the data is changed.
|
|
|
|
*/
|
|
|
|
_updateCallFromRil: function(aCall, aRilCall) {
|
|
|
|
aRilCall.state = this._convertRILCallState(aRilCall.state);
|
|
|
|
aRilCall.number = this._formatInternationalNumber(aRilCall.number,
|
|
|
|
aRilCall.toa);
|
|
|
|
|
|
|
|
let change = false;
|
|
|
|
const key = ["state", "number", "numberPresentation", "name",
|
|
|
|
"namePresentation"];
|
|
|
|
|
|
|
|
for (let k of key) {
|
|
|
|
if (aCall[k] != aRilCall[k]) {
|
|
|
|
aCall[k] = aRilCall[k];
|
|
|
|
change = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aCall.isOutgoing = !aRilCall.isMT;
|
2015-05-12 09:41:46 +00:00
|
|
|
aCall.isEmergency = DialNumberUtils.isEmergency(aCall.number);
|
2015-03-24 10:04:49 +00:00
|
|
|
|
2015-03-29 13:54:57 +00:00
|
|
|
if (!aCall.started &&
|
|
|
|
aCall.state == nsITelephonyService.CALL_STATE_CONNECTED) {
|
|
|
|
aCall.started = new Date().getTime();
|
|
|
|
}
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
return change;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Identify the conference group.
|
2015-04-24 10:10:37 +00:00
|
|
|
* @return [conference state, array of calls in group]
|
2015-03-24 10:04:49 +00:00
|
|
|
*
|
|
|
|
* TODO: handle multi-sim case.
|
|
|
|
*/
|
|
|
|
_detectConference: function(aClientId) {
|
|
|
|
// There are some difficuties to identify the conference by |.isMpty| from RIL
|
|
|
|
// so we don't rely on this flag.
|
|
|
|
// - |.isMpty| becomes false when the conference call is put on hold.
|
|
|
|
// - |.isMpty| may remain true when other participants left the conference.
|
|
|
|
|
|
|
|
// All the calls in the conference should have the same state and it is
|
|
|
|
// either CONNECTED or HELD. That means, if we find a group of call with
|
|
|
|
// the same state and its size is larger than 2, it must be a conference.
|
|
|
|
let connectedCalls = this._getCallsWithState(aClientId, nsITelephonyService.CALL_STATE_CONNECTED);
|
|
|
|
let heldCalls = this._getCallsWithState(aClientId, nsITelephonyService.CALL_STATE_HELD);
|
|
|
|
|
|
|
|
if (connectedCalls.length >= 2) {
|
|
|
|
return [nsITelephonyService.CALL_STATE_CONNECTED, connectedCalls];
|
|
|
|
} else if (heldCalls.length >= 2) {
|
|
|
|
return [nsITelephonyService.CALL_STATE_HELD, heldCalls];
|
|
|
|
}
|
|
|
|
|
|
|
|
return [nsITelephonyService.CALL_STATE_UNKNOWN, null];
|
|
|
|
},
|
|
|
|
|
2015-04-24 10:10:37 +00:00
|
|
|
/**
|
|
|
|
* Update the isConference flag of all Calls.
|
|
|
|
*
|
|
|
|
* @return [conference state, array of calls being updated]
|
|
|
|
*/
|
|
|
|
_updateConference: function(aClientId) {
|
|
|
|
let [newConferenceState, conferenceCalls] = this._detectConference(aClientId);
|
|
|
|
if (DEBUG) debug("Conference state: " + newConferenceState);
|
|
|
|
|
|
|
|
let changedCalls = [];
|
|
|
|
let conference = new Set(conferenceCalls);
|
|
|
|
|
|
|
|
for (let i in this._currentCalls[aClientId]) {
|
|
|
|
let call = this._currentCalls[aClientId][i];
|
|
|
|
let isConference = conference.has(call);
|
|
|
|
if (call.isConference != isConference) {
|
|
|
|
call.isConference = isConference;
|
|
|
|
changedCalls.push(call);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return [newConferenceState, changedCalls];
|
|
|
|
},
|
|
|
|
|
2015-01-07 06:37:03 +00:00
|
|
|
sendTones: function(aClientId, aDtmfChars, aPauseDuration, aToneDuration,
|
|
|
|
aCallback) {
|
|
|
|
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
|
|
|
let tones = aDtmfChars;
|
|
|
|
let playTone = (tone) => {
|
|
|
|
this._sendToRilWorker(aClientId, "startTone", { dtmfChar: tone }, response => {
|
2014-05-12 10:29:53 +00:00
|
|
|
if (response.errorMsg) {
|
2015-01-07 06:37:03 +00:00
|
|
|
aCallback.notifyError(response.errorMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
timer.initWithCallback(() => {
|
|
|
|
this.stopTone();
|
|
|
|
timer.initWithCallback(() => {
|
|
|
|
if (tones.length === 1) {
|
|
|
|
aCallback.notifySuccess();
|
|
|
|
} else {
|
|
|
|
tones = tones.substr(1);
|
|
|
|
playTone(tones[0]);
|
|
|
|
}
|
|
|
|
}, TONES_GAP_DURATION, Ci.nsITimer.TYPE_ONE_SHOT);
|
|
|
|
}, aToneDuration, Ci.nsITimer.TYPE_ONE_SHOT);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
timer.initWithCallback(() => {
|
|
|
|
playTone(tones[0]);
|
|
|
|
}, aPauseDuration, Ci.nsITimer.TYPE_ONE_SHOT);
|
|
|
|
},
|
|
|
|
|
2013-10-31 12:05:51 +00:00
|
|
|
startTone: function(aClientId, aDtmfChar) {
|
2014-08-19 04:23:00 +00:00
|
|
|
this._sendToRilWorker(aClientId, "startTone", { dtmfChar: aDtmfChar });
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2013-10-31 12:05:51 +00:00
|
|
|
stopTone: function(aClientId) {
|
2014-08-19 04:23:00 +00:00
|
|
|
this._sendToRilWorker(aClientId, "stopTone");
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2014-12-24 00:06:00 +00:00
|
|
|
answerCall: function(aClientId, aCallIndex, aCallback) {
|
2015-03-24 10:04:49 +00:00
|
|
|
let call = this._currentCalls[aClientId][aCallIndex];
|
|
|
|
if (!call || call.state != nsITelephonyService.CALL_STATE_INCOMING) {
|
|
|
|
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let callNum = Object.keys(this._currentCalls[aClientId]).length;
|
|
|
|
if (callNum !== 1) {
|
|
|
|
this._switchActiveCall(aClientId, aCallback);
|
|
|
|
} else {
|
|
|
|
this._sendToRilWorker(aClientId, "answerCall", null,
|
|
|
|
this._defaultCallbackHandler.bind(this, aCallback));
|
|
|
|
}
|
2014-12-24 00:06:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
rejectCall: function(aClientId, aCallIndex, aCallback) {
|
2015-03-24 10:04:49 +00:00
|
|
|
if (this._isCdmaClient(aClientId)) {
|
|
|
|
this._hangUpBackground(aClientId, aCallback);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let call = this._currentCalls[aClientId][aCallIndex];
|
|
|
|
if (!call || call.state != nsITelephonyService.CALL_STATE_INCOMING) {
|
|
|
|
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let callNum = Object.keys(this._currentCalls[aClientId]).length;
|
|
|
|
if (callNum !== 1) {
|
|
|
|
this._hangUpBackground(aClientId, aCallback);
|
|
|
|
} else {
|
2015-04-07 10:09:14 +00:00
|
|
|
call.hangUpLocal = true;
|
2015-03-24 10:04:49 +00:00
|
|
|
this._sendToRilWorker(aClientId, "udub", null,
|
|
|
|
this._defaultCallbackHandler.bind(this, aCallback));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_hangUpForeground: function(aClientId, aCallback) {
|
|
|
|
let calls = this._getCallsWithState(aClientId, nsITelephonyService.CALL_STATE_CONNECTED);
|
|
|
|
calls.forEach(call => call.hangUpLocal = true);
|
|
|
|
|
|
|
|
this._sendToRilWorker(aClientId, "hangUpForeground", null,
|
|
|
|
this._defaultCallbackHandler.bind(this, aCallback));
|
|
|
|
},
|
|
|
|
|
|
|
|
_hangUpBackground: function(aClientId, aCallback) {
|
|
|
|
// When both a held and a waiting call exist, the request shall apply to
|
|
|
|
// the waiting call.
|
|
|
|
let waitingCalls = this._getCallsWithState(aClientId, nsITelephonyService.CALL_STATE_INCOMING);
|
|
|
|
let heldCalls = this._getCallsWithState(aClientId, nsITelephonyService.CALL_STATE_HELD);
|
|
|
|
|
|
|
|
if (waitingCalls.length) {
|
|
|
|
waitingCalls.forEach(call => call.hangUpLocal = true);
|
|
|
|
} else {
|
|
|
|
heldCalls.forEach(call => call.hangUpLocal = true);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._sendToRilWorker(aClientId, "hangUpBackground", null,
|
2014-12-24 00:06:00 +00:00
|
|
|
this._defaultCallbackHandler.bind(this, aCallback));
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2014-12-24 00:06:00 +00:00
|
|
|
hangUpCall: function(aClientId, aCallIndex, aCallback) {
|
2015-02-03 04:18:20 +00:00
|
|
|
// Should release both, child and parent, together. Since RIL holds only
|
|
|
|
// the parent call, we send 'parentId' to RIL.
|
|
|
|
aCallIndex = this._currentCalls[aClientId][aCallIndex].parentId || aCallIndex;
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
let call = this._currentCalls[aClientId][aCallIndex];
|
|
|
|
if (call.state === nsITelephonyService.CALL_STATE_HELD) {
|
|
|
|
this._hangUpBackground(aClientId, aCallback);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-07-30 03:36:27 +00:00
|
|
|
// After hangup a single call, gecko has to resume the held call or conference.
|
2015-06-30 10:02:23 +00:00
|
|
|
if (!call.isConference) {
|
|
|
|
let heldCalls = this._getCallsWithState(aClientId, nsITelephonyService.CALL_STATE_HELD);
|
|
|
|
|
|
|
|
if (heldCalls.length) {
|
2015-07-30 03:36:27 +00:00
|
|
|
if (call.state === nsITelephonyService.CALL_STATE_CONNECTED) {
|
|
|
|
// For a foreground call, ril has a request to do two actions together.
|
|
|
|
this._hangUpForeground(aClientId, aCallback);
|
|
|
|
} else {
|
|
|
|
// Otherwise, gecko should send out two consecutive requests by itself.
|
|
|
|
this._sendToRilWorker(aClientId, "hangUpCall", { callIndex: aCallIndex }, response => {
|
|
|
|
if (response.errorMsg) {
|
|
|
|
aCallback.notifyError(response.errorMsg);
|
|
|
|
} else {
|
|
|
|
aCallback.notifySuccess();
|
|
|
|
|
|
|
|
let emptyCallback = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsITelephonyCallback]),
|
|
|
|
notifySuccess: () => {},
|
|
|
|
notifyError: () => {}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (heldCalls.length === 1) {
|
|
|
|
this.resumeCall(aClientId, heldCalls[0].callIndex, emptyCallback);
|
|
|
|
} else {
|
|
|
|
this.resumeConference(aClientId, emptyCallback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-06-30 10:02:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
call.hangUpLocal = true;
|
2015-02-03 04:18:20 +00:00
|
|
|
this._sendToRilWorker(aClientId, "hangUpCall", { callIndex: aCallIndex },
|
|
|
|
this._defaultCallbackHandler.bind(this, aCallback));
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
_switchCall: function(aClientId, aCallIndex, aCallback, aRequiredState) {
|
2014-02-21 09:46:58 +00:00
|
|
|
let call = this._currentCalls[aClientId][aCallIndex];
|
2015-02-03 04:18:20 +00:00
|
|
|
if (!call) {
|
2014-12-24 00:06:00 +00:00
|
|
|
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
|
2014-02-21 09:46:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
if (this._isCdmaClient(aClientId)) {
|
|
|
|
this._switchCallCdma(aClientId, aCallIndex, aCallback);
|
|
|
|
} else {
|
|
|
|
this._switchCallGsm(aClientId, aCallIndex, aCallback, aRequiredState);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_switchCallGsm: function(aClientId, aCallIndex, aCallback, aRequiredState) {
|
|
|
|
let call = this._currentCalls[aClientId][aCallIndex];
|
|
|
|
if (call.state != aRequiredState) {
|
|
|
|
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
this._switchActiveCall(aClientId, aCallback);
|
|
|
|
},
|
|
|
|
|
|
|
|
_switchActiveCall: function(aClientId, aCallback) {
|
2015-02-03 04:18:20 +00:00
|
|
|
this._sendToRilWorker(aClientId, "switchActiveCall", null,
|
2014-12-24 00:06:00 +00:00
|
|
|
this._defaultCallbackHandler.bind(this, aCallback));
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
_switchCallCdma: function(aClientId, aCallIndex, aCallback) {
|
2014-02-21 09:46:58 +00:00
|
|
|
let call = this._currentCalls[aClientId][aCallIndex];
|
2015-02-03 04:18:20 +00:00
|
|
|
if (!call.isSwitchable) {
|
2014-12-24 00:06:00 +00:00
|
|
|
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
|
2014-02-21 09:46:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
this._sendToRilWorker(aClientId, "cdmaFlash", null,
|
2014-12-24 00:06:00 +00:00
|
|
|
this._defaultCallbackHandler.bind(this, aCallback));
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
holdCall: function(aClientId, aCallIndex, aCallback) {
|
|
|
|
this._switchCall(aClientId, aCallIndex, aCallback,
|
|
|
|
nsITelephonyService.CALL_STATE_CONNECTED);
|
|
|
|
},
|
|
|
|
|
|
|
|
resumeCall: function(aClientId, aCallIndex, aCallback) {
|
|
|
|
this._switchCall(aClientId, aCallIndex, aCallback,
|
|
|
|
nsITelephonyService.CALL_STATE_HELD);
|
|
|
|
},
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
_conferenceCallGsm: function(aClientId, aCallback) {
|
|
|
|
this._sendToRilWorker(aClientId, "conferenceCall", null, response => {
|
2014-05-12 10:29:53 +00:00
|
|
|
if (response.errorMsg) {
|
2015-02-03 04:18:20 +00:00
|
|
|
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
|
|
|
|
// TODO: Bug 1124993. Deprecate it. Use callback response is enough.
|
|
|
|
this._notifyAllListeners("notifyConferenceError",
|
|
|
|
["addError", response.errorMsg]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
aCallback.notifySuccess();
|
|
|
|
});
|
|
|
|
},
|
2014-02-21 09:46:58 +00:00
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
_conferenceCallCdma: function(aClientId, aCallback) {
|
|
|
|
for (let index in this._currentCalls[aClientId]) {
|
|
|
|
let call = this._currentCalls[aClientId][index];
|
2014-02-21 09:46:58 +00:00
|
|
|
if (!call.isMergeable) {
|
2015-01-11 08:25:00 +00:00
|
|
|
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
|
2014-02-21 09:46:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
this._sendToRilWorker(aClientId, "cdmaFlash", null, response => {
|
2014-05-12 10:29:53 +00:00
|
|
|
if (response.errorMsg) {
|
2015-01-11 08:25:00 +00:00
|
|
|
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
|
2015-02-03 04:18:20 +00:00
|
|
|
// TODO: Bug 1124993. Deprecate it. Use callback response is enough.
|
|
|
|
this._notifyAllListeners("notifyConferenceError",
|
|
|
|
["addError", response.errorMsg]);
|
2014-08-19 04:23:00 +00:00
|
|
|
return;
|
2014-02-21 09:46:58 +00:00
|
|
|
}
|
|
|
|
|
2015-04-24 10:10:37 +00:00
|
|
|
let calls = [];
|
2015-02-03 04:18:20 +00:00
|
|
|
for (let index in this._currentCalls[aClientId]) {
|
|
|
|
let call = this._currentCalls[aClientId][index];
|
2015-03-24 10:04:49 +00:00
|
|
|
call.state = nsITelephonyService.CALL_STATE_CONNECTED;
|
2015-02-03 04:18:20 +00:00
|
|
|
call.isConference = true;
|
2015-04-24 10:10:37 +00:00
|
|
|
calls.push(call);
|
2014-02-21 09:46:58 +00:00
|
|
|
}
|
2015-04-24 10:10:37 +00:00
|
|
|
this._handleCallStateChanged(aClientId, calls);
|
2015-01-11 08:25:00 +00:00
|
|
|
|
|
|
|
aCallback.notifySuccess();
|
2014-08-19 04:23:00 +00:00
|
|
|
});
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
conferenceCall: function(aClientId, aCallback) {
|
|
|
|
if (Object.keys(this._currentCalls[aClientId]).length < 2) {
|
2015-01-11 08:25:00 +00:00
|
|
|
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
|
2014-02-21 09:46:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
if (this._isCdmaClient(aClientId)) {
|
|
|
|
this._conferenceCallCdma(aClientId, aCallback);
|
|
|
|
} else {
|
|
|
|
this._conferenceCallGsm(aClientId, aCallback);
|
2014-02-21 09:46:58 +00:00
|
|
|
}
|
2015-02-03 04:18:20 +00:00
|
|
|
},
|
2014-02-21 09:46:58 +00:00
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
_separateCallGsm: function(aClientId, aCallIndex, aCallback) {
|
2014-08-19 04:23:00 +00:00
|
|
|
this._sendToRilWorker(aClientId, "separateCall", { callIndex: aCallIndex },
|
|
|
|
response => {
|
2014-05-12 10:29:53 +00:00
|
|
|
if (response.errorMsg) {
|
2015-01-11 08:25:00 +00:00
|
|
|
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
|
2015-02-03 04:18:20 +00:00
|
|
|
// TODO: Bug 1124993. Deprecate it. Use callback response is enough.
|
|
|
|
this._notifyAllListeners("notifyConferenceError",
|
|
|
|
["removeError", response.errorMsg]);
|
2014-08-19 04:23:00 +00:00
|
|
|
return;
|
2014-02-21 09:46:58 +00:00
|
|
|
}
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
aCallback.notifySuccess();
|
|
|
|
});
|
|
|
|
},
|
2015-01-11 08:25:00 +00:00
|
|
|
|
2015-04-24 10:10:37 +00:00
|
|
|
_removeCdmaSecondCall: function(aClientId) {
|
|
|
|
let childCall = this._currentCalls[aClientId][CDMA_SECOND_CALL_INDEX];
|
|
|
|
let parentCall = this._currentCalls[aClientId][CDMA_FIRST_CALL_INDEX];
|
|
|
|
|
|
|
|
this._disconnectCalls(aClientId, [childCall]);
|
|
|
|
|
|
|
|
parentCall.isConference = false;
|
|
|
|
parentCall.isSwitchable = true;
|
|
|
|
parentCall.isMergeable = true;
|
|
|
|
this._handleCallStateChanged(aClientId, [childCall, parentCall]);
|
|
|
|
},
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
// See 3gpp2, S.R0006-522-A v1.0. Table 4, XID 6S.
|
|
|
|
// Release the third party. Optionally apply a warning tone. Connect the
|
|
|
|
// controlling subscriber and the second party. Go to the 2-way state.
|
|
|
|
_separateCallCdma: function(aClientId, aCallIndex, aCallback) {
|
|
|
|
this._sendToRilWorker(aClientId, "cdmaFlash", null, response => {
|
2014-05-12 10:29:53 +00:00
|
|
|
if (response.errorMsg) {
|
2015-02-03 04:18:20 +00:00
|
|
|
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
|
|
|
|
// TODO: Bug 1124993. Deprecate it. Use callback response is enough.
|
|
|
|
this._notifyAllListeners("notifyConferenceError",
|
|
|
|
["removeError", response.errorMsg]);
|
|
|
|
return;
|
2014-02-21 09:46:58 +00:00
|
|
|
}
|
2015-01-11 08:25:00 +00:00
|
|
|
|
2015-04-24 10:10:37 +00:00
|
|
|
this._removeCdmaSecondCall(aClientId);
|
2015-01-11 08:25:00 +00:00
|
|
|
aCallback.notifySuccess();
|
2014-08-19 04:23:00 +00:00
|
|
|
});
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
separateCall: function(aClientId, aCallIndex, aCallback) {
|
|
|
|
let call = this._currentCalls[aClientId][aCallIndex];
|
|
|
|
if (!call || !call.isConference) {
|
|
|
|
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._isCdmaClient(aClientId)) {
|
|
|
|
this._separateCallCdma(aClientId, aCallIndex, aCallback);
|
|
|
|
} else {
|
|
|
|
this._separateCallGsm(aClientId, aCallIndex, aCallback);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-10-20 07:13:00 +00:00
|
|
|
hangUpConference: function(aClientId, aCallback) {
|
2015-02-03 04:18:20 +00:00
|
|
|
// In cdma, ril only maintains one call index.
|
|
|
|
if (this._isCdmaClient(aClientId)) {
|
|
|
|
this._sendToRilWorker(aClientId, "hangUpCall",
|
|
|
|
{ callIndex: CDMA_FIRST_CALL_INDEX },
|
|
|
|
this._defaultCallbackHandler.bind(this, aCallback));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-11 23:47:00 +00:00
|
|
|
// Find a conference call, and send the corresponding request to RIL worker.
|
|
|
|
for (let index in this._currentCalls[aClientId]) {
|
|
|
|
let call = this._currentCalls[aClientId][index];
|
|
|
|
if (!call.isConference) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
let command = call.state === nsITelephonyService.CALL_STATE_CONNECTED ?
|
|
|
|
"hangUpForeground" : "hangUpBackground";
|
|
|
|
this._sendToRilWorker(aClientId, command, null,
|
|
|
|
this._defaultCallbackHandler.bind(this, aCallback));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// There is no conference call.
|
|
|
|
if (DEBUG) debug("hangUpConference: " +
|
|
|
|
"No conference call in modem[" + aClientId + "].");
|
|
|
|
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
|
2014-10-20 07:13:00 +00:00
|
|
|
},
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
_switchConference: function(aClientId, aCallback) {
|
|
|
|
// Cannot hold/resume a conference in cdma.
|
|
|
|
if (this._isCdmaClient(aClientId)) {
|
|
|
|
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
this._switchActiveCall(aClientId, aCallback);
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2015-02-03 04:18:20 +00:00
|
|
|
holdConference: function(aClientId, aCallback) {
|
|
|
|
this._switchConference(aClientId, aCallback);
|
|
|
|
},
|
|
|
|
|
2015-01-11 08:25:00 +00:00
|
|
|
resumeConference: function(aClientId, aCallback) {
|
2015-02-03 04:18:20 +00:00
|
|
|
this._switchConference(aClientId, aCallback);
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2014-10-15 06:51:00 +00:00
|
|
|
sendUSSD: function(aClientId, aUssd, aCallback) {
|
2015-04-30 14:45:40 +00:00
|
|
|
this._sendUSSDInternal(aClientId, aUssd,
|
|
|
|
this._defaultCallbackHandler.bind(this, aCallback));
|
|
|
|
},
|
|
|
|
|
|
|
|
_sendUSSDInternal: function(aClientId, aUssd, aCallback) {
|
2015-08-28 08:39:57 +00:00
|
|
|
this._ussdSessions[aClientId] = USSD_SESSION_ONGOING;
|
2015-08-23 17:29:00 +00:00
|
|
|
this._sendToRilWorker(aClientId, "sendUSSD", { ussd: aUssd }, aResponse => {
|
2015-08-28 08:39:57 +00:00
|
|
|
if (aResponse.errorMsg) {
|
|
|
|
this._ussdSessions[aClientId] = USSD_SESSION_DONE;
|
|
|
|
}
|
2015-08-23 17:29:00 +00:00
|
|
|
aCallback(aResponse);
|
2015-04-30 14:45:40 +00:00
|
|
|
});
|
2014-10-15 06:51:00 +00:00
|
|
|
},
|
|
|
|
|
2015-01-07 07:28:44 +00:00
|
|
|
cancelUSSD: function(aClientId, aCallback) {
|
2015-04-30 14:45:40 +00:00
|
|
|
this._cancelUSSDInternal(aClientId,
|
|
|
|
this._defaultCallbackHandler.bind(this, aCallback));
|
|
|
|
},
|
|
|
|
|
|
|
|
_cancelUSSDInternal: function(aClientId, aCallback) {
|
2015-08-28 08:39:57 +00:00
|
|
|
this._ussdSessions[aClientId] = USSD_SESSION_CANCELLING;
|
2015-04-30 14:45:40 +00:00
|
|
|
this._sendToRilWorker(aClientId, "cancelUSSD", {}, aResponse => {
|
2015-08-28 08:39:57 +00:00
|
|
|
if (aResponse.errorMsg) {
|
|
|
|
this._ussdSessions[aClientId] = USSD_SESSION_ONGOING;
|
|
|
|
}
|
2015-04-30 14:45:40 +00:00
|
|
|
aCallback(aResponse);
|
|
|
|
});
|
2015-01-07 07:28:44 +00:00
|
|
|
},
|
|
|
|
|
2013-09-07 06:19:57 +00:00
|
|
|
get microphoneMuted() {
|
2014-11-14 07:20:44 +00:00
|
|
|
return gAudioService.microphoneMuted;
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
set microphoneMuted(aMuted) {
|
2014-11-14 07:20:44 +00:00
|
|
|
gAudioService.microphoneMuted = aMuted;
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
get speakerEnabled() {
|
2014-11-14 07:20:44 +00:00
|
|
|
return gAudioService.speakerEnabled;
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
set speakerEnabled(aEnabled) {
|
2014-11-14 07:20:44 +00:00
|
|
|
gAudioService.speakerEnabled = aEnabled;
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2014-06-03 14:15:25 +00:00
|
|
|
* nsIGonkTelephonyService interface.
|
2013-09-07 06:19:57 +00:00
|
|
|
*/
|
|
|
|
|
2015-04-24 10:10:37 +00:00
|
|
|
_notifyCallEnded: function(aCall) {
|
2013-09-07 06:19:57 +00:00
|
|
|
let duration = ("started" in aCall && typeof aCall.started == "number") ?
|
|
|
|
new Date().getTime() - aCall.started : 0;
|
2014-07-17 11:18:28 +00:00
|
|
|
|
2015-04-24 10:10:37 +00:00
|
|
|
gTelephonyMessenger.notifyCallEnded(aCall.clientId,
|
2014-10-20 08:50:57 +00:00
|
|
|
aCall.number,
|
|
|
|
this._cdmaCallWaitingNumber,
|
|
|
|
aCall.isEmergency,
|
|
|
|
duration,
|
|
|
|
aCall.isOutgoing,
|
|
|
|
aCall.hangUpLocal);
|
2014-07-17 11:18:28 +00:00
|
|
|
|
2014-10-20 08:50:57 +00:00
|
|
|
// Clear cache of this._cdmaCallWaitingNumber after call disconnected.
|
|
|
|
this._cdmaCallWaitingNumber = null;
|
2015-04-24 10:10:37 +00:00
|
|
|
},
|
2013-09-07 06:19:57 +00:00
|
|
|
|
2015-04-24 10:10:37 +00:00
|
|
|
/**
|
|
|
|
* Disconnect calls by updating their states. Sometimes, it may cause other
|
|
|
|
* calls being disconnected as well.
|
|
|
|
*
|
|
|
|
* @return Array a list of calls we need to fire callStateChange
|
|
|
|
*/
|
|
|
|
_disconnectCalls: function(aClientId, aCalls,
|
|
|
|
aFailCause = RIL.GECKO_CALL_ERROR_NORMAL_CALL_CLEARING) {
|
|
|
|
if (DEBUG) debug("_disconnectCalls: " + JSON.stringify(aCalls));
|
|
|
|
|
2015-09-15 00:03:00 +00:00
|
|
|
// In addition to the disconnected call itself, its decedent calls should be
|
|
|
|
// treated as disconnected calls as well.
|
2015-04-24 10:10:37 +00:00
|
|
|
let disconnectedCalls = aCalls.slice();
|
|
|
|
for (let call in aCalls) {
|
|
|
|
while (call.childId) {
|
|
|
|
call = this._currentCalls[aClientId][call.childId];
|
|
|
|
disconnectedCalls.push(call);
|
2014-02-21 09:46:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-24 10:10:37 +00:00
|
|
|
// Store unique value in the list.
|
2015-05-21 03:45:09 +00:00
|
|
|
disconnectedCalls = [...new Set(disconnectedCalls)];
|
2015-03-24 10:04:49 +00:00
|
|
|
|
2015-04-24 10:10:37 +00:00
|
|
|
let callsForStateChanged = [];
|
2013-12-02 10:51:54 +00:00
|
|
|
|
2015-04-24 10:10:37 +00:00
|
|
|
disconnectedCalls.forEach(call => {
|
|
|
|
call.state = nsITelephonyService.CALL_STATE_DISCONNECTED;
|
2015-04-28 03:28:00 +00:00
|
|
|
call.disconnectedReason = aFailCause;
|
2015-04-24 10:10:37 +00:00
|
|
|
|
2015-09-15 00:03:00 +00:00
|
|
|
let parentCall = this._currentCalls[aClientId][call.parentId];
|
|
|
|
if (parentCall) {
|
2015-04-24 10:10:37 +00:00
|
|
|
delete parentCall.childId;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._notifyCallEnded(call);
|
|
|
|
|
2015-04-28 03:28:00 +00:00
|
|
|
callsForStateChanged.push(call);
|
2015-04-24 10:10:37 +00:00
|
|
|
|
|
|
|
delete this._currentCalls[aClientId][call.callIndex];
|
|
|
|
});
|
|
|
|
|
|
|
|
return callsForStateChanged;
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle an incoming call.
|
|
|
|
*
|
|
|
|
* Not much is known about this call at this point, but it's enough
|
|
|
|
* to start bringing up the Phone app already.
|
|
|
|
*/
|
2014-01-13 02:44:40 +00:00
|
|
|
notifyCallRing: function() {
|
2013-10-28 06:07:28 +00:00
|
|
|
// We need to acquire a CPU wake lock to avoid the system falling into
|
|
|
|
// the sleep mode when the RIL handles the incoming call.
|
|
|
|
this._acquireCallRingWakeLock();
|
2013-09-07 06:19:57 +00:00
|
|
|
|
2014-10-20 08:50:57 +00:00
|
|
|
gTelephonyMessenger.notifyNewCall();
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2015-03-24 10:04:49 +00:00
|
|
|
* Handle current calls reported from RIL.
|
|
|
|
*
|
|
|
|
* @param aCalls call from RIL, which contains:
|
|
|
|
* state, callIndex, toa, isMT, number, numberPresentation, name,
|
|
|
|
* namePresentation.
|
2013-09-07 06:19:57 +00:00
|
|
|
*/
|
2015-03-24 10:04:49 +00:00
|
|
|
notifyCurrentCalls: function(aClientId, aCalls) {
|
|
|
|
// Check whether there is a removed call.
|
|
|
|
let hasRemovedCalls = () => {
|
|
|
|
let newIndexes = new Set(Object.keys(aCalls));
|
|
|
|
for (let i in this._currentCalls[aClientId]) {
|
|
|
|
if (!newIndexes.has(i)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
2013-09-07 06:19:57 +00:00
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
// If there are removedCalls, we should fetch the failCause first.
|
|
|
|
if (!hasRemovedCalls()) {
|
|
|
|
this._handleCurrentCalls(aClientId, aCalls);
|
|
|
|
} else {
|
|
|
|
this._sendToRilWorker(aClientId, "getFailCause", null, response => {
|
|
|
|
this._handleCurrentCalls(aClientId, aCalls, response.failCause);
|
|
|
|
});
|
2014-02-21 09:46:58 +00:00
|
|
|
}
|
2015-03-24 10:04:49 +00:00
|
|
|
},
|
2014-02-21 09:46:58 +00:00
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
_handleCurrentCalls: function(aClientId, aCalls,
|
|
|
|
aFailCause = RIL.GECKO_CALL_ERROR_NORMAL_CALL_CLEARING) {
|
|
|
|
if (DEBUG) debug("handleCurrentCalls: " + JSON.stringify(aCalls) +
|
|
|
|
", failCause: " + aFailCause);
|
|
|
|
|
|
|
|
let changedCalls = new Set();
|
|
|
|
let removedCalls = new Set();
|
|
|
|
|
|
|
|
let allIndexes = new Set([...Object.keys(this._currentCalls[aClientId]),
|
|
|
|
...Object.keys(aCalls)]);
|
|
|
|
|
|
|
|
for (let i of allIndexes) {
|
|
|
|
let call = this._currentCalls[aClientId][i];
|
|
|
|
let rilCall = aCalls[i];
|
|
|
|
|
|
|
|
// Determine the change of call.
|
|
|
|
if (call && !rilCall) { // removed.
|
|
|
|
removedCalls.add(call);
|
|
|
|
} else if (call && rilCall) { // changed.
|
|
|
|
if (this._updateCallFromRil(call, rilCall)) {
|
|
|
|
changedCalls.add(call);
|
|
|
|
}
|
|
|
|
} else { // !call && rilCall. added.
|
|
|
|
this._currentCalls[aClientId][i] = call = new Call(aClientId, i);
|
|
|
|
this._updateCallFromRil(call, rilCall);
|
|
|
|
changedCalls.add(call);
|
|
|
|
|
|
|
|
// Handle ongoingDial.
|
|
|
|
if (this._ongoingDial && this._ongoingDial.clientId === aClientId &&
|
|
|
|
call.state !== nsITelephonyService.CALL_STATE_INCOMING) {
|
|
|
|
this._ongoingDial.callback.notifyDialCallSuccess(aClientId, i,
|
|
|
|
call.number);
|
|
|
|
this._ongoingDial = null;
|
|
|
|
}
|
|
|
|
}
|
2013-09-07 06:19:57 +00:00
|
|
|
}
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
// For correct conference detection, we should mark removedCalls as
|
|
|
|
// DISCONNECTED first.
|
2015-04-24 10:10:37 +00:00
|
|
|
let disconnectedCalls = this._disconnectCalls(aClientId, [...removedCalls], aFailCause);
|
|
|
|
disconnectedCalls.forEach(call => changedCalls.add(call));
|
2015-03-24 10:04:49 +00:00
|
|
|
|
|
|
|
// Detect conference and update isConference flag.
|
2015-04-24 10:10:37 +00:00
|
|
|
let [newConferenceState, conferenceChangedCalls] = this._updateConference(aClientId);
|
|
|
|
conferenceChangedCalls.forEach(call => changedCalls.add(call));
|
2014-08-11 06:48:00 +00:00
|
|
|
|
2015-04-24 10:10:37 +00:00
|
|
|
this._handleCallStateChanged(aClientId, [...changedCalls]);
|
2014-04-16 11:43:08 +00:00
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
this._updateAudioState(aClientId);
|
|
|
|
|
2014-08-22 07:26:00 +00:00
|
|
|
// Handle cached dial request.
|
2015-03-24 10:04:49 +00:00
|
|
|
if (this._cachedDialRequest && !this._isActive(aClientId)) {
|
2014-08-22 07:26:00 +00:00
|
|
|
if (DEBUG) debug("All calls held. Perform the cached dial request.");
|
|
|
|
|
2014-09-22 05:36:00 +00:00
|
|
|
let request = this._cachedDialRequest;
|
2015-03-24 10:04:49 +00:00
|
|
|
this._sendDialCallRequest(request.clientId, request.options,
|
|
|
|
request.callback);
|
2014-09-22 05:36:00 +00:00
|
|
|
this._cachedDialRequest = null;
|
2014-08-22 07:26:00 +00:00
|
|
|
}
|
2015-03-24 10:04:49 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle call state changes.
|
|
|
|
*/
|
2015-04-24 10:10:37 +00:00
|
|
|
_handleCallStateChanged: function(aClientId, aCalls) {
|
|
|
|
if (DEBUG) debug("handleCallStateChanged: " + JSON.stringify(aCalls));
|
2015-03-24 10:04:49 +00:00
|
|
|
|
2015-08-06 08:20:00 +00:00
|
|
|
if (aCalls.length === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-04-24 10:10:37 +00:00
|
|
|
if (aCalls.some(call => call.state == nsITelephonyService.CALL_STATE_DIALING)) {
|
2015-03-24 10:04:49 +00:00
|
|
|
gTelephonyMessenger.notifyNewCall();
|
|
|
|
}
|
2014-08-22 07:26:00 +00:00
|
|
|
|
2015-04-24 10:10:37 +00:00
|
|
|
let allInfo = aCalls.map(call => new TelephonyCallInfo(call));
|
|
|
|
this._notifyAllListeners("callStateChanged", [allInfo.length, allInfo]);
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2014-04-16 11:43:08 +00:00
|
|
|
notifyCdmaCallWaiting: function(aClientId, aCall) {
|
2013-10-28 06:07:28 +00:00
|
|
|
// We need to acquire a CPU wake lock to avoid the system falling into
|
|
|
|
// the sleep mode when the RIL handles the incoming call.
|
|
|
|
this._acquireCallRingWakeLock();
|
|
|
|
|
2014-02-21 09:46:58 +00:00
|
|
|
let call = this._currentCalls[aClientId][CDMA_SECOND_CALL_INDEX];
|
|
|
|
if (call) {
|
|
|
|
// TODO: Bug 977503 - B2G RIL: [CDMA] update callNumber when a waiting
|
|
|
|
// call comes after a 3way call.
|
2015-04-24 10:10:37 +00:00
|
|
|
this._removeCdmaSecondCall(aClientId);
|
2014-02-21 09:46:58 +00:00
|
|
|
}
|
2014-07-17 11:18:28 +00:00
|
|
|
|
|
|
|
this._cdmaCallWaitingNumber = aCall.number;
|
|
|
|
|
2014-04-16 11:43:08 +00:00
|
|
|
this._notifyAllListeners("notifyCdmaCallWaiting", [aClientId,
|
|
|
|
aCall.number,
|
|
|
|
aCall.numberPresentation,
|
|
|
|
aCall.name,
|
|
|
|
aCall.namePresentation]);
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2015-03-24 10:04:49 +00:00
|
|
|
notifySupplementaryService: function(aClientId, aNumber, aNotification) {
|
2013-09-07 06:19:57 +00:00
|
|
|
let notification = this._convertRILSuppSvcNotification(aNotification);
|
2015-03-24 10:04:49 +00:00
|
|
|
|
|
|
|
// Get the target call object for this notification.
|
|
|
|
let callIndex = -1;
|
|
|
|
|
|
|
|
let indexes = Object.keys(this.currentCalls);
|
|
|
|
if (indexes.length === 1) {
|
|
|
|
// Only one call exists. This should be the target.
|
|
|
|
callIndex = indexes[0];
|
|
|
|
} else {
|
|
|
|
// Find the call in |currentCalls| by the given number.
|
|
|
|
if (aNumber) {
|
|
|
|
for (let i in this._currentCalls) {
|
|
|
|
let call = this._currentCalls[aClientId][i];
|
|
|
|
if (call.number === aNumber) {
|
|
|
|
callIndex = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-07 06:19:57 +00:00
|
|
|
this._notifyAllListeners("supplementaryServiceNotification",
|
2015-03-24 10:04:49 +00:00
|
|
|
[aClientId, callIndex, notification]);
|
2013-09-07 06:19:57 +00:00
|
|
|
},
|
|
|
|
|
2014-10-15 06:51:00 +00:00
|
|
|
notifyUssdReceived: function(aClientId, aMessage, aSessionEnded) {
|
|
|
|
if (DEBUG) {
|
|
|
|
debug("notifyUssdReceived for " + aClientId + ": " +
|
|
|
|
aMessage + " (sessionEnded : " + aSessionEnded + ")");
|
|
|
|
}
|
|
|
|
|
2015-04-30 14:45:40 +00:00
|
|
|
let oldSession = this._ussdSessions[aClientId];
|
2015-08-28 08:39:57 +00:00
|
|
|
this._ussdSessions[aClientId] =
|
|
|
|
aSessionEnded ? USSD_SESSION_DONE : USSD_SESSION_ONGOING;
|
|
|
|
|
|
|
|
// We suppress the empty message only when the session is not changed and
|
|
|
|
// is not alive. See Bug 1057455, 1198676.
|
|
|
|
// Moreover, we should allow a notification initiated by network
|
|
|
|
// in which further response is not required.
|
|
|
|
// See |5.2.2 Actions at the UE| in 3GPP TS 22.090:
|
|
|
|
// "
|
|
|
|
// The network may explicitly indicate to the UE that a response
|
|
|
|
// from the user is required. ...
|
|
|
|
// If the network does not indicate that a response is required,
|
|
|
|
// then the normal MMI procedures on the UE continue to apply.
|
|
|
|
// "
|
|
|
|
if (oldSession != USSD_SESSION_ONGOING &&
|
|
|
|
this._ussdSessions[aClientId] != USSD_SESSION_ONGOING &&
|
|
|
|
!aMessage) {
|
2015-04-30 14:45:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-21 16:35:00 +00:00
|
|
|
gTelephonyMessenger.notifyUssdReceived(aClientId, aMessage, aSessionEnded);
|
2014-09-22 05:36:00 +00:00
|
|
|
},
|
|
|
|
|
2013-09-07 06:19:57 +00:00
|
|
|
/**
|
|
|
|
* nsIObserver interface.
|
|
|
|
*/
|
|
|
|
|
2014-01-13 02:44:40 +00:00
|
|
|
observe: function(aSubject, aTopic, aData) {
|
2013-09-07 06:19:57 +00:00
|
|
|
switch (aTopic) {
|
2013-10-24 08:14:59 +00:00
|
|
|
case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
|
|
|
|
if (aData === kPrefRilDebuggingEnabled) {
|
2013-09-07 06:19:57 +00:00
|
|
|
this._updateDebugFlag();
|
2014-02-21 09:46:58 +00:00
|
|
|
} else if (aData === kPrefDefaultServiceId) {
|
2013-10-24 08:15:06 +00:00
|
|
|
this.defaultServiceId = this._getDefaultServiceId();
|
2013-09-07 06:19:57 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-10-24 08:14:59 +00:00
|
|
|
case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
|
2013-10-28 06:07:28 +00:00
|
|
|
// Release the CPU wake lock for handling the incoming call.
|
|
|
|
this._releaseCallRingWakeLock();
|
2013-09-07 06:19:57 +00:00
|
|
|
|
2013-10-24 08:14:59 +00:00
|
|
|
Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
2013-09-07 06:19:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-13 07:26:16 +00:00
|
|
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TelephonyService]);
|