Lines Matching defs:env

221 int add_app_instance(const hub_app_info *appInfo, uint32_t hubHandle, JNIEnv *env) {
241 env->CallIntMethod(db.jniInfo.jContextHubService,
315 JNIEnv *env;
317 if ((db.jniInfo.vm)->AttachCurrentThread(&env, nullptr) != JNI_OK) {
321 jbyteArray jmsg = env->NewByteArray(msgLen);
326 jintArray jheader = env->NewIntArray(headerLen);
328 env->DeleteLocalRef(jmsg);
333 env->SetByteArrayRegion(jmsg, 0, msgLen, (jbyte *)msg);
334 env->SetIntArrayRegion(jheader, 0, headerLen, (jint *)header);
336 int ret = (env->CallIntMethod(db.jniInfo.jContextHubService,
339 env->DeleteLocalRef(jmsg);
340 env->DeleteLocalRef(jheader);
346 JNIEnv *env;
347 if ((db.jniInfo.vm)->AttachCurrentThread(&env, nullptr) != JNI_OK) {
357 add_app_instance(&info, hubHandle, env);
453 static int init_jni(JNIEnv *env, jobject instance) {
455 if (env->GetJavaVM(&db.jniInfo.vm) != JNI_OK) {
459 db.jniInfo.jContextHubService = env->NewGlobalRef(instance);
462 env->FindClass("android/hardware/location/ContextHubInfo");
465 env->FindClass("android/hardware/location/ContextHubService");
468 env->FindClass("android/hardware/location/MemoryRegion");
471 env->GetMethodID(db.jniInfo.contextHubInfoClass, "<init>", "()V");
473 env->GetMethodID(db.jniInfo.contextHubInfoClass, "setId", "(I)V");
475 env->GetMethodID(db.jniInfo.contextHubInfoClass, "setName",
479 env->GetMethodID(db.jniInfo.contextHubInfoClass,
482 env->GetMethodID(db.jniInfo.contextHubInfoClass,
485 env->GetMethodID(db.jniInfo.contextHubInfoClass,
488 env->GetMethodID(db.jniInfo.contextHubInfoClass,
491 env->GetMethodID(db.jniInfo.contextHubInfoClass,
494 env->GetMethodID(db.jniInfo.contextHubInfoClass,
497 env->GetMethodID(db.jniInfo.contextHubInfoClass,
500 env->GetMethodID(db.jniInfo.contextHubInfoClass,
503 env->GetMethodID(db.jniInfo.contextHubInfoClass,
506 env->GetMethodID(db.jniInfo.contextHubInfoClass,
509 env->GetMethodID(db.jniInfo.contextHubInfoClass,
512 env->GetMethodID(db.jniInfo.contextHubInfoClass,
517 env->GetMethodID(db.jniInfo.contextHubServiceClass, "onMessageReceipt",
520 env->GetMethodID(db.jniInfo.contextHubInfoClass, "setName",
524 env->GetMethodID(db.jniInfo.contextHubServiceClass,
532 static jobject constructJContextHubInfo(JNIEnv *env, const struct context_hub_t *hub) {
539 jobject jHub = env->NewObject(db.jniInfo.contextHubInfoClass,
541 env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetId, hub->hub_id);
543 jstrBuf = env->NewStringUTF(hub->name);
544 env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetName, jstrBuf);
545 env->DeleteLocalRef(jstrBuf);
547 jstrBuf = env->NewStringUTF(hub->vendor);
548 env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetVendor, jstrBuf);
549 env->DeleteLocalRef(jstrBuf);
551 jstrBuf = env->NewStringUTF(hub->toolchain);
552 env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetToolchain, jstrBuf);
553 env->DeleteLocalRef(jstrBuf);
555 env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetPlatformVersion, hub->platform_version);
556 env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetToolchainVersion, hub->toolchain_version);
557 env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetPeakMips, hub->peak_mips);
558 env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetStoppedPowerDrawMw,
560 env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetSleepPowerDrawMw,
562 env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetPeakPowerDrawMw,
564 env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetMaxPacketLenBytes,
568 // TODO : jintBuf = env->NewIntArray(hub->num_connected_sensors);
569 // TODO : env->SetIntArrayRegion(jintBuf, 0, hub->num_connected_sensors,
571 jintBuf = env->NewIntArray(array_length(dummyConnectedSensors));
572 env->SetIntArrayRegion(jintBuf, 0, hub->num_connected_sensors, dummyConnectedSensors);
573 env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetSupportedSensors, jintBuf);
574 env->DeleteLocalRef(jintBuf);
577 jmemBuf = env->NewObjectArray(0, db.jniInfo.memoryRegionsClass, nullptr);
579 env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetMemoryRegions, jmemBuf);
580 env->DeleteLocalRef(jmemBuf);
586 static jobjectArray nativeInitialize(JNIEnv *env, jobject instance)
591 if (init_jni(env, instance) < 0) {
602 retArray = env->NewObjectArray(db.hubInfo.numHubs, db.jniInfo.contextHubInfoClass, nullptr);
605 hub = constructJContextHubInfo(env, &db.hubInfo.hubs[i]);
606 env->SetObjectArrayElement(retArray, i, hub);
612 static jint nativeSendMessage(JNIEnv *env, jobject instance, jintArray header_,
616 jint *header = env->GetIntArrayElements(header_, 0);
617 unsigned int numHeaderElements = env->GetArrayLength(header_);
618 jbyte *data = env->GetByteArrayElements(data_, 0);
619 int dataBufferLength = env->GetArrayLength(data_);
650 env->ReleaseIntArrayElements(header_, header, 0);
651 env->ReleaseByteArrayElements(data_, data, 0);
671 int register_android_hardware_location_ContextHubService(JNIEnv *env)
673 RegisterMethodsOrDie(env, "android/hardware/location/ContextHubService",