From b215636d8a059f268f754d9520feffc46de58fbe Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Mon, 5 Aug 2013 16:28:31 -0400 Subject: [PATCH] Bug 743150 - Part 3: Handle supplementary service notification in RIL. r=hsinyi --- dom/system/gonk/RILContentHelper.js | 6 +++ dom/system/gonk/RadioInterfaceLayer.js | 22 ++++++++++ dom/system/gonk/ril_consts.js | 11 +++++ dom/system/gonk/ril_worker.js | 56 +++++++++++++++++++++++++- 4 files changed, 94 insertions(+), 1 deletion(-) diff --git a/dom/system/gonk/RILContentHelper.js b/dom/system/gonk/RILContentHelper.js index c7732f43795..fba8f84e135 100644 --- a/dom/system/gonk/RILContentHelper.js +++ b/dom/system/gonk/RILContentHelper.js @@ -78,6 +78,7 @@ const RIL_IPC_MSG_NAMES = [ "RIL:VoicemailNotification", "RIL:VoicemailInfoChanged", "RIL:CallError", + "RIL:SuppSvcNotification", "RIL:CardLockResult", "RIL:CardLockRetryCount", "RIL:USSDReceived", @@ -1475,6 +1476,11 @@ RILContentHelper.prototype = { [data.callIndex, data.errorMsg]); break; } + case "RIL:SuppSvcNotification": + this._deliverEvent("_telephonyListeners", + "supplementaryServiceNotification", + [msg.json.callIndex, msg.json.notification]); + break; case "RIL:VoicemailNotification": this.handleVoicemailNotification(msg.json.data); break; diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index ed8563bef8f..4035d906d7f 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -209,6 +209,17 @@ function convertRILCallState(state) { } } +function convertRILSuppSvcNotification(notification) { + switch (notification) { + case RIL.GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD: + return nsITelephonyProvider.NOTIFICATION_REMOTE_HELD; + case RIL.GECKO_SUPP_SVC_NOTIFICATION_REMOTE_RESUMED: + return nsITelephonyProvider.NOTIFICATION_REMOTE_RESUMED; + default: + throw new Error("Unknown rilSuppSvcNotification: " + notification); + } +} + /** * Fake nsIAudioManager implementation so that we can run the telephony * code in a non-Gonk build. @@ -939,6 +950,9 @@ RadioInterface.prototype = { case "callError": this.handleCallError(message); break; + case "suppSvcNotification": + this.handleSuppSvcNotification(message); + break; case "iccOpenChannel": this.handleIccOpenChannel(message); break; @@ -1810,6 +1824,14 @@ RadioInterface.prototype = { this.clientId, message); }, + /** + * Handle supplementary service notification. + */ + handleSuppSvcNotification: function handleSuppSvcNotification(message) { + message.notification = convertRILSuppSvcNotification(message.notification); + this._sendTelephonyMessage("RIL:SuppSvcNotification", message); + }, + /** * Handle WDP port push PDU. Constructor WDP bearer information and deliver * to WapPushManager. diff --git a/dom/system/gonk/ril_consts.js b/dom/system/gonk/ril_consts.js index 6184b8b101a..a10952480cb 100644 --- a/dom/system/gonk/ril_consts.js +++ b/dom/system/gonk/ril_consts.js @@ -2767,5 +2767,16 @@ this.MCC_TABLE_FOR_MNC_LENGTH_IS_3 = [ "750" // Falkland Islands (Malvinas) ]; +// Supplementary service notifications, code2, as defined in 3GPP 27.007 7.17 +this.SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD = 2; +this.SUPP_SVC_NOTIFICATION_CODE2_RETRIEVED = 3; + +this.GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD = "RemoteHeld"; +this.GECKO_SUPP_SVC_NOTIFICATION_REMOTE_RESUMED = "RemoteResumed"; + +this.GECKO_SUPP_SVC_NOTIFICATION_FROM_CODE2 = {}; +GECKO_SUPP_SVC_NOTIFICATION_FROM_CODE2[SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD] = GECKO_SUPP_SVC_NOTIFICATION_REMOTE_HELD; +GECKO_SUPP_SVC_NOTIFICATION_FROM_CODE2[SUPP_SVC_NOTIFICATION_CODE2_RETRIEVED] = GECKO_SUPP_SVC_NOTIFICATION_REMOTE_RESUMED; + // Allow this file to be imported via Components.utils.import(). this.EXPORTED_SYMBOLS = Object.keys(this); diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index aa3b31df6c6..734fc425cdf 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -3848,6 +3848,51 @@ let RIL = { } }, + _processSuppSvcNotification: function _processSuppSvcNotification(info) { + debug("handle supp svc notification: " + JSON.stringify(info)); + + let notification = null; + let callIndex = -1; + + if (info.notificationType === 0) { + // MO intermediate result code. Refer to code1 defined in 3GPP 27.007 + // 7.17. + } else if (info.notificationType === 1) { + // MT unsolicited result code. Refer to code2 defined in 3GPP 27.007 7.17. + switch (info.code) { + case SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD: + case SUPP_SVC_NOTIFICATION_CODE2_RETRIEVED: + notification = GECKO_SUPP_SVC_NOTIFICATION_FROM_CODE2[info.code]; + break; + default: + // Notification type not supported. + return; + } + + // Get the target call object for this notification. + let currentCallIndexes = Object.keys(this.currentCalls); + if (currentCallIndexes.length === 1) { + // Only one call exists. This should be the target. + callIndex = currentCallIndexes[0]; + } else { + // Find the call in |currentCalls| by the given number. + if (info.number) { + for each (let currentCall in this.currentCalls) { + if (currentCall.number == info.number) { + callIndex = currentCall.callIndex; + break; + } + } + } + } + } + + let message = {rilMessageType: "suppSvcNotification", + notification: notification, + callIndex: callIndex}; + this.sendChromeMessage(message); + }, + _processNetworks: function _processNetworks() { let strings = Buf.readStringList(); let networks = []; @@ -6011,7 +6056,16 @@ RIL[UNSOLICITED_DATA_CALL_LIST_CHANGED] = function UNSOLICITED_DATA_CALL_LIST_CH } this[REQUEST_DATA_CALL_LIST](length, {rilRequestError: ERROR_SUCCESS}); }; -RIL[UNSOLICITED_SUPP_SVC_NOTIFICATION] = null; +RIL[UNSOLICITED_SUPP_SVC_NOTIFICATION] = function UNSOLICITED_SUPP_SVC_NOTIFICATION(length) { + let info = {}; + info.notificationType = Buf.readUint32(); + info.code = Buf.readUint32(); + info.index = Buf.readUint32(); + info.type = Buf.readUint32(); + info.number = Buf.readString(); + + this._processSuppSvcNotification(info); +}; RIL[UNSOLICITED_STK_SESSION_END] = function UNSOLICITED_STK_SESSION_END() { this.sendChromeMessage({rilMessageType: "stksessionend"});