[aapt2] Ensure all zip entry times are the same
We want them to be all the same, so that APKs are identical if its
contents are the same, regardless of the time zone of the machine that
produced them. The accompanying change in libziparchive
(Iefc7945bff0610f8a025d4887cd5644cfa3cfb3b) ensures this.
Bug: 277978832
Test: atest aapt2_tests
Change-Id: Iab000b7c74dcb06efad41a6495b73216fd2528d6
diff --git a/tools/aapt2/io/File.h b/tools/aapt2/io/File.h
index 08d497d..673d1b7 100644
--- a/tools/aapt2/io/File.h
+++ b/tools/aapt2/io/File.h
@@ -57,6 +57,11 @@
return false;
}
+ // Fills in buf with the last modification time of the file. Returns true if successful,
+ // otherwise false (i.e., the operation is not supported or the file system is unable to provide
+ // a last modification time).
+ virtual bool GetModificationTime(struct tm* buf) const = 0;
+
private:
// Any segments created from this IFile need to be owned by this IFile, so
// keep them
@@ -79,6 +84,10 @@
return file_->GetSource();
}
+ bool GetModificationTime(struct tm* buf) const override {
+ return file_->GetModificationTime(buf);
+ };
+
private:
DISALLOW_COPY_AND_ASSIGN(FileSegment);