Merge "ZipUtils: use FileChannel#size" am: d0798d7117 am: f92201554a am: 0c60cbf8c0

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1765685

Change-Id: I0cdb5778b34957c712da6d0a4fd470c17df9da97
This commit is contained in:
Jooyung Han
2021-07-21 00:36:39 +00:00
committed by Automerger Merge Worker

View File

@@ -63,7 +63,8 @@ abstract class ZipUtils {
// exactly the remaining bytes in the buffer. The search is bounded because the maximum // 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. // size of the comment field is 65535 bytes because the field is an unsigned 16-bit number.
long fileSize = zip.length(); // TODO(b/193592496) RandomAccessFile#length
long fileSize = zip.getChannel().size();
if (fileSize < ZIP_EOCD_REC_MIN_SIZE) { if (fileSize < ZIP_EOCD_REC_MIN_SIZE) {
return null; return null;
} }
@@ -110,7 +111,8 @@ abstract class ZipUtils {
throw new IllegalArgumentException("maxCommentSize: " + maxCommentSize); throw new IllegalArgumentException("maxCommentSize: " + maxCommentSize);
} }
long fileSize = zip.length(); // TODO(b/193592496) RandomAccessFile#length
long fileSize = zip.getChannel().size();
if (fileSize < ZIP_EOCD_REC_MIN_SIZE) { if (fileSize < ZIP_EOCD_REC_MIN_SIZE) {
// No space for EoCD record in the file. // No space for EoCD record in the file.
return null; return null;