Permalink
Browse files

Merge pull request #7418 from psiddh/input_text

Bug 827655 - Part 1: STK Get input display timeout takes too long. r=@ochameau
  • Loading branch information...
2 parents 53fc61e + dd4b0c4 commit ef83df64ced6831b80801e162399b4002cdb33d4 @ochameau ochameau committed Jan 9, 2013
Showing with 40 additions and 13 deletions.
  1. +38 −12 apps/settings/js/icc.js
  2. +2 −1 build/settings.py
@@ -21,6 +21,7 @@
var stkOpenAppName = null;
var stkLastSelectedTest = null;
var displayTextTimeout = 10000;
+ var inputTimeout = 10000;
var icc;
init();
@@ -96,6 +97,14 @@
reqDisplayTimeout.onsuccess = function icc_getDisplayTimeout() {
displayTextTimeout = reqDisplayTimeout.result['icc.displayTextTimeout'];
};
+
+ // Update inputTimeout with settings parameter
+ var reqInputTimeout =
+ window.navigator.mozSettings.createLock().get('icc.inputTextTimeout');
+ reqInputTimeout.onsuccess = function icc_getInputTimeout() {
+ inputTimeout = reqInputTimeout.result['icc.inputTextTimeout'];
+ };
+
}
/**
@@ -512,6 +521,22 @@
stkLastSelectedTest = event.target.textContent;
}
+ function calculateDurationInMS(duration) {
+ var timeout = duration.timeInterval;
+ switch (duration.timeUnit) {
+ case icc.STK_TIME_UNIT_MINUTE:
+ timeout *= 3600000;
+ break;
+ case icc.STK_TIME_UNIT_SECOND:
+ timeout *= 1000;
+ break;
+ case icc.STK_TIME_UNIT_TENTH_SECOND:
+ timeout *= 100;
+ break;
+ }
+ return timeout;
+ }
+
/**
* Show an INPUT box requiring data
* Command options like:
@@ -557,6 +582,14 @@
li.appendChild(input);
iccStkList.appendChild(li);
+ var timeoutInUse = options.duration;
+ var inputTimeOutID = setTimeout(function() {
+ debug('No response from user (Timeout)');
+ responseSTKCommand({
+ resultCode: icc.STK_RESULT_NO_RESPONSE_FROM_USER
+ });
+ }, timeoutInUse ? calculateDurationInMS(options.duration) : inputTimeout);
+
li = document.createElement('li');
var label = document.createElement('label');
var button = document.createElement('button');
@@ -566,6 +599,10 @@
options.minLength,
options.maxLength);
button.onclick = function(event) {
+ if (inputTimeOutID) {
+ clearTimeout(inputTimeOutID);
+ inputTimeOutID = null;
+ }
var value = document.getElementById('stk-item-input').value;
responseSTKCommand({
resultCode: icc.STK_RESULT_OK,
@@ -683,18 +720,7 @@
tonePlayer.loop = true;
tonePlayer.play();
- var timeout = options.duration.timeInterval;
- switch (options.duration.timeUnit) {
- case icc.STK_TIME_UNIT_MINUTE:
- timeout *= 3600000;
- break;
- case icc.STK_TIME_UNIT_SECOND:
- timeout *= 1000;
- break;
- case icc.STK_TIME_UNIT_TENTH_SECOND:
- timeout *= 100;
- break;
- }
+ timeout = calculateDurationInMS(options.duration);
setTimeout(function() {
tonePlayer.pause();
},timeout);
View
@@ -133,7 +133,8 @@
"wifi.enabled": True,
"wifi.disabled_by_wakelock": False,
"wifi.notification": False,
- "icc.displayTextTimeout": 10000
+ "icc.displayTextTimeout": 10000,
+ "icc.inputTextTimeout": 30000
}
def main():

0 comments on commit ef83df6

Please sign in to comment.