Ejemplo n.º 1
0
Q_BLUETOOTH_EXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* /*reserved*/)
{
    typedef union {
        JNIEnv *nativeEnvironment;
        void *venv;
    } UnionJNIEnvToVoid;

    UnionJNIEnvToVoid uenv;
    uenv.venv = 0;

    if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_4) != JNI_OK) {
        __android_log_print(ANDROID_LOG_FATAL, logTag, "GetEnv failed");
        return -1;
    }

    JNIEnv *env = uenv.nativeEnvironment;
    if (!registerNatives(env)) {
        __android_log_print(ANDROID_LOG_FATAL, logTag, "registerNatives failed");
        return -1;
    }

    if (QT_BT_ANDROID().isDebugEnabled())
        __android_log_print(ANDROID_LOG_INFO, logTag, "Bluetooth start");

    return JNI_VERSION_1_4;
}
/**
 * This sets up the 'Gateway' java class for execution of
 * scripts.   The class's constructor takes a jlong.  This java long
 * is used to store the pointer to 'this'.  When ScriptRunner makes
 * native calls, it passes that jlong back, so that it can call the
 * methods of this C++ class.  
 */  
bool JavaBinderyImpl::setupGateway()
{
    String className = "org/inkscape/cmn/Gateway";
    if (!registerNatives(className, gatewayMethods))
        {
        return false;
        }
    jclass cls = env->FindClass(className.c_str());
    if (!cls)
        {
        err("setupGateway: cannot find class '%s' : %s",
		         className.c_str(), getException().c_str());
        return false;
		}
	jmethodID mid = env->GetMethodID(cls, "<init>", "(J)V");
	if (!mid)
        {
        err("setupGateway: cannot find constructor for '%s' : %s",
		          className.c_str(), getException().c_str());
        return false;
		}
    gatewayObj = env->NewObject(cls, mid, ((jlong)this));
    if (!gatewayObj)
        {
        err("setupGateway: cannot construct '%s' : %s",
		         className.c_str(), getException().c_str());
        return false;
		}

	msg("Gateway ready");
    return true;
}
Ejemplo n.º 3
0
void CountableOnLoad(JNIEnv* env) {
  jclass countable = env->FindClass("com/facebook/jni/Countable");
  gCountableNativePtr = env->GetFieldID(countable, "mInstance", "J");
  registerNatives(env, countable, {
    { "dispose", "()V", (void*) dispose },
  });
}
Ejemplo n.º 4
0
	/*
	 * Set some test stuff up.
	 *
	 * Returns the JNI version on success, -1 on failure.
	 */
	__attribute__ ((visibility("default"))) jint JNI_OnLoad(JavaVM* vm, void* reserved)
	{
		JNIEnv* env = NULL;
		jint result = -1;

		if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK)
		{
			LOGE("ERROR: GetEnv failed");
			goto bail;
		}
		assert(env != NULL);

		LOGD("In main JNI_OnLoad");

		if (registerNatives(env) < 0)
		{
			LOGE("ERROR: Exif native registration failed");
			goto bail;
		}

		/* success -- return valid version number */
		result = JNI_VERSION_1_4;

		bail: return result;
	}
Ejemplo n.º 5
0
jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
	JNIEnv* env = NULL;
	jint result = -1;

	LOGE("OnLoad");

	if (vm->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK) {
		goto bail;
	}

	if (!registerNatives(env,
			     "com/ti/jfm/core/JFmRx",
	                     JFmRxNative_sMethods,
			     NELEM(JFmRxNative_sMethods))) {
		goto bail;
	}

	env->GetJavaVM(&g_jVM);

	/* success -- return valid version number */
	result = JNI_VERSION_1_4;

bail:
	return result;
}
Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* /*reserved*/)
{
	__android_log_print(ANDROID_LOG_INFO,"Qt", "qt start");
	UnionJNIEnvToVoid uenv;
    uenv.venv = NULL;
	m_javaVM = 0;

    if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_4) != JNI_OK)
    {
        __android_log_print(ANDROID_LOG_FATAL,"Qt","GetEnv failed");
        return -1;
    }
    m_env = uenv.nativeEnvironment;
    if (!registerNatives(m_env))
    {
        __android_log_print(ANDROID_LOG_FATAL, "Qt", "registerNatives failed");
        return -1;
    }
	if (!saveCustomClass(m_env, customClass))
	{
		__android_log_print(ANDROID_LOG_FATAL, "Qt", "Custom registerNatives failed");
		return -1;
	}
	m_javaVM = vm;
    return JNI_VERSION_1_4;
}
Ejemplo n.º 7
0
Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/)
{
    static bool initialized = false;
    if (initialized)
        return JNI_VERSION_1_6;
    initialized = true;

    typedef union {
        JNIEnv *nativeEnvironment;
        void *venv;
    } UnionJNIEnvToVoid;

    __android_log_print(ANDROID_LOG_INFO, logTag, "Sensors start");
    UnionJNIEnvToVoid uenv;
    uenv.venv = NULL;
    javaVM = 0;

    if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_4) != JNI_OK) {
        __android_log_print(ANDROID_LOG_FATAL, logTag, "GetEnv failed");
        return -1;
    }
    JNIEnv *env = uenv.nativeEnvironment;
    if (!registerNatives(env)) {
        __android_log_print(ANDROID_LOG_FATAL, logTag, "registerNatives failed");
        return -1;
    }

    javaVM = vm;
    return JNI_VERSION_1_4;
}
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
{
//    JNIEnv* env = NULL;
//    jint result = -1;
//
//    if (vm->GetEnv( (void**) &env, JNI_VERSION_1_1) != JNI_OK) {
//        __android_log_print(ANDROID_LOG_ERROR, "tag", "load library error 1");
//        return JNI_ERR;
//    }
//    assert(env != NULL);
//
//    if (!registerNatives(env)) {
//        ALOG(ANDROID_LOG_ERROR, "tag", "load library error 2");
//        return JNI_ERR;
//    }
//    result = JNI_VERSION_1_1;
//    ALOG(ANDROID_LOG_ERROR, "tag", "load library success: %d", result);
//    return result;
	JNIEnv* env = NULL;
	jint result = -1;
	if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {//从VM中取得JNIEnv的指针
		ALOG(ANDROID_LOG_ERROR, "tag","ERROR: GetEnv failed\n");
		return JNI_ERR;
	}
	assert(env != NULL);
	if (!registerNatives(env)) {//调用动态注册的方法
		ALOG(ANDROID_LOG_ERROR, "tag","ERROR: MediaPlayer native registration failed\n");
		return JNI_ERR;
	}
	 result = JNI_VERSION_1_4;
	 ALOG(ANDROID_LOG_ERROR, "tag", "load library success: %d", result);
   return result;
}
Ejemplo n.º 9
0
Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/)
{
    typedef union {
        JNIEnv *nativeEnvironment;
        void *venv;
    } UnionJNIEnvToVoid;

    LOG_MODEL_DEBUG("CAndroidNotification", "JNI_OnLoad start");
    UnionJNIEnvToVoid uenv;
    uenv.venv = NULL;
    javaVM = 0;

    if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_4) != JNI_OK) {
        LOG_MODEL_ERROR("CAndroidNotification", "GetEnv failed");
        return -1;
    }
    JNIEnv *env = uenv.nativeEnvironment;
    if (!registerNatives(env)) {
        LOG_MODEL_ERROR("CAndroidNotification", "registerNatives failed");
        return -1;
    }

    javaVM = vm;
    return JNI_VERSION_1_4;
}
Ejemplo n.º 10
0
/*
 * Set some test stuff up.
 *
 * Returns the JNI version on success, -1 on failure.
 */
jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
    UnionJNIEnvToVoid uenv;
    uenv.venv = NULL;
    jint result = -1;
    JNIEnv* env = NULL;

    if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_4) != JNI_OK) {
        fprintf(stderr, "ERROR: GetEnv failed\n");
        goto bail;
    }
    env = uenv.env;

    assert(env != NULL);

    printf("In mgmain JNI_OnLoad\n");

    if (!registerNatives(env)) {
        fprintf(stderr, "ERROR: SEHome native registration failed\n");
        goto bail;
    }

    register_com_android_se_SECamera(env);
    register_com_android_se_SEObject(env);
    register_com_android_se_scene(env);
    register_com_android_se_SEParticleSystem(env);
    register_com_android_se_XMLAnimation(env);
//    register_com_android_se_uiManager(env);
    /* success -- return valid version number */
    result = JNI_VERSION_1_4;

bail:
    return result;
}
Ejemplo n.º 11
0
jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
	UnionJNIEnvToVoid uenv;
	uenv.venv = NULL;
	jint result = -1;
	JNIEnv* env = NULL;
	
	LOGI("JNI_OnLoad");

	if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_4) != JNI_OK) {
		LOGE("ERROR: GetEnv failed");
		goto bail;
	}
	env = uenv.env;

	if (registerNatives(env) != JNI_TRUE) {
		LOGE("ERROR: registerNatives failed");
		goto bail;
	}
	
	result = JNI_VERSION_1_4;
	
bail:
	return result;
}
Ejemplo n.º 12
0
void CNetwork::initAMXGM( void ) {
	if(registerNatives(gamemode_Natives)) {
		ExecMain();
		OnGameModeInit(); //Everything is loaded, init our gamemode..
		mainHooks();
		RestartMap();
	}
}
Ejemplo n.º 13
0
/*
 * Set some test stuff up.
 *
 * Returns the JNI version on success, -1 on failure.
 */
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
    
    if (vm->GetEnv((void**) &gEnv, JNI_VERSION_1_4) != JNI_OK) {
        return -1;
    }
    
    if (!registerNatives(gEnv)) {
        return -1;
    }
    return JNI_VERSION_1_4;
}
Ejemplo n.º 14
0
Archivo: jcc.cpp Proyecto: ahua/java
    JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
    {
        JNIEnv *vm_env;

        if (!vm->GetEnv((void **) &vm_env, JNI_VERSION_1_4))
            env = new JCCEnv(vm, vm_env);

        registerNatives(vm_env);

        return JNI_VERSION_1_4;
    }
Ejemplo n.º 15
0
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
	jint result = -1;
	JNIEnv* env = NULL;
	if ((*vm)->GetEnv(vm, (void **) &env, JNI_VERSION_1_4)) {
		goto fail;
	}
	if (registerNatives(env) != JNI_TRUE) {
		goto fail;
	}
	result = JNI_VERSION_1_4;
	fail: return result;
}
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
	JNIEnv* env = NULL;
	jint result = -1;
	if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK)
		return JNI_FALSE;
	assert(env != NULL);

	if (registerNatives(env) != JNI_OK)
		return JNI_FALSE;

	return JNI_VERSION_1_4;
}
Ejemplo n.º 17
0
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void * reserved) {
    jint result = -1;

    gJvm = vm;
    if(vm->GetEnv((void**)&gEnv, JNI_VERSION_1_6) != JNI_OK) goto bail;
    if(vm->AttachCurrentThread(&gEnv, NULL) < 0) goto bail;
    if(registerNatives(gEnv) != JNI_TRUE) goto bail;

    result = JNI_VERSION_1_6;

bail:
    return result;
}
//JVM虚拟机加载完so库后,接着会在该库中查找JNI_OnLoad()函数,并调用。因此在这里进行动态注册。
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
{
    LOGE("---------------------------JNI_OnLoad---------------------------\n");
    JNIEnv* env;
    if ((vm->GetEnv((void**)&env, JNI_VERSION_1_4)) != JNI_OK)
    {
        return -1;
    }

    //进行动态注册
    registerNatives(env);

    return JNI_VERSION_1_4;
}
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
{
  JNIEnv* env = NULL;
  jint result = -1;

  if ((*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_2) != JNI_OK)
    return JNI_ERR;

  if (!registerNatives(env))
    return JNI_ERR;

  /* success -- return valid version number */
  result = JNI_VERSION_1_4;
  return result;
}
Ejemplo n.º 20
0
jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
    void *venv;
    LOGE("JNI_OnLoad!");
    if ((*vm)->GetEnv(vm, (void**)&venv, JNI_VERSION_1_4) != JNI_OK) {
        LOGE("ERROR: GetEnv failed");
        return -1;
    }
    if (registerNatives(venv) != JNI_TRUE) {
            LOGE("ERROR: registerNatives failed");
            return -1;
    }
    LOGE("JNI_VERSION_1_4 %d",JNI_VERSION_1_4);
    return JNI_VERSION_1_4;
}
Ejemplo n.º 21
0
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
    UnionJNIEnvToVoid uenv;
    uenv.venv = NULL;
    jint result = -1;
    JNIEnv* env = NULL;
    if ((*vm)->GetEnv(vm, &uenv.venv, JNI_VERSION_1_4) != JNI_OK) {
        goto bail;
    }
    env = uenv.env;
    if (registerNatives(env) != JNI_TRUE) {
        goto bail;
    }
    result = JNI_VERSION_1_4;
    bail: LOGI("JNI_ONload result '%d' ", result);
    return result;
}
Ejemplo n.º 22
0
/*
* System.loadLibrary("lib")时调用
* 如果成功返回JNI版本, 失败返回-1
*/
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
    JNIEnv* env = NULL;
    jint result = -1;

    if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) {
        return -1;
    }
    assert(env != NULL);

    if (!registerNatives(env)) {//注册
        return -1;
    }
    //成功
    result = JNI_VERSION_1_4;

    return result;
}
Ejemplo n.º 23
0
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
    JNIEnv* env = NULL;
    jint result = -1;

    if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
        return -1;
    }
    assert(env != NULL);

    if (!registerNatives(env)) { //注册
        return -1;
    }
    /* success -- return valid version number */
    result = JNI_VERSION_1_4;

    return result;
}
Ejemplo n.º 24
0
/* This function will be call when the library first be loaded */
JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM *vm, void *reserved)
{
	UnionJNIEnvToVoid uenv;
	JNIEnv* env = NULL;
	jint result = -1;
	if (vm->GetEnv((void**)&uenv.venv, JNI_VERSION_1_6) != JNI_OK) {
		goto bail;
	}
	env = uenv.env;
	if (registerNatives(env) != JNI_TRUE) {
		goto bail;
	}
	result = JNI_VERSION_1_6;
bail:
	return result;
}
AndroidConnectivityManager::AndroidConnectivityManager()
{
    QJNIEnvironmentPrivate env;
    if (!registerNatives(env))
        return;

    m_connectivityManager = QJNIObjectPrivate::callStaticObjectMethod(networkReceiverClass,
                                                                      "getConnectivityManager",
                                                                      "(Landroid/app/Activity;)Landroid/net/ConnectivityManager;",
                                                                      QtAndroidPrivate::activity());
    if (!m_connectivityManager.isValid())
        return;

    QJNIObjectPrivate::callStaticMethod<void>(networkReceiverClass,
                                              "registerReceiver",
                                              "(Landroid/app/Activity;)V",
                                              QtAndroidPrivate::activity());
}
Ejemplo n.º 26
0
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
    UnionJNIEnvToVoid uenv;
    uenv.venv = NULL;
    jint result = -1;
    JNIEnv* env = NULL;

    if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_6) != JNI_OK) {
        THROW(env, "java/lang/RuntimeException", "GetEnv failed");
        goto bail;
    }
    env = uenv.env;

    if (registerNatives(env) != JNI_TRUE) {
        THROW(env, "java/lang/RuntimeException", "registerNativeMethods failed");
        goto bail;
    }

    if (sdk_version() < 24) {
        if (!(ProcessImpl = env->FindClass("java/lang/ProcessManager$ProcessImpl"))) {
            THROW(env, "java/lang/RuntimeException", "ProcessManager$ProcessImpl not found");
            goto bail;
        }
        ProcessImpl = (jclass) env->NewGlobalRef((jobject) ProcessImpl);
        if (!(ProcessImpl_pid = env->GetFieldID(ProcessImpl, "pid", "I"))) {
            THROW(env, "java/lang/RuntimeException", "ProcessManager$ProcessImpl.pid not found");
            goto bail;
        }
        if (!(ProcessImpl_exitValue = env->GetFieldID(ProcessImpl, "exitValue", "Ljava/lang/Integer;"))) {
            THROW(env, "java/lang/RuntimeException", "ProcessManager$ProcessImpl.exitValue not found");
            goto bail;
        }
        if (!(ProcessImpl_exitValueMutex = env->GetFieldID(ProcessImpl, "exitValueMutex", "Ljava/lang/Object;"))) {
            THROW(env, "java/lang/RuntimeException", "ProcessManager$ProcessImpl.exitValueMutex not found");
            goto bail;
        }
    }

    result = JNI_VERSION_1_6;

bail:
    return result;
}
Ejemplo n.º 27
0
/*
 * When library is loaded by Java by invoking "loadLibrary()".
 */
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
    JNIEnv* env = NULL;
    jint result = -1;

    if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
	HID_ERR("ERROR: GetEnv failed\n");
	goto bail;
    }
    assert(env != null);

    if (!registerNatives(env)) {
	HID_ERR("ERROR: BluetoothHidService failed to register natives\n");
	goto bail;
    }

    result = JNI_VERSION_1_4;

bail:
    return result;;
}
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
    JNIEnv* env = NULL;
    jint result = -1;

    LOGI("JNI_OnLoad");

    if (vm->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK) {
        LOGE("ERROR: GetEnv failed");
        goto bail;
    }

    if (!registerNatives(env)) {
        LOGE("ERROR: registerNatives failed");
        goto bail;
    }

    result = JNI_VERSION_1_4;

bail:
    return result;
}
Ejemplo n.º 29
0
Archivo: j_moc.c Proyecto: bigclean/moc
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
{
    /* cache the JavaVM interface pointer */
    gVm = vm;

    JNIEnv *env    = NULL;
    jint    result = -1;

    if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK){
        return -1;
    }

    LOGI("Register native methods inside moc client.");
    if (!registerNatives(env)) {
        return -1;
    }

    result = JNI_VERSION_1_4;

    return result;
}
Ejemplo n.º 30
0
/*
 * Returns the JNI version on success, -1 on failure.
 */
jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
    JNIEnv* env = NULL;
    jint result = -1;

    if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
        printf("ERROR: GetEnv failed\n");
        goto bail;
    }

    if (!registerNatives(env)) {
        printf("ERROR: BinaryDictionary native registration failed\n");
        goto bail;
    }

    /* success -- return valid version number */
    result = JNI_VERSION_1_4;

bail:
    return result;
}