當前位置: 首頁>>代碼示例>>Java>>正文


Java DataSink.consume方法代碼示例

本文整理匯總了Java中com.android.apksig.util.DataSink.consume方法的典型用法代碼示例。如果您正苦於以下問題:Java DataSink.consume方法的具體用法?Java DataSink.consume怎麽用?Java DataSink.consume使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.android.apksig.util.DataSink的用法示例。


在下文中一共展示了DataSink.consume方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: outputRecordWithModifiedExtra

import com.android.apksig.util.DataSink; //導入方法依賴的package包/類
/**
 * Outputs this record, replacing its extra field with the provided one, and returns returns the
 * number of bytes output.
 */
public long outputRecordWithModifiedExtra(
        DataSource sourceApk,
        ByteBuffer extra,
        DataSink output) throws IOException {
    long recordStartOffsetInSource = getStartOffsetInArchive();
    int extraStartOffsetInRecord = getExtraFieldStartOffsetInsideRecord();
    int extraSizeBytes = extra.remaining();
    int headerSize = extraStartOffsetInRecord + extraSizeBytes;
    ByteBuffer header = ByteBuffer.allocate(headerSize);
    header.order(ByteOrder.LITTLE_ENDIAN);
    sourceApk.copyTo(recordStartOffsetInSource, extraStartOffsetInRecord, header);
    header.put(extra.slice());
    header.flip();
    ZipUtils.setUnsignedInt16(header, EXTRA_LENGTH_OFFSET, extraSizeBytes);

    long outputByteCount = header.remaining();
    output.consume(header);
    long remainingRecordSize = getSize() - mDataStartOffset;
    sourceApk.feed(recordStartOffsetInSource + mDataStartOffset, remainingRecordSize, output);
    outputByteCount += remainingRecordSize;
    return outputByteCount;
}
 
開發者ID:F8LEFT,項目名稱:FApkSigner,代碼行數:27,代碼來源:LocalFileRecord.java

示例2: feed

import com.android.apksig.util.DataSink; //導入方法依賴的package包/類
@Override
public void feed(long offset, long size, DataSink sink) throws IOException {
    long sourceSize = size();
    checkChunkValid(offset, size, sourceSize);
    if (size == 0) {
        return;
    }

    long chunkOffsetInFile = mOffset + offset;
    long remaining = size;
    byte[] buf = new byte[(int) Math.min(remaining, MAX_READ_CHUNK_SIZE)];
    while (remaining > 0) {
        int chunkSize = (int) Math.min(remaining, buf.length);
        synchronized (mFile) {
            mFile.seek(chunkOffsetInFile);
            mFile.readFully(buf, 0, chunkSize);
        }
        sink.consume(buf, 0, chunkSize);
        chunkOffsetInFile += chunkSize;
        remaining -= chunkSize;
    }
}
 
開發者ID:F8LEFT,項目名稱:FApkSigner,代碼行數:23,代碼來源:RandomAccessFileDataSource.java

示例3: outputRecordWithDeflateCompressedData

import com.android.apksig.util.DataSink; //導入方法依賴的package包/類
/**
 * Outputs the specified Local File Header record with its data and returns the number of bytes
 * output.
 */
public static long outputRecordWithDeflateCompressedData(
        String name,
        int lastModifiedTime,
        int lastModifiedDate,
        byte[] compressedData,
        long crc32,
        long uncompressedSize,
        DataSink output) throws IOException {
    byte[] nameBytes = name.getBytes(StandardCharsets.UTF_8);
    int recordSize = HEADER_SIZE_BYTES + nameBytes.length;
    ByteBuffer result = ByteBuffer.allocate(recordSize);
    result.order(ByteOrder.LITTLE_ENDIAN);
    result.putInt(RECORD_SIGNATURE);
    ZipUtils.putUnsignedInt16(result,  0x14); // Minimum version needed to extract
    result.putShort(ZipUtils.GP_FLAG_EFS); // General purpose flag: UTF-8 encoded name
    result.putShort(ZipUtils.COMPRESSION_METHOD_DEFLATED);
    ZipUtils.putUnsignedInt16(result, lastModifiedTime);
    ZipUtils.putUnsignedInt16(result, lastModifiedDate);
    ZipUtils.putUnsignedInt32(result, crc32);
    ZipUtils.putUnsignedInt32(result, compressedData.length);
    ZipUtils.putUnsignedInt32(result, uncompressedSize);
    ZipUtils.putUnsignedInt16(result, nameBytes.length);
    ZipUtils.putUnsignedInt16(result, 0); // Extra field length
    result.put(nameBytes);
    if (result.hasRemaining()) {
        throw new RuntimeException("pos: " + result.position() + ", limit: " + result.limit());
    }
    result.flip();

    long outputByteCount = result.remaining();
    output.consume(result);
    outputByteCount += compressedData.length;
    output.consume(compressedData, 0, compressedData.length);
    return outputByteCount;
}
 
開發者ID:F8LEFT,項目名稱:FApkSigner,代碼行數:40,代碼來源:LocalFileRecord.java

示例4: feed

import com.android.apksig.util.DataSink; //導入方法依賴的package包/類
@Override
public void feed(long offset, long size, DataSink sink) throws IOException {
    if ((size < 0) || (size > mSize)) {
        throw new IndexOutOfBoundsException("size: " + size + ", source size: " + mSize);
    }
    sink.consume(getByteBuffer(offset, (int) size));
}
 
開發者ID:F8LEFT,項目名稱:FApkSigner,代碼行數:8,代碼來源:ByteBufferDataSource.java

示例5: feed

import com.android.apksig.util.DataSink; //導入方法依賴的package包/類
@Override
public void feed(long offset, long size, DataSink sink) throws IOException {
    checkChunkValid(offset, size);

    // checkChunkValid ensures that it's OK to cast offset and size to int.
    sink.consume(mArray, (int) offset, (int) size);
}
 
開發者ID:F8LEFT,項目名稱:FApkSigner,代碼行數:8,代碼來源:ByteArrayDataSink.java

示例6: feed

import com.android.apksig.util.DataSink; //導入方法依賴的package包/類
@Override
public void feed(long offset, long size, DataSink sink) throws IOException {
    if ((size < 0) || (size > mSize)) {
        throw new IllegalArgumentException("size: " + size + ", source size: " + mSize);
    }
    sink.consume(getByteBuffer(offset, (int) size));
}
 
開發者ID:nukc,項目名稱:ApkMultiChannelPlugin,代碼行數:8,代碼來源:ByteBufferDataSource.java


注:本文中的com.android.apksig.util.DataSink.consume方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。