From 832e5f81ec48eef50a2ca5789983b8d01ec0dd01 Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Tue, 1 Nov 2022 20:08:35 +0000 Subject: [PATCH] Revert "Revert "Compress .so files for PackageManager to reclaim the space"" This reverts commit ad0c6b5d8c24180569e6a38a2fd56a26a40dcf5d. 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 --- ...m_android_internal_content_NativeLibraryHelper.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp index 2cd9f8966bb28..6762e45d0b79d 100644 --- a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp +++ b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -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);