Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #22880 from frsela/STK/Bug1026556
Browse files Browse the repository at this point in the history
Bug 1026556 - Stk Timer Management Proactive Command error conditions not supported, r=timdream
  • Loading branch information
Fernando Rodríguez Sela committed Aug 27, 2014
2 parents 111257a + 467737c commit 66c5ef5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 17 deletions.
12 changes: 12 additions & 0 deletions apps/system/js/icc.js
Expand Up @@ -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',
Expand Down
54 changes: 37 additions & 17 deletions apps/system/js/icc_worker.js
Expand Up @@ -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;
}
},
Expand Down

0 comments on commit 66c5ef5

Please sign in to comment.