1 /******************************************************************
3 * Copyright 2016 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
24 jclass g_cls_RemoteEnrollee = NULL;
25 jclass g_cls_ESException = NULL;
26 jclass g_cls_CloudProvisioningStatus = NULL;
28 jmethodID g_mid_RemoteEnrollee_ctor = NULL;
29 jmethodID g_mid_ESException_ctor = NULL;
30 jmethodID g_mid_CloudProvisioningStatus_ctor = NULL;
33 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
39 if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
41 LOGE("Failed to get the environment using GetEnv()");
45 jclass clazz = nullptr;
48 clazz = env->FindClass("org/iotivity/service/easysetup/mediator/RemoteEnrollee");
49 if (!clazz) return JNI_ERR;
50 g_cls_RemoteEnrollee = (jclass)env->NewGlobalRef(clazz);
51 env->DeleteLocalRef(clazz);
53 g_mid_RemoteEnrollee_ctor = env->GetMethodID(g_cls_RemoteEnrollee, "<init>",
55 if (!g_mid_RemoteEnrollee_ctor) return JNI_ERR;
58 clazz = env->FindClass("org/iotivity/service/easysetup/mediator/ESException");
59 if (!clazz) return JNI_ERR;
60 g_cls_ESException = (jclass)env->NewGlobalRef(clazz);
61 env->DeleteLocalRef(clazz);
63 g_mid_ESException_ctor = env->GetMethodID(g_cls_ESException, "<init>", "(Ljava/lang/String;)V");
64 if (!g_mid_ESException_ctor) return JNI_ERR;
66 // CloudProvisioningStatus
67 clazz = env->FindClass("org/iotivity/service/easysetup/mediator/CloudProvisioningStatus");
68 if (!clazz) return JNI_ERR;
69 g_cls_CloudProvisioningStatus = (jclass)env->NewGlobalRef(clazz);
70 env->DeleteLocalRef(clazz);
72 g_mid_CloudProvisioningStatus_ctor = env->GetMethodID(g_cls_CloudProvisioningStatus, "<init>",
74 if (!g_mid_CloudProvisioningStatus_ctor) return JNI_ERR;
76 return JNI_CURRENT_VERSION;
80 JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
85 if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
87 LOGE("Failed to get the environment using GetEnv()");
90 env->DeleteGlobalRef(g_cls_RemoteEnrollee);
91 env->DeleteGlobalRef(g_cls_ESException);