Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e99ae2c authored by Sahil Sonar's avatar Sahil Sonar 💬
Browse files

web-installer: Add progress bar for recovery sideload

parent be245ad5
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -374,7 +374,9 @@ export class ControllerManager {
  async runSideloadCommand(cmd) {
    try {
      await this.deviceManager.connect("recovery");
      await this.deviceManager.sideload(cmd.file);
      await this.deviceManager.sideload(cmd.file, (block, total) => {
        this.view.onInstalling(cmd.file, block, total);
      });
      return true;
    } catch (e) {
      throw new Error(`Sideload ${cmd.file} failed: ${e.message || e}`);
+2 −2
Original line number Diff line number Diff line
@@ -301,13 +301,13 @@ export class DeviceManager {
   * @param {string} file Filename in downloader cache.
   * @returns {Promise<any>} Sideload result from the active device.
   */
  async sideload(file) {
  async sideload(file, onProgress) {
    let blob = await this.downloader.getFile(file);
    if (!blob) {
      throw new Error(`error getting blob file ${file}`);
    }

    return await this.device.sideload(blob);
    return await this.device.sideload(blob, onProgress);
  }

  /**
+2 −1
Original line number Diff line number Diff line
@@ -49,12 +49,13 @@ export class Recovery extends Device {
   * @param {Blob} blob Zip blob to sideload.
   * @returns {Promise<void>} Resolves when sideload completes.
   */
  async sideload(blob) {
  async sideload(blob, onProgress) {
    try {
      await this._adbDevice.sideload(blob, (block, totalBlocks) => {
        if (block % 10 === 0) {
          DebugManager.log(`Sideloading block ${block}/${totalBlocks}`);
        }
        onProgress?.(block, totalBlocks);
      });
    } catch (e) {
      throw new Error(`Sideload fails ${e.message || e}`);
+1 −1
Original line number Diff line number Diff line
@@ -323,7 +323,7 @@ export default class ViewManager {
      $progress.innerText = `Installing ${name}: ${v}/${100}`;
    }
    this.DebugManager.log(
      `Installing ${name}: ${Math.round(v * 100)}/${100}`,
      `Installing ${name}: ${v}/${100}`,
      `installing-${name}`,
    );
  }