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

Commit 980a3d60 authored by Pawan Wagh's avatar Pawan Wagh
Browse files

Add runtime flag to zygote

Add runtime flag to zygote to enable page size compat
mode for application which will be started. Based on the runtime
flag, compat mode will be set in linker

Test: atest -c FileSystemUtilsTests
Test: Install 4KB aligned app and see the dialog on 16 KB device,
Test that app is working in compat mode
Bug: 371049373

Change-Id: Ibd796cedf9d996af6114e76310c92be23fd6a47e
parent 9fd0c6a7
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -201,6 +201,9 @@ public final class Zygote {
     */
    public static final int DEBUG_ENABLE_PTRACE = 1 << 25;

    /** Load 4KB ELF files on 16KB device using appcompat mode */
    public static final int ENABLE_PAGE_SIZE_APP_COMPAT = 1 << 26;

    /** No external storage should be mounted. */
    public static final int MOUNT_EXTERNAL_NONE = IVold.REMOUNT_MODE_NONE;
    /** Default external storage should be mounted. */
+8 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@

#if defined(__BIONIC__)
extern "C" void android_reset_stack_guards();
extern "C" void android_set_16kb_appcompat_mode(bool enable_app_compat);
#endif

namespace {
@@ -350,6 +351,7 @@ enum RuntimeFlags : uint32_t {
    NATIVE_HEAP_ZERO_INIT_ENABLED = 1 << 23,
    PROFILEABLE = 1 << 24,
    DEBUG_ENABLE_PTRACE = 1 << 25,
    ENABLE_PAGE_SIZE_APP_COMPAT = 1 << 26,
};

enum UnsolicitedZygoteMessageTypes : uint32_t {
@@ -2117,6 +2119,12 @@ static void SpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray gids,
    SetCapabilities(permitted_capabilities, effective_capabilities, permitted_capabilities,
                    fail_fn);

    if ((runtime_flags & RuntimeFlags::ENABLE_PAGE_SIZE_APP_COMPAT) != 0) {
        android_set_16kb_appcompat_mode(true);
        // Now that we've used the flag, clear it so that we don't pass unknown flags to the ART
        // runtime.
        runtime_flags &= ~RuntimeFlags::ENABLE_PAGE_SIZE_APP_COMPAT;
    }
    __android_log_close();
    AStatsSocket_close();