diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2021-01-05 04:16:42 -0500 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2021-01-05 05:34:45 -0500 |
| commit | fe063f50fec346b57453f541308ad5ffa7454398 (patch) | |
| tree | 21589782d7d2b1c08133ebc485fb506e1bc8f71d /static/js/web-install.js | |
| parent | f9328e24c1b4adf2d6e5f36a471fd504fa8dd8f7 (diff) | |
add foundation for WebUSB-based install page
Diffstat (limited to 'static/js/web-install.js')
| -rw-r--r-- | static/js/web-install.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/static/js/web-install.js b/static/js/web-install.js new file mode 100644 index 00000000..5899fc9b --- /dev/null +++ b/static/js/web-install.js @@ -0,0 +1,32 @@ +// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT + +async function doConnect() { + const webusb = await Adb.open("WebUSB"); + + console.log("connected"); + + if (webusb.isAdb()) { + console.log("adb"); + const adb = await webusb.connectAdb("host::"); + await adb.reboot("bootloader"); + return; + } + + if (webusb.isFastboot()) { + console.log("fastboot"); + const fastboot = await webusb.connectFastboot(); + await fastboot.send("flashing unlock"); + await fastboot.receive(); + } +} + +if ("usb" in navigator) { + console.log("WebUSB available"); + + const connect = document.getElementById("connect"); + connect.onclick = doConnect; +} else { + console.log("WebUSB unavailable"); +} + +// @license-end |
