forked from ferjm/b2g-js-ril
/
test.html
83 lines (68 loc) · 2.55 KB
/
test.html
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
<!DOCTYPE html>
<html>
<head>
</head>
<body onload="init();" onunload="cleanup();">
<div>
Host/Port:
<input id="host" type="text" value="localhost">
<input id="port" type="text" value="6200">
<button id="connect" onclick="connect(); return false;">Connect</button>
</div>
<p id="status"></p>
<p>Use the Web Console above to poke at the <code>RIL</code> and
<code>Phone</code> objects and see the debugging output.</p>
<script type="application/javascript;version=1.8" src="socket.js"></script>
<script type="application/javascript;version=1.8" src="ril_consts.js"></script>
<script type="application/javascript;version=1.8" src="ril_worker.js"></script>
<script type="application/javascript;version=1.8" src="dom_telephony.js"></script>
<script type="application/javascript;version=1.8">
function init() {
window.setTimeout(function () {
Cu.import("resource://gre/modules/Services.jsm");
let chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
if (!chromeWin.HUDConsoleUI.getOpenHUD()) {
chromeWin.HUDConsoleUI.toggleHUD();
}
}, 100);
}
function connect() {
if (SocketListener.connected) {
SocketListener.stop();
document.getElementById("connect").textContent = "Connect";
} else {
let host = document.getElementById("host").value;
let port = document.getElementById("port").value;
SocketListener.listen(host, port, onConnectionError);
document.getElementById("status").textContent = "";
document.getElementById("connect").textContent = "Disconnect";
}
}
function onConnectionError(error) {
document.getElementById("status").textContent = "Connection failed: " + error.message + " " + error.result;
document.getElementById("connect").textContent = "Connect";
}
function cleanup() {
if (SocketListener.connected) {
SocketListener.stop();
}
}
gRadioInterface = new nsRadioInterface(window);
navigator.mozTelephony = new Telephony(window);
navigator.mozTelephony.onradiostatechange = function (event) {
console.log("New Radio State in the DOM: " +
JSON.stringify(this.radioState));
}
navigator.mozTelephony.onsignalstrengthchange = function (event) {
console.log("New Radio State in the DOM: " +
JSON.stringify(this.signalStrength));
if (this.signalStrength.gsmSignalStrength == 99) {
return;
}
document.getElementById("signalStrength").value =
this.signalStrength.gsmSignalStrength;
}
</script>
<progress id="signalStrength" max="31" value="0"></progress>
</body>
</html>