summaryrefslogtreecommitdiff
path: root/include/utils/ZipFileRO.h
diff options
context:
space:
mode:
author Kenny Root <kroot@google.com> 2011-07-12 14:14:01 -0700
committer Kenny Root <kroot@google.com> 2011-07-26 10:14:58 -0700
commit66269ea6f68f2f25888ce1080c94ac782742fafc (patch)
tree0ecbefcdbecf98cbacd428a422e6a2a846ac726e /include/utils/ZipFileRO.h
parente432a0005180ba9ac2c1d7822c4761b475fddc51 (diff)
Move extract native libraries to JNI code
The built-in ZipFile class was quite a long time to find an unpack libraries. Move everything to using the libutils ZipFileRO class that goes quite a bit faster. Initial measurements are 6 times faster than the Java code. Also, read files off the disk and compare their CRC against the APK's CRC to see if we need to write the new file to disk. This also cuts down the bootup time by up to a second per APK that has native files. Change-Id: Ic464a7969a17368fb6a6b81d026888c4136c7603
Diffstat (limited to 'include/utils/ZipFileRO.h')
-rw-r--r--include/utils/ZipFileRO.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/utils/ZipFileRO.h b/include/utils/ZipFileRO.h
index 3a999797b476..547e36a09864 100644
--- a/include/utils/ZipFileRO.h
+++ b/include/utils/ZipFileRO.h
@@ -38,6 +38,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <time.h>
namespace android {
@@ -174,6 +175,20 @@ public:
size_t uncompLen, size_t compLen);
/*
+ * Utility function to convert ZIP's time format to a timespec struct.
+ */
+ static inline void zipTimeToTimespec(long when, struct tm* timespec) {
+ const long date = when >> 16;
+ timespec->tm_year = ((date >> 9) & 0x7F) + 80; // Zip is years since 1980
+ timespec->tm_mon = (date >> 5) & 0x0F;
+ timespec->tm_mday = date & 0x1F;
+
+ timespec->tm_hour = (when >> 11) & 0x1F;
+ timespec->tm_min = (when >> 5) & 0x3F;
+ timespec->tm_sec = (when & 0x1F) << 1;
+ }
+
+ /*
* Some basic functions for raw data manipulation. "LE" means
* Little Endian.
*/