-
Notifications
You must be signed in to change notification settings - Fork 0
/
w2d.js
76 lines (74 loc) · 2.23 KB
/
w2d.js
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
/* document.addEventListener("click", (e) => {
var id = e.target.id;
if (id) openMenu(id);
}, true); */
/** Invoke configure mozActivity/webActivity and redirect user to a Settings page
*
* @author Tom Barrasso <[email protected]>
* @author Luxferre
* @author the Gaia Team at Mozilla
* @author KaiOS Technologies
* @param section: section ID for the page in the Settings app
* @implements mozActivity (KaiOS 2.5)
* @implements webActivity (KaiOS 3 and later)
* @see https://gitlab.com/project-pris/system/-/blob/master/src/system/b2g/webapps/settings.gaiamobile.org/src/index.html?ref_type=heads
* @see https://gitlab.com/project-pris/system/-/tree/master/src/system/b2g/webapps/settings.gaiamobile.org/src/elements?ref_type=heads
*/
function openMenu(section) {
// KaiOS 2.5
if (window.MozActivity) {
var act = new MozActivity({
name: "configure",
data: {
target: "device",
section: section,
},
});
act.onerror = function (e) {
console.error(act, e);
window.alert("Error:", JSON.stringify(act), e);
};
}
// KaiOS 3 and later
else if (window.WebActivity) {
var act = new WebActivity("configure", {
target: "device",
section: section,
});
act.start().catch(function (e) {
console.error(e, act);
window.alert("Error: " + e);
});
}
// Not a KaiOS device?
else {
window.alert('It appears your device doesn\'t support the mozActivity or webActivity API. Please open this page on a KaiOS device for this function to work.');
}
};
/** Configure adbd port to 5555 for wireless ADB connection
*
* @requires navigator.engmodeExtension
* @requires navigator.jrdExtension
* @requires navigator.kaiosExtension
*/
function wadb() {
var masterExt = navigator.engmodeExtension || navigator.jrdExtension || navigator.kaiosExtension;
if (!masterExt) {
window.alert('No supported extension found for configuring adbd.');
return;
}
var propSet = {
'service.adb.tcp.port': 5555,
'ctl.stop': 'adbd',
'ctl.start': 'adbd'
};
try {
for (var key in propSet) {
masterExt.setPropertyValue(key, propSet[key]);
}
window.alert('ADB port has been set to 5555.');
} catch (e) {
console.error('Error setting adbd properties:', e);
window.alert('Failed to set adbd properties. Please try again.');
}
}