Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8948d071 authored by Pawan Wagh's avatar Pawan Wagh
Browse files

Flag punch hole changes with build time flag

Adding ENABLE_PUNCH_HOLES flag to enable punch hole changes in
JNI.

Test: acloud delete --all && m && acloud create --local-instance --local-image && adb logcat -c && m FileSystemUtilsTests && atest -c FileSystemUtilsTests
Bug: 301631861
Change-Id: I611893e3171e0a2334e4d49b195768cdfb57fb96
parent 1ad068f5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ soong_config_module_type {
    config_namespace: "ANDROID",
    bool_variables: [
        "release_binder_death_recipient_weak_from_jni",
        "release_package_libandroid_runtime_punch_holes",
    ],
    properties: [
        "cflags",
@@ -63,6 +64,9 @@ cc_library_shared_for_libandroid_runtime {
        release_binder_death_recipient_weak_from_jni: {
            cflags: ["-DBINDER_DEATH_RECIPIENT_WEAK_FROM_JNI"],
        },
        release_package_libandroid_runtime_punch_holes: {
            cflags: ["-DENABLE_PUNCH_HOLES"],
        },
    },

    cpp_std: "gnu++20",
+10 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@

#include <memory>

#include "com_android_internal_content_FileSystemUtils.h"
#include "core_jni_helpers.h"

#define RS_BITCODE_SUFFIX ".bc"
@@ -169,6 +170,15 @@ copyFileIfChanged(JNIEnv *env, void* arg, ZipFileRO* zipFile, ZipEntryRO zipEntr
            return INSTALL_FAILED_INVALID_APK;
        }

#ifdef ENABLE_PUNCH_HOLES
        // if library is uncompressed, punch hole in it in place
        if (!punchHolesInElf64(zipFile->getZipFileName(), offset)) {
            ALOGW("Failed to punch uncompressed elf file :%s inside apk : %s at offset: "
                  "%" PRIu64 "",
                  fileName, zipFile->getZipFileName(), offset);
        }
#endif // ENABLE_PUNCH_HOLES

        return INSTALL_SUCCEEDED;
    }