From c05d0bd37c359adc5064c7391b13e5d9a3b06c74 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Thu, 12 Aug 2021 10:32:07 -0700 Subject: [PATCH] Fix a bug where small manifest isn't read If a single read request contains the entire manifest, we will return right after prefixLength is computed, and the UI just hangs there. Test: load a small OTA pkg Change-Id: Idb93fdba103f9c6e7b14974b45d1aecdb2ae9168 --- tools/ota_analysis/src/services/payload.js | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tools/ota_analysis/src/services/payload.js b/tools/ota_analysis/src/services/payload.js index 2282a1797..650f284df 100644 --- a/tools/ota_analysis/src/services/payload.js +++ b/tools/ota_analysis/src/services/payload.js @@ -72,18 +72,20 @@ class OTAPayloadBlobWriter extends zip.Writer { // Once the prefixLength is non-zero, the address of manifest and signature // become known and can be read in. Otherwise the header needs to be read // in first to determine the prefixLength. - if (this.prefixLength > 0) { - if (this.offset >= this.prefixLength) { - await this.payload.readManifest(this.blob) - await this.payload.readSignature(this.blob) - } - } else if (this.offset >= _PAYLOAD_HEADER_SIZE) { + if (this.offset >= _PAYLOAD_HEADER_SIZE) { await this.payload.readHeader(this.blob) this.prefixLength = _PAYLOAD_HEADER_SIZE + this.payload.manifest_len + this.payload.metadata_signature_len - return + console.log(`Computed metadata length: ${this.prefixLength}`); + } + if (this.prefixLength > 0) { + console.log(`${this.offset}/${this.prefixLength}`); + if (this.offset >= this.prefixLength) { + await this.payload.readManifest(this.blob) + await this.payload.readSignature(this.blob) + } } // The prefix has everything we need (header, manifest, signature). Once // the offset is beyond the prefix, no need to move on. @@ -159,12 +161,12 @@ export class Payload { this.buffer.slice(this.cursor, this.cursor + size)) if (typeof view.getBigUint64 !== "function") { view.getBigUint64 = - function(offset) { - const a = BigInt(view.getUint32(offset)) - const b = BigInt(view.getUint32(offset + 4)) - const bigNumber = a * 4294967296n + b - return bigNumber - } + function (offset) { + const a = BigInt(view.getUint32(offset)) + const b = BigInt(view.getUint32(offset + 4)) + const bigNumber = a * 4294967296n + b + return bigNumber + } } this.cursor += size switch (size) {