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

This reverts commit ad0c6b5d8c.

Reason for revert: rolling forward the .so compression change. According to https://b.corp.google.com/issues/188859114#comment8, the underlying issue was fixed.

Bug: 254793035
Bug: 188859114
Fixes: 254793035
Fixes: 188859114

Change-Id: I4edc15d08527013206e3daf20c33ba29c87a01a2
Merged-In: I4edc15d08527013206e3daf20c33ba29c87a01a2
This commit is contained in:
Alex Buynytskyy
2022-11-01 20:08:35 +00:00
parent a2ceba2023
commit 832e5f81ec

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);