From 308d1f7157a2a20c21c179ded5caa330883479a2 Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Thu, 5 Apr 2012 14:16:56 -0700 Subject: [PATCH] Bug 727319 - Part 2: notify SMS send failed. r=philikon --- dom/system/gonk/RadioInterfaceLayer.js | 23 ++++++++++++++++- dom/system/gonk/ril_consts.js | 5 ++++ dom/system/gonk/ril_worker.js | 35 +++++++++++++++++++++++--- 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index 38241addb012..f6fc2939d01d 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -262,6 +262,9 @@ RadioInterfaceLayer.prototype = { case "sms-delivered": this.handleSmsDelivered(message); return; + case "sms-send-failed": + this.handleSmsSendFailed(message); + return; case "datacallstatechange": this.handleDataCallState(message.datacall); break; @@ -468,7 +471,6 @@ RadioInterfaceLayer.prototype = { options.sms = sms; } - //TODO handle errors (bug 727319) gSmsRequestManager.notifySmsSent(options.requestId, sms); }, @@ -484,6 +486,25 @@ RadioInterfaceLayer.prototype = { Services.obs.notifyObservers(options.sms, kSmsDeliveredObserverTopic, null); }, + handleSmsSendFailed: function handleSmsSendFailed(message) { + debug("handleSmsSendFailed: " + JSON.stringify(message)); + + let options = this._sentSmsEnvelopes[message.envelopeId]; + if (!options) { + return; + } + delete this._sentSmsEnvelopes[message.envelopeId]; + + let error = gSmsRequestManager.UNKNOWN_ERROR; + switch (message.error) { + case RIL.ERROR_RADIO_NOT_AVAILABLE: + error = gSmsRequestManager.NO_SIGNAL_ERROR; + break; + } + + gSmsRequestManager.notifySmsSendFailed(options.requestId, error); + }, + /** * Handle data call state changes. */ diff --git a/dom/system/gonk/ril_consts.js b/dom/system/gonk/ril_consts.js index 5aa2526f34f5..6b7ec81fde15 100644 --- a/dom/system/gonk/ril_consts.js +++ b/dom/system/gonk/ril_consts.js @@ -241,6 +241,11 @@ const ERROR_SS_MODIFIED_TO_USSD = 24; const ERROR_SS_MODIFIED_TO_SS = 25; const ERROR_SUBSCRIPTION_NOT_SUPPORTED = 26; +// 3GPP 23.040 clause 9.2.3.6 TP-Message-Reference(TP-MR): +// The number of times the MS automatically repeats the SMS-SUBMIT shall be in +// the range 1 to 3 but the precise number is an implementation matter. +const SMS_RETRY_MAX = 3; + const RADIO_STATE_OFF = 0; const RADIO_STATE_UNAVAILABLE = 1; const RADIO_STATE_ON = 2; diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index 37e0abf3bb7b..6481d360f7d4 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -1026,6 +1026,10 @@ let RIL = { //TODO: verify values on 'options' + if (!options.retryCount) { + options.retryCount = 0; + } + if (options.segmentMaxSeq > 1) { if (!options.segmentSeq) { // Fist segment to send @@ -1572,7 +1576,8 @@ let RIL = { delete this._pendingSentSmsMap[message.messageRef]; if ((status >>> 5) != 0x00) { - // TODO: bug 727319 - Notify SMS send failures + // It seems unlikely to get a result code for a failure to deliver. + // Even if, we don't want to do anything with this. return PDU_FCS_OK; } @@ -1954,7 +1959,24 @@ RIL[REQUEST_RADIO_POWER] = null; RIL[REQUEST_DTMF] = null; RIL[REQUEST_SEND_SMS] = function REQUEST_SEND_SMS(length, options) { if (options.rilRequestError) { - //TODO handle errors (bug 727319) + switch (options.rilRequestError) { + case ERROR_SMS_SEND_FAIL_RETRY: + if (options.retryCount < SMS_RETRY_MAX) { + options.retryCount++; + // TODO: bug 736702 TP-MR, retry interval, retry timeout + this.sendSMS(options); + break; + } + + // Fallback to default error handling if it meets max retry count. + default: + this.sendDOMMessage({ + type: "sms-send-failed", + envelopeId: options.envelopeId, + error: options.rilRequestError, + }); + break; + } return; } @@ -2211,8 +2233,13 @@ RIL[REQUEST_DEVICE_IDENTITY] = null; RIL[REQUEST_EXIT_EMERGENCY_CALLBACK_MODE] = null; RIL[REQUEST_GET_SMSC_ADDRESS] = function REQUEST_GET_SMSC_ADDRESS(length, options) { if (options.rilRequestError) { - //TODO: notify main thread if we fail retrieving the SMSC, especially - // if there was a pending SMS (bug 727319). + if (options.body) { + this.sendDOMMessage({ + type: "sms-send-failed", + envelopeId: options.envelopeId, + error: options.rilRequestError, + }); + } return; }