Search in sources :

Example 1 with CompiledFile

use of android.aapt.pb.internal.ResourcesInternal.CompiledFile in project atlas by alibaba.

the class ApkFileListUtils method getCompiledFileMd5.

private static String getCompiledFileMd5(File file) {
    String md5;
    try (InputStream is = new BufferedInputStream(new FileInputStream(file))) {
        CodedInputStream codedInputStream = CodedInputStream.newInstance(is);
        int numFiles = codedInputStream.readRawLittleEndian32();
        // Preconditions.checkState(numFiles == 1, "inline xml not implemented yet");
        long pbSize = codedInputStream.readRawLittleEndian64();
        codedInputStream.pushLimit((int) pbSize);
        CompiledFile compiledFile = CompiledFile.parser().parsePartialFrom(codedInputStream);
        md5 = MD5Util.getFileMD5(compiledFile.getSourcePath());
        // codedInputStream.pushLimit(0);
        return md5;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) CodedInputStream(com.google.protobuf.CodedInputStream) InputStream(java.io.InputStream) CodedInputStream(com.google.protobuf.CodedInputStream) CompiledFile(android.aapt.pb.internal.ResourcesInternal.CompiledFile) UncheckedIOException(org.gradle.api.UncheckedIOException) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Aggregations

CompiledFile (android.aapt.pb.internal.ResourcesInternal.CompiledFile)1 CodedInputStream (com.google.protobuf.CodedInputStream)1 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1