private void InvalidateV2Signature() { if (_v2SigningEnabled) { _v2SignaturePending = true; _addV2SignatureRequest = null; } }
/// <summary> /// Indicates to this engine that the ZIP sections comprising the output APK have been output. /// /// The provided data sources are guaranteed to not be used by the engine after this method terminates. /// </summary> /// <param name="zipEntries">the section of ZIP archive containing Local File Header records and data of /// the ZIP entries.In a well-formed archive, this section starts at the start of the /// archive and extends all the way to the ZIP Central Directory. /// </param> /// <param name="zipCentralDirectory">ZIP Central Directory section</param> /// <param name="zipEocd">ZIP End of Central Directory (EoCD) record /// </param> /// <returns> /// request to add an APK Signing Block to the output or {@code null} if the output must /// not contain an APK Signing Block.The request must be fulfilled before <see cref="OutputDone"/> is invoked. /// </returns> public IOutputApkSigningBlockRequest OutputZipSections(Stream zipEntries, Stream zipCentralDirectory, Stream zipEocd) { CheckV1SigningDoneIfEnabled(); if (!_v2SigningEnabled) { return(null); } InvalidateV2Signature(); var apkSigningBlock = V2SchemeSigner.GenerateApkSigningBlock(zipEntries, zipCentralDirectory, zipEocd, _v2SignerConfigs); _addV2SignatureRequest = new OutputApkSigningBlockRequestImpl(apkSigningBlock); return(_addV2SignatureRequest); }
private void CheckV2SigningDoneIfEnabled() { if (!_v2SignaturePending) { return; } if (_addV2SignatureRequest == null) { throw new InvalidOperationException( "v2 signature (APK Signature Scheme v2 signature) not yet generated." + " Skipped outputZipSections()?"); } if (!_addV2SignatureRequest.IsDone) { throw new InvalidOperationException( "v2 signature (APK Signature Scheme v2 signature) addition requested by" + " outputZipSections() hasn't been fulfilled yet"); } _addV2SignatureRequest = null; _v2SignaturePending = false; }