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

Commit c1f14111 authored by Jerome Gaillard's avatar Jerome Gaillard Committed by Brett Chabot
Browse files

Resubmit of 'Allow loading of host runtime for Windows"

This makes the loading of host runtime dependent on a Java system
property instead of simply ignoring it for Windows. By default, this
will be loaded (keeping the current behaviour working for non windows platforms).

But setting use_base_native_hostruntime to false will allow the host runtime to be
skipped when libandroid_runtime is loaded.

Flag: NONE host-only change
Bug: 340885449
Test: atest RavenwoodCoreTest
Change-Id: Idaf33dda2c114732ea4862c8ec203907b8e93042
parent 853186b4
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -262,7 +262,8 @@ static void* mmapFile(const char* dataFilePath) {
}

// returns result from java.lang.System.getProperty
static string getJavaProperty(JNIEnv* env, const char* property_name) {
static string getJavaProperty(JNIEnv* env, const char* property_name,
                              const char* defaultValue = "") {
    jclass system = FindClassOrDie(env, "java/lang/System");
    jmethodID getPropertyMethod =
            GetStaticMethodIDOrDie(env, system, "getProperty",
@@ -270,7 +271,7 @@ static string getJavaProperty(JNIEnv* env, const char* property_name) {

    auto jString = (jstring)env->CallStaticObjectMethod(system, getPropertyMethod,
                                                        env->NewStringUTF(property_name),
                                                        env->NewStringUTF(""));
                                                        env->NewStringUTF(defaultValue));
    ScopedUtfChars chars(env, jString);
    return string(chars.c_str());
}
@@ -430,7 +431,6 @@ public:

} // namespace android

#ifndef _WIN32
using namespace android;

JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) {
@@ -439,12 +439,14 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) {
        return JNI_ERR;
    }

    string useBaseHostRuntime = getJavaProperty(env, "use_base_native_hostruntime", "true");
    if (useBaseHostRuntime == "true") {
        Vector<String8> args;
        HostRuntime runtime;

        runtime.onVmCreated(env);
        runtime.start("HostRuntime", args, false);
    }

    return JNI_VERSION_1_6;
}
#endif