diff --git a/apps/system/js/icc.js b/apps/system/js/icc.js index a65ae6012f12..910b7e796c5e 100755 --- a/apps/system/js/icc.js +++ b/apps/system/js/icc.js @@ -9,8 +9,20 @@ var icc = { _inputTimeout: 40000, _toneDefaultTimeout: 5000, + checkPlatformCompatibility: function icc_checkPlatformCompat() { + // The STK_RESULT_ACTION_CONTRADICTION_TIMER_STATE constant will be added + // in the next versions of the platform. This code avoid errors if running + // in old versions. See bug #1026556 + // Remove this workaround as soon as Gecko has the constant defined. + // Followup bug #1059166 + if (!('STK_RESULT_ACTION_CONTRADICTION_TIMER_STATE' in this._iccManager)) { + this._iccManager.STK_RESULT_ACTION_CONTRADICTION_TIMER_STATE = 0x24; + } + }, + init: function icc_init() { this._iccManager = window.navigator.mozIccManager; + checkPlatformCompatibility(); var self = this; this.clearMenuCache(function() { window.navigator.mozSetMessageHandler('icc-stkcommand', diff --git a/apps/system/js/icc_worker.js b/apps/system/js/icc_worker.js index 40a0f9c26b59..3922f5322afb 100755 --- a/apps/system/js/icc_worker.js +++ b/apps/system/js/icc_worker.js @@ -477,27 +477,47 @@ var icc_worker = { break; case icc._iccManager.STK_TIMER_DEACTIVATE: - pendingTime = a_timer.stop(options.timerId) / 1000; - icc.responseSTKCommand(message, { - timer: { - 'timerId': options.timerId, - 'timerValue': pendingTime, - 'timerAction': icc._iccManager.STK_TIMER_DEACTIVATE - }, - resultCode: icc._iccManager.STK_RESULT_OK - }); + if (a_timer.queryPendingTime(options.timerId) === 0) { + icc.responseSTKCommand(message, { + timer: { + 'timerId': options.timerId + }, + resultCode: + icc._iccManager.STK_RESULT_ACTION_CONTRADICTION_TIMER_STATE + }); + } else { + pendingTime = a_timer.stop(options.timerId) / 1000; + icc.responseSTKCommand(message, { + timer: { + 'timerId': options.timerId, + 'timerValue': pendingTime, + 'timerAction': icc._iccManager.STK_TIMER_DEACTIVATE + }, + resultCode: icc._iccManager.STK_RESULT_OK + }); + } break; case icc._iccManager.STK_TIMER_GET_CURRENT_VALUE: pendingTime = a_timer.queryPendingTime(options.timerId) / 1000; - icc.responseSTKCommand(message, { - timer: { - 'timerId': options.timerId, - 'timerValue': pendingTime, - 'timerAction': icc._iccManager.STK_TIMER_GET_CURRENT_VALUE - }, - resultCode: icc._iccManager.STK_RESULT_OK - }); + if (pendingTime === 0) { + icc.responseSTKCommand(message, { + timer: { + 'timerId': options.timerId + }, + resultCode: + icc._iccManager.STK_RESULT_ACTION_CONTRADICTION_TIMER_STATE + }); + } else { + icc.responseSTKCommand(message, { + timer: { + 'timerId': options.timerId, + 'timerValue': pendingTime, + 'timerAction': icc._iccManager.STK_TIMER_GET_CURRENT_VALUE + }, + resultCode: icc._iccManager.STK_RESULT_OK + }); + } break; } },