From d78ceb1e9b4c9eb767db994182a547472fcfeef7 Mon Sep 17 00:00:00 2001
From: Daniel Micay
Date: Tue, 5 Jan 2021 09:45:09 -0500
Subject: [PATCH] add stub download implementation
---
static/js/web-install.js | 34 ++++++++++++++++++++++++++++++++++
static/web-install.html | 13 +++++++++++++
2 files changed, 47 insertions(+)
diff --git a/static/js/web-install.js b/static/js/web-install.js
index 1f623fad..85cd195b 100644
--- a/static/js/web-install.js
+++ b/static/js/web-install.js
@@ -28,6 +28,36 @@ async function unlockBootloader() {
await fastboot.receive();
}
+async function downloadRelease() {
+ const webusb = await Adb.open("WebUSB");
+
+ if (!webusb.isFastboot()) {
+ console.log("error: not in fastboot mode");
+ }
+
+ console.log("connecting with fastboot");
+
+ const fastboot = await webusb.connectFastboot();
+ await fastboot.send("getvar:product");
+ const response = await fastboot.receive();
+ if (fastboot.get_cmd(response) == "FAIL") {
+ throw new Error("getvar product failed");
+ }
+ const decoder = new TextDecoder();
+ const product = decoder.decode(fastboot.get_payload(response));
+
+ const baseUrl = "https://releases.grapheneos.org/";
+ const metadata = await (await fetch(baseUrl + product + "-stable")).text();
+ const buildNumber = metadata.split(" ")[0];
+ const downloadUrl = baseUrl + product + "-factory-" + buildNumber + ".zip";
+ console.log(downloadUrl);
+
+ // Download factory images
+ //
+ // Need to do this in a way that works well with huge files, particularly since the zip needs
+ // to be extracted. Could potentially split it up on the server if this works out badly.
+}
+
async function lockBootloader() {
const webusb = await Adb.open("WebUSB");
@@ -53,6 +83,10 @@ if ("usb" in navigator) {
unlockBootloaderButton.disabled = false;
unlockBootloaderButton.onclick = unlockBootloader;
+ const downloadReleaseButton = document.getElementById("download-release");
+ downloadReleaseButton.disabled = false;
+ downloadReleaseButton.onclick = downloadRelease;
+
const lockBootloaderButton = document.getElementById("lock-bootloader");
lockBootloaderButton.disabled = false;
lockBootloaderButton.onclick = lockBootloader;
diff --git a/static/web-install.html b/static/web-install.html
index 169969ee..963b8700 100644
--- a/static/web-install.html
+++ b/static/web-install.html
@@ -139,6 +139,19 @@
confirm.
+
+
+
+ You need to obtain the GrapheneOS factory images for your device to proceed with
+ the installation process.
+
+ Press the button below to start the download:
+
+
+
+ Download not implemented yet.
+
+