Repository navigation
Expand file tree
/
Copy pathicc_menu.js
More file actions
88 lines (75 loc) · 2.67 KB
/
Copy pathicc_menu.js
File metadata and controls
88 lines (75 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* -*- Mode: js; js-indent-level: 2; indent-tabs-mode: nil -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
'use strict';
(function() {
function executeICCCmd(iccCommand) {
if (!iccCommand)
return;
// Clear cache
var reqIccData = window.navigator.mozSettings.createLock().set({
'icc.data': null
});
reqIccData. icc_getIccData() {
DUMP('ICC Cache cleared');
};
// Open ICC section
DUMP('ICC command to execute: ', iccCommand);
Settings.currentPanel = '#icc';
setTimeout(function() {
var event = new CustomEvent('stkasynccommand', {
detail: { 'command': iccCommand }
});
window.dispatchEvent(event);
}, 2000);
}
setTimeout(function updateStkMenu() {
DUMP('Showing STK main menu');
// XXX https://bugzilla.mozilla.org/show_bug.cgi?id=844727
// We should use Settings.settingsCache first
var settings = Settings.mozSettings;
var lock = settings.createLock();
function showStkEntry(menu) {
if (!menu || !menu.items ||
(menu.items.length == 1 && menu.items[0] === null)) {
DUMP('No STK available - exit');
document.getElementById('icc-mainheader').hidden = true;
document.getElementById('icc-mainentry').hidden = true;
return;
}
// update and show the entry in settings
DUMP('STK Main App Menu title: ' + menu.title);
document.getElementById('menuItem-icc').textContent = menu.title;
document.getElementById('icc-mainheader').hidden = false;
document.getElementById('icc-mainentry').hidden = false;
}
// Check if SIM card sends an Applications menu
var reqApplications = lock.get('icc.applications');
reqApplications. icc_getApplications() {
var json = reqApplications.result['icc.applications'];
var menu = json && JSON.parse(json);
showStkEntry(menu);
};
settings.addObserver('icc.applications',
function icc_getApplications(event) {
var json = event.settingValue;
var menu = json && JSON.parse(json);
showStkEntry(menu);
});
// Check if there are pending STK commands
var reqIccData = lock.get('icc.data');
reqIccData. icc_getIccData() {
var cmd = reqIccData.result['icc.data'];
if (cmd) {
DUMP('ICC async command (launcher)');
executeICCCmd(JSON.parse(cmd));
}
};
settings.addObserver('icc.data', function(event) {
var value = event.settingValue;
if (value) {
DUMP('ICC async command while settings running: ', value);
executeICCCmd(JSON.parse(value));
}
});
});
})();