OSDN Git Service

Unbreak verifying v2 signatures of large APKs.
authorAlex Klyubin <klyubin@google.com>
Fri, 18 Mar 2016 23:09:06 +0000 (16:09 -0700)
committerAlex Klyubin <klyubin@google.com>
Sat, 19 Mar 2016 00:08:46 +0000 (17:08 -0700)
commit0722ffcd0699406efe21d2bd69cc8c1708fe858c
treef7b03be63716ceb581dcc1b4efb99ec6847f542a
parent46b5258138c82692191ff261cfa7e119f963b778
Unbreak verifying v2 signatures of large APKs.

The original implementation of APK Signature Scheme v2 verification
mmapped the whole APK. This does not work on devices with limited
amount of contiguous free logical memory, especially on 32-bit
devices where logical address space is relatively small. For example,
a 500 MB APK is unlikely to mmap on a Nexus 6.

This commit fixes the issue by switching the verification strategy
to mmapping each individual 1 MB chunk of the APK, digesting it, and
then immediately munmapping. This is about 5-10% slower than mmapping
the whole APK in one go.

Bug: 27613575
Change-Id: I4167d5a7720c1bb87a0edad5d4f2607f7d554b56
core/java/android/util/apk/ApkSignatureSchemeV2Verifier.java
core/java/android/util/apk/ZipUtils.java