Merge "Revert "Revert "Compress .so files for PackageManager to reclaim the space"""

This commit is contained in:
TreeHugger Robot
2022-11-02 17:21:34 +00:00
committed by Android (Google) Code Review

View File

@@ -22,6 +22,7 @@
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <linux/fs.h>
#include <nativehelper/ScopedUtfChars.h>
#include <stdlib.h>
#include <string.h>
@@ -250,6 +251,16 @@ copyFileIfChanged(JNIEnv *env, void* arg, ZipFileRO* zipFile, ZipEntryRO zipEntr
return INSTALL_FAILED_CONTAINER_ERROR;
}
// If a filesystem like f2fs supports per-file compression, set the compression bit before data
// writes
unsigned int flags;
if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1) {
ALOGE("Failed to call FS_IOC_GETFLAGS on %s: %s\n", localTmpFileName, strerror(errno));
} else if ((flags & FS_COMPR_FL) == 0) {
flags |= FS_COMPR_FL;
ioctl(fd, FS_IOC_SETFLAGS, &flags);
}
if (!zipFile->uncompressEntry(zipEntry, fd)) {
ALOGE("Failed uncompressing %s to %s\n", fileName, localTmpFileName);
close(fd);