summaryrefslogtreecommitdiff
path: root/static/js
diff options
context:
space:
mode:
authorDanny Lin <danny@kdrag0n.dev>2021-01-29 17:46:08 -0800
committerDaniel Micay <danielmicay@gmail.com>2021-01-29 22:15:04 -0500
commite582d6ca4577767ab1c869b71fc0103e2706f96f (patch)
treec801c2e8fe698406c512fa8cc2245900240e9092 /static/js
parent3f76cf5942dd9609a7a32ec2343471406d8c4785 (diff)
web-install: Implement Android reconnection callback
On Android, Chromium does not support automatic reconnection. The user must manually pair the device after every reboot in order for fastboot.js to reconnect to it. Unfortunately, this requires the user of the library to get involved because USB device connction requests are only allowed as the result of explicit user action, so we need to add a reconnect request callback for the user to handle.
Diffstat (limited to 'static/js')
-rw-r--r--static/js/web-install.js26
1 files changed, 21 insertions, 5 deletions
diff --git a/static/js/web-install.js b/static/js/web-install.js
index ed8c9fd2..660fd02e 100644
--- a/static/js/web-install.js
+++ b/static/js/web-install.js
@@ -148,6 +148,19 @@ async function downloadRelease(setProgress) {
return `Downloaded ${latestZip} release.`;
}
+async function reconnectCallback() {
+ let statusField = document.getElementById("flash-release-status");
+ statusField.textContent =
+ "In order to continue flashing, you need to reconnect the device by tapping here:";
+
+ let reconnectButton = document.getElementById("flash-reconnect-button");
+ reconnectButton.style.display = "inline-block";
+ reconnectButton.onclick = async () => {
+ await device.connect();
+ reconnectButton.style.display = "none";
+ };
+}
+
async function flashRelease(setProgress) {
await ensureConnected(setProgress);
@@ -162,11 +175,14 @@ async function flashRelease(setProgress) {
}
setProgress("Flashing release...");
- await fastboot.FactoryImages.flashZip(device, blob, true, (action, item) => {
- let userAction = fastboot.FactoryImages.USER_ACTION_MAP[action];
- let userItem = item === "avb_custom_key" ? "verified boot key" : item;
- setProgress(`${userAction} ${userItem}...`);
- });
+ await fastboot.FactoryImages.flashZip(
+ device, blob, true, reconnectCallback,
+ (action, item) => {
+ let userAction = fastboot.FactoryImages.USER_ACTION_MAP[action];
+ let userItem = item === "avb_custom_key" ? "verified boot key" : item;
+ setProgress(`${userAction} ${userItem}...`);
+ }
+ );
return `Flashed ${latestZip} to device.`;
}