当前位置: 首页>>代码示例>>Java>>正文


Java DataSource.size方法代码示例

本文整理汇总了Java中com.android.apksig.util.DataSource.size方法的典型用法代码示例。如果您正苦于以下问题:Java DataSource.size方法的具体用法?Java DataSource.size怎么用?Java DataSource.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.apksig.util.DataSource的用法示例。


在下文中一共展示了DataSource.size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: inputApkSigningBlock

import com.android.apksig.util.DataSource; //导入方法依赖的package包/类
@Override
public void inputApkSigningBlock(DataSource apkSigningBlock) {
    checkNotClosed();

    if ((apkSigningBlock == null) || (apkSigningBlock.size() == 0)) {
        return;
    }

    if (mOtherSignersSignaturesPreserved) {
        // TODO: Preserve blocks other than APK Signature Scheme v2 blocks of signers configured
        // in this engine.
        return;
    }
    // TODO: Preserve blocks other than APK Signature Scheme v2 blocks.
}
 
开发者ID:F8LEFT,项目名称:FApkSigner,代码行数:16,代码来源:DefaultApkSignerEngine.java

示例2: findZipEndOfCentralDirectoryRecord

import com.android.apksig.util.DataSource; //导入方法依赖的package包/类
/**
 * Returns the ZIP End of Central Directory record of the provided ZIP file.
 *
 * @return contents of the ZIP End of Central Directory record and the record's offset in the
 *         file or {@code null} if the file does not contain the record.
 *
 * @throws IOException if an I/O error occurs while reading the file.
 */
public static Pair<ByteBuffer, Long> findZipEndOfCentralDirectoryRecord(DataSource zip)
        throws IOException {
    // ZIP End of Central Directory (EOCD) record is located at the very end of the ZIP archive.
    // The record can be identified by its 4-byte signature/magic which is located at the very
    // beginning of the record. A complication is that the record is variable-length because of
    // the comment field.
    // The algorithm for locating the ZIP EOCD record is as follows. We search backwards from
    // end of the buffer for the EOCD record signature. Whenever we find a signature, we check
    // the candidate record's comment length is such that the remainder of the record takes up
    // exactly the remaining bytes in the buffer. The search is bounded because the maximum
    // size of the comment field is 65535 bytes because the field is an unsigned 16-bit number.

    long fileSize = zip.size();
    if (fileSize < ZIP_EOCD_REC_MIN_SIZE) {
        return null;
    }

    // Optimization: 99.99% of APKs have a zero-length comment field in the EoCD record and thus
    // the EoCD record offset is known in advance. Try that offset first to avoid unnecessarily
    // reading more data.
    Pair<ByteBuffer, Long> result = findZipEndOfCentralDirectoryRecord(zip, 0);
    if (result != null) {
        return result;
    }

    // EoCD does not start where we expected it to. Perhaps it contains a non-empty comment
    // field. Expand the search. The maximum size of the comment field in EoCD is 65535 because
    // the comment length field is an unsigned 16-bit number.
    return findZipEndOfCentralDirectoryRecord(zip, UINT16_MAX_VALUE);
}
 
开发者ID:F8LEFT,项目名称:FApkSigner,代码行数:39,代码来源:ZipUtils.java


注:本文中的com.android.apksig.util.DataSource.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。