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

Commit 59368e35 authored by Vince Leung's avatar Vince Leung Committed by Linux Build Service Account
Browse files

performance: update JNI to support 64 bit

Update the class to support 64 bit client
library and remove old functions no longer
relevant.

Change-Id: I5ddb3456245d2655ff72a660209b0d537d0af758
parent 2729d407
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -168,10 +168,8 @@ LOCAL_SRC_FILES:= \
	com_android_internal_net_NetworkStatsFactory.cpp \
	com_android_internal_os_Zygote.cpp \
	com_android_internal_util_VirtualRefBasePtr.cpp \
	com_android_internal_view_animation_NativeInterpolatorFactoryHelper.cpp
    ifeq ($(call is-vendor-board-platform,QCOM),true)
    LOCAL_SRC_FILES += org_codeaurora_Performance.cpp
    endif
	com_android_internal_view_animation_NativeInterpolatorFactoryHelper.cpp \
	org_codeaurora_Performance.cpp

LOCAL_C_INCLUDES += \
	$(JNI_H_INCLUDE) \
+0 −4
Original line number Diff line number Diff line
@@ -190,9 +190,7 @@ extern int register_com_android_internal_content_NativeLibraryHelper(JNIEnv *env
extern int register_com_android_internal_net_NetworkStatsFactory(JNIEnv *env);
extern int register_com_android_internal_os_Zygote(JNIEnv *env);
extern int register_com_android_internal_util_VirtualRefBasePtr(JNIEnv *env);
#ifndef NON_QCOM_TARGET
extern int register_org_codeaurora_Performance(JNIEnv *env);
#endif

static AndroidRuntime* gCurRuntime = NULL;

@@ -1366,9 +1364,7 @@ static const RegJNIRec gRegJNI[] = {
    REG_JNI(register_android_animation_PropertyValuesHolder),
    REG_JNI(register_com_android_internal_content_NativeLibraryHelper),
    REG_JNI(register_com_android_internal_net_NetworkStatsFactory),
#ifndef NON_QCOM_TARGET
    REG_JNI(register_org_codeaurora_Performance),
#endif
};

/*
+3 −40
Original line number Diff line number Diff line
@@ -39,13 +39,10 @@
#include <cutils/properties.h>
#include <utils/Log.h>

#define LIBRARY_PATH_PREFIX	"/vendor/lib/"

namespace android
{

// ----------------------------------------------------------------------------
static int  (*cpu_setoptions)(int, int)             = NULL;
static int  (*perf_lock_acq)(int, int, int[], int)  = NULL;
static int  (*perf_lock_rel)(int)                   = NULL;
static void *dlhandle                               = NULL;
@@ -56,7 +53,6 @@ static void
org_codeaurora_performance_native_init()
{
    const char *rc;
    void (*init)(void);
    char buf[PROPERTY_VALUE_MAX];
    int len;

@@ -67,24 +63,17 @@ org_codeaurora_performance_native_init()

    /* Sanity check - ensure */
    buf[PROPERTY_VALUE_MAX-1] = '\0';
    if ((strncmp(buf, LIBRARY_PATH_PREFIX, sizeof(LIBRARY_PATH_PREFIX) - 1) != 0)
        ||
        (strstr(buf, "..") != NULL)) {
    if (strstr(buf, "/") != NULL) {
        return;
    }


    dlhandle = dlopen(buf, RTLD_NOW | RTLD_LOCAL);

    if (dlhandle == NULL) {
        return;
    }

    dlerror();

    cpu_setoptions = (int (*) (int, int))dlsym(dlhandle, "perf_cpu_setoptions");
    if ((rc = dlerror()) != NULL) {
        goto cleanup;
    }

    perf_lock_acq = (int (*) (int, int, int[], int))dlsym(dlhandle, "perf_lock_acq");
    if ((rc = dlerror()) != NULL) {
        goto cleanup;
@@ -95,15 +84,9 @@ org_codeaurora_performance_native_init()
        goto cleanup;
    }

    init = (void (*) ())dlsym(dlhandle, "libqc_opt_init");
    if ((rc = dlerror()) != NULL) {
        goto cleanup;
    }
    (*init)();
    return;

cleanup:
    cpu_setoptions = NULL;
    perf_lock_acq  = NULL;
    perf_lock_rel  = NULL;
    if (dlhandle) {
@@ -115,33 +98,15 @@ cleanup:
static void
org_codeaurora_performance_native_deinit(JNIEnv *env, jobject clazz)
{
    void (*deinit)(void);

    if (dlhandle) {
        cpu_setoptions = NULL;
        perf_lock_acq  = NULL;
        perf_lock_rel  = NULL;

        deinit = (void (*) ())dlsym(dlhandle, "libqc_opt_deinit");
        if (deinit) {
            (*deinit)();
        }

        dlclose(dlhandle);
        dlhandle       = NULL;
    }
}

static jint
org_codeaurora_performance_native_cpu_setoptions(JNIEnv *env, jobject clazz,
                                                 jint reqtype, jint reqvalue)
{
    if (cpu_setoptions) {
        return (*cpu_setoptions)(reqtype, reqvalue);
    }
    return 0;
}

static jint
org_codeaurora_performance_native_perf_lock_acq(JNIEnv *env, jobject clazz, jint handle, jint duration, jintArray list)
{
@@ -173,10 +138,8 @@ org_codeaurora_performance_native_perf_lock_rel(JNIEnv *env, jobject clazz, jint
// ----------------------------------------------------------------------------

static JNINativeMethod gMethods[] = {
    {"native_cpu_setoptions", "(II)I",                 (int *)org_codeaurora_performance_native_cpu_setoptions},
    {"native_perf_lock_acq",  "(II[I)I",               (int *)org_codeaurora_performance_native_perf_lock_acq},
    {"native_perf_lock_rel",  "(I)I",                  (int *)org_codeaurora_performance_native_perf_lock_rel},
    {"native_deinit",         "()V",                   (void *)org_codeaurora_performance_native_deinit},
};