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 #include "cacommonutil.h"
25 #include "camanagerleutil.h"
26 #include "caleclient.h"
27 #include "caleutils.h"
29 #define TAG "OIC_CA_MANAGER_UTIL"
31 static const char CLASSPATH_CONTENT_PREF[] = "android/content/SharedPreferences";
32 static const char CLASSPATH_CONTENT_PREF_EDITOR[] = "android/content/SharedPreferences$Editor";
33 static const char CLASSPATH_CONTEXT[] = "android/content/Context";
35 static const char PREF_NAME_CONNECTED_DEVICE[] = "PREF_NAME_CONNECTED_DEVICE";
36 static const char PREF_KEY_CONNECTED_DEVICE[] = "PREF_KEY_CONNECTED_DEVICE";
38 static const char METHODID_BOOLEAN_RET_STRING_PARAM[] = "(Ljava/lang/String;)Z";
40 static jobject CAManagerGetAdapterContext(JNIEnv *env)
42 OIC_LOG(DEBUG, TAG, "CAManagerGetAdapterContext");
43 VERIFY_NON_NULL_RET(env, TAG, "env is null", NULL);
45 jclass jni_cid_BTAdapter = (*env)->FindClass(env, CLASSPATH_BT_ADAPTER);
46 if (!jni_cid_BTAdapter)
48 OIC_LOG(ERROR, TAG, "jni_cid_BTAdapter: jni_cid_BTAdapter is null");
52 jmethodID jni_mid_getDefaultAdapter = (*env)->GetStaticMethodID(env, jni_cid_BTAdapter,
54 METHODID_OBJECTNONPARAM);
55 if (!jni_mid_getDefaultAdapter)
57 OIC_LOG(ERROR, TAG, "jni_mid_getDefaultAdapter is null");
61 jobject jni_obj_BTAdapter = (*env)->CallStaticObjectMethod(env, jni_cid_BTAdapter,
62 jni_mid_getDefaultAdapter);
63 if (!jni_obj_BTAdapter)
65 OIC_LOG(ERROR, TAG, "jni_obj_BTAdapter is null");
68 return jni_obj_BTAdapter;
71 jobject CAManagerGetRemoteDevice(JNIEnv *env, jstring address)
73 OIC_LOG(DEBUG, TAG, "IN - CAManagerGetRemoteDevice");
75 VERIFY_NON_NULL_RET(env, TAG, "env is null", NULL);
76 VERIFY_NON_NULL_RET(address, TAG, "address is null", NULL);
78 jclass jni_cid_BTAdapter = (*env)->FindClass(env, CLASSPATH_BT_ADAPTER);
79 if (!jni_cid_BTAdapter)
81 OIC_LOG(ERROR, TAG, "jni_cid_BTAdapter is null");
85 // get remote bt adapter method
86 jmethodID jni_mid_getDefaultAdapter = (*env)->GetStaticMethodID(env, jni_cid_BTAdapter,
88 METHODID_OBJECTNONPARAM);
89 if (!jni_mid_getDefaultAdapter)
91 OIC_LOG(ERROR, TAG, "jni_mid_getDefaultAdapter is null");
95 // gat bt adapter object
96 jobject jni_obj_BTAdapter = (*env)->CallStaticObjectMethod(env, jni_cid_BTAdapter,
97 jni_mid_getDefaultAdapter);
98 if (!jni_obj_BTAdapter)
100 OIC_LOG(ERROR, TAG, "jni_obj_BTAdapter is null");
104 jmethodID jni_mid_getRemoteDevice = (*env)->GetMethodID(env, jni_cid_BTAdapter,
106 METHODID_BT_REMOTE_DEVICE);
107 if (!jni_mid_getRemoteDevice)
109 OIC_LOG(ERROR, TAG, "jni_mid_getRemoteDevice is null");
113 jobject jni_obj_device = (*env)->CallObjectMethod(env, jni_obj_BTAdapter,
114 jni_mid_getRemoteDevice,
118 OIC_LOG(ERROR, TAG, "jni_obj_device is null");
122 OIC_LOG(DEBUG, TAG, "OUT - CAManagerGetRemoteDevice");
123 return jni_obj_device;
126 bool CAManagerIsDeviceBonded(JNIEnv *env, jobject btDevice)
128 OIC_LOG(DEBUG, TAG, "IN - CAManagerIsDeviceBonded");
130 VERIFY_NON_NULL(env, TAG, "env is null");
131 VERIFY_NON_NULL(btDevice, TAG, "btDevice is null");
133 jclass jni_cid_BTDevice = (*env)->FindClass(env, CLASSPATH_BT_DEVICE);
134 if (!jni_cid_BTDevice)
136 OIC_LOG(ERROR, TAG, "jni_cid_BTDevice is null");
140 jmethodID jni_mid_getBondState = (*env)->GetMethodID(env, jni_cid_BTDevice,
141 "getBondState", "()I");
142 if (!jni_mid_getBondState)
144 OIC_LOG(ERROR, TAG, "jni_mid_getBondState is null");
148 jint jni_bond_state = (*env)->CallIntMethod(env, btDevice, jni_mid_getBondState);
149 OIC_LOG_V(DEBUG, TAG, "bond state is %d", jni_bond_state);
151 // BOND_BONDED - Constant value : 12 (0x0000000c)
152 jfieldID id_bonded = (*env)->GetStaticFieldID(env, jni_cid_BTDevice,
156 OIC_LOG(ERROR, TAG, "id_bonded is null");
160 jint jni_bonded_const = (*env)->GetStaticIntField(env, jni_cid_BTDevice, id_bonded);
162 if (jni_bond_state == jni_bonded_const)
164 OIC_LOG(INFO, TAG, "it is not bonded to each other");
167 OIC_LOG(DEBUG, TAG, "OUT - CAManagerIsDeviceBonded");
171 bool CAManagerControlAdapter(JNIEnv *env, bool control_flag)
173 OIC_LOG(DEBUG, TAG, "IN - CAManagerControlAdapter");
175 VERIFY_NON_NULL_RET(env, TAG, "env", false);
177 jobject jni_obj_BTAdapter = CAManagerGetAdapterContext(env);
178 if (!jni_obj_BTAdapter)
180 OIC_LOG(ERROR, TAG, "jni_obj_BTAdapter is null");
184 jclass jni_cid_BTAdapter = (*env)->FindClass(env, CLASSPATH_BT_ADAPTER);
185 if (!jni_cid_BTAdapter)
187 OIC_LOG(ERROR, TAG, "jni_cid_BTAdapter: jni_cid_BTAdapter is null");
191 OIC_LOG_V(DEBUG, TAG, "change adapter : %d", control_flag);
192 jmethodID jni_mid_control = NULL;
196 jni_mid_control = (*env)->GetMethodID(env, jni_cid_BTAdapter, "enable", "()Z");
201 jni_mid_control = (*env)->GetMethodID(env, jni_cid_BTAdapter, "disable", "()Z");
204 if (!jni_mid_control)
206 OIC_LOG(ERROR, TAG, "jni_mid_control is null");
210 OIC_LOG(DEBUG, TAG, "CALL API - Adapter Will be Changed");
211 jboolean jni_res = (*env)->CallBooleanMethod(env, jni_obj_BTAdapter, jni_mid_control);
216 CAResult_t CAManagerReadRemoteRssi(JNIEnv *env, jobject bluetoothGatt)
218 VERIFY_NON_NULL(env, TAG, "env is null");
219 VERIFY_NON_NULL(bluetoothGatt, TAG, "bluetoothGatt is null");
221 if (!CALEIsEnableBTAdapter(env))
223 OIC_LOG(INFO, TAG, "BT adapter is not enabled");
224 return CA_ADAPTER_NOT_ENABLED;
227 // get BluetoothGatt class
228 jclass jni_cid_BluetoothGatt = (*env)->FindClass(env, CLASSPATH_BT_GATT);
229 if (!jni_cid_BluetoothGatt)
231 OIC_LOG(ERROR, TAG, "jni_cid_BluetoothGatt is null");
232 return CA_STATUS_FAILED;
235 jmethodID jni_mid_readRemoteRssi = (*env)->GetMethodID(env, jni_cid_BluetoothGatt,
236 "readRemoteRssi", "()Z");
237 if (!jni_mid_readRemoteRssi)
239 OIC_LOG(ERROR, TAG, "jni_mid_readRemoteRssi is null");
240 return CA_STATUS_FAILED;
242 // call disconnect gatt method
243 jboolean ret = (*env)->CallBooleanMethod(env, bluetoothGatt, jni_mid_readRemoteRssi);
246 OIC_LOG(ERROR, TAG, "readremoteRssi has not been called");
247 return CA_STATUS_FAILED;
253 jobject CAManagerGetSharedPreference(JNIEnv *env, jobject context, jstring prefName)
255 VERIFY_NON_NULL_RET(env, TAG, "env", NULL);
256 VERIFY_NON_NULL_RET(context, TAG, "context", NULL);
257 VERIFY_NON_NULL_RET(prefName, TAG, "prefName", NULL);
259 jclass jni_cls_context = (*env)->FindClass(env, CLASSPATH_CONTEXT);
260 if (!jni_cls_context)
262 OIC_LOG(ERROR, TAG, "jni_cls_context is null");
266 // getSharedPreferences
267 jmethodID jni_mid_getPref = (*env)->GetMethodID(env, jni_cls_context, "getSharedPreferences",
268 "(Ljava/lang/String;I)"
269 "Landroid/content/SharedPreferences;");
270 if (!jni_mid_getPref)
272 OIC_LOG(ERROR, TAG, "jni_mid_getPref is null");
276 jobject jni_obj_sharedPref = (*env)->CallObjectMethod(env, context,
280 if (!jni_obj_sharedPref)
282 OIC_LOG(ERROR, TAG, "jni_obj_sharedPref is null");
286 return jni_obj_sharedPref;
289 jobject CAManagerGetPrefEditObject(JNIEnv *env, jobject context)
291 OIC_LOG(DEBUG, TAG, "IN-CAManagerGetPrefEditObject");
292 VERIFY_NON_NULL_RET(env, TAG, "env", NULL);
293 VERIFY_NON_NULL_RET(context, TAG, "context", NULL);
295 jstring jni_str_prefName = (*env)->NewStringUTF(env, PREF_NAME_CONNECTED_DEVICE);
296 if (!jni_str_prefName)
298 OIC_LOG(ERROR, TAG, "jni_str_prefName is null");
302 jstring jni_str_prefKey = (*env)->NewStringUTF(env, PREF_KEY_CONNECTED_DEVICE);
303 if (!jni_str_prefKey)
305 OIC_LOG(ERROR, TAG, "jni_str_prefKey is null");
309 // get SharedPreference
310 jobject jni_obj_pref = CAManagerGetSharedPreference(env, context, jni_str_prefName);
313 OIC_LOG(ERROR, TAG, "jni_obj_pref is null");
318 jobject jni_cls_pref = (*env)->FindClass(env, CLASSPATH_CONTENT_PREF);
321 OIC_LOG(ERROR, TAG, "jni_cls_pref is null");
325 jmethodID jni_mid_prefEdit = (*env)->GetMethodID(env, jni_cls_pref, "edit",
326 "()Landroid/content/SharedPreferences$Editor;");
327 if (!jni_mid_prefEdit)
329 OIC_LOG(ERROR, TAG, "jni_mid_prefEdit is null");
333 jobject jni_obj_prefEdit = (*env)->CallObjectMethod(env, jni_obj_pref, jni_mid_prefEdit);
334 if (!jni_obj_prefEdit)
336 OIC_LOG(ERROR, TAG, "jni_obj_prefEdit is null");
340 OIC_LOG(DEBUG, TAG, "OUT-CAManagerGetPrefEditObject");
341 return jni_obj_prefEdit;
344 bool CAManagerUpdatePrefStringSet(JNIEnv *env, jobject context, jobject set)
346 OIC_LOG(DEBUG, TAG, "IN-CAManagerUpdatePrefStringSet");
348 VERIFY_NON_NULL_RET(env, TAG, "env", false);
349 VERIFY_NON_NULL_RET(context, TAG, "context", false);
350 VERIFY_NON_NULL_RET(set, TAG, "set", false);
352 jstring jni_str_prefKey = (*env)->NewStringUTF(env, PREF_KEY_CONNECTED_DEVICE);
353 if (!jni_str_prefKey)
355 OIC_LOG(ERROR, TAG, "jni_str_prefKey is null");
359 jobject jni_obj_prefEdit = CAManagerGetPrefEditObject(env, context);
360 if (!jni_obj_prefEdit)
362 OIC_LOG(ERROR, TAG, "jni_obj_prefEdit is null");
367 jobject jni_cls_edit = (*env)->FindClass(env, CLASSPATH_CONTENT_PREF_EDITOR);
370 OIC_LOG(ERROR, TAG, "jni_cls_edit is null");
374 // get putString method interface
375 jmethodID jni_mid_PrefPutStringSet = (*env)->GetMethodID(env, jni_cls_edit, "putStringSet",
376 "(Ljava/lang/String;Ljava/util/Set;)"
377 "Landroid/content/SharedPreferences"
379 if (!jni_mid_PrefPutStringSet)
381 OIC_LOG(ERROR, TAG, "jni_mid_PrefPutStringSet is null");
385 jobject gSetString = (jobject)(*env)->NewGlobalRef(env, set);
388 OIC_LOG(ERROR, TAG, "gAddress is null");
392 OIC_LOG(DEBUG, TAG, "CALL API - request putString for SharedPreferences.Editor");
393 (*env)->CallObjectMethod(env, jni_obj_prefEdit, jni_mid_PrefPutStringSet,
394 jni_str_prefKey, gSetString);
396 // get commit method interface
397 jmethodID jni_mid_PrefCommit = (*env)->GetMethodID(env, jni_cls_edit, "commit",
399 if (!jni_mid_PrefCommit)
401 OIC_LOG(ERROR, TAG, "jni_mid_PrefCommit is null");
405 jboolean res = (*env)->CallBooleanMethod(env, jni_obj_prefEdit, jni_mid_PrefCommit);
407 OIC_LOG(DEBUG, TAG, "OUT-CAManagerUpdatePrefStringSet");
411 jobject CAManagerGetPrefStringSet(JNIEnv *env, jobject context)
413 OIC_LOG(DEBUG, TAG, "CAManagerGetPrefStringSet");
415 VERIFY_NON_NULL_RET(env, TAG, "env", NULL);
416 VERIFY_NON_NULL_RET(context, TAG, "context", NULL);
418 jstring jni_str_prefName = (*env)->NewStringUTF(env, PREF_NAME_CONNECTED_DEVICE);
419 if (!jni_str_prefName)
421 OIC_LOG(ERROR, TAG, "jni_str_prefName is null");
425 jstring jni_str_prefKey = (*env)->NewStringUTF(env, PREF_KEY_CONNECTED_DEVICE);
426 if (!jni_str_prefKey)
428 OIC_LOG(ERROR, TAG, "jni_str_prefKey is null");
432 // get SharedPreference
433 jobject jni_obj_pref = CAManagerGetSharedPreference(env, context, jni_str_prefName);
436 OIC_LOG(ERROR, TAG, "jni_obj_pref is null");
440 // contains(String key)
441 jobject jni_cls_pref = (*env)->FindClass(env, CLASSPATH_CONTENT_PREF);
444 OIC_LOG(ERROR, TAG, "jni_cls_pref is null");
448 jmethodID jni_mid_getStringSet = (*env)->GetMethodID(env, jni_cls_pref, "getStringSet",
449 "(Ljava/lang/String;Ljava/util/Set;)"
451 if (!jni_mid_getStringSet)
453 OIC_LOG(ERROR, TAG, "jni_mid_getStringSet is null");
457 jobject jni_defSet = CAManagerCreateSetString(env);
460 OIC_LOG(ERROR, TAG, "jni_defSet is null");
464 jobject value = (*env)->CallObjectMethod(env, jni_obj_pref,
465 jni_mid_getStringSet,
472 bool CAManagerContainsPrefStringSet(JNIEnv *env, jobject context)
474 OIC_LOG(DEBUG, TAG, "CAManagerContainsPrefStringSet");
476 VERIFY_NON_NULL_RET(env, TAG, "env", false);
477 VERIFY_NON_NULL_RET(context, TAG, "context", false);
479 jstring jni_str_prefName = (*env)->NewStringUTF(env, PREF_NAME_CONNECTED_DEVICE);
480 if (!jni_str_prefName)
482 OIC_LOG(ERROR, TAG, "jni_str_prefName is null");
486 jstring jni_str_prefKey = (*env)->NewStringUTF(env, PREF_KEY_CONNECTED_DEVICE);
487 if (!jni_str_prefKey)
489 OIC_LOG(ERROR, TAG, "jni_str_prefKey is null");
493 // get SharedPreference
494 jobject jni_obj_pref = CAManagerGetSharedPreference(env, context, jni_str_prefName);
497 OIC_LOG(ERROR, TAG, "jni_obj_pref is null");
501 // contains(String key)
502 jobject jni_cls_pref = (*env)->FindClass(env, CLASSPATH_CONTENT_PREF);
505 OIC_LOG(ERROR, TAG, "jni_cls_pref is null");
509 jmethodID jni_mid_prefContains = (*env)->GetMethodID(env, jni_cls_pref, "contains",
510 METHODID_BOOLEAN_RET_STRING_PARAM);
511 if (!jni_mid_prefContains)
513 OIC_LOG(ERROR, TAG, "jni_mid_prefContains is null");
517 jboolean res = (*env)->CallBooleanMethod(env, jni_obj_pref,
518 jni_mid_prefContains,
521 OIC_LOG_V(DEBUG, TAG, "Preference - contains (%d)", res);
525 bool CAManagerRemovePrefStringSet(JNIEnv *env, jobject context)
527 OIC_LOG(DEBUG, TAG, "CAManagerRemovePrefStringSet");
529 VERIFY_NON_NULL_RET(env, TAG, "env", false);
530 VERIFY_NON_NULL_RET(context, TAG, "context", false);
532 jstring jni_str_prefKey = (*env)->NewStringUTF(env, PREF_KEY_CONNECTED_DEVICE);
533 if (!jni_str_prefKey)
535 OIC_LOG(ERROR, TAG, "jni_str_prefKey is null");
539 jobject jni_obj_prefEdit = CAManagerGetPrefEditObject(env, context);
540 if (!jni_obj_prefEdit)
542 OIC_LOG(ERROR, TAG, "jni_obj_prefEdit is null");
547 jobject jni_cls_edit = (*env)->FindClass(env, CLASSPATH_CONTENT_PREF_EDITOR);
550 OIC_LOG(ERROR, TAG, "jni_cls_edit is null");
554 // get remove method interface
555 jmethodID jni_mid_PrefRemove = (*env)->GetMethodID(env, jni_cls_edit, "remove",
556 "(Ljava/lang/String;)"
557 "Landroid/content/SharedPreferences"
559 if (!jni_mid_PrefRemove)
561 OIC_LOG(ERROR, TAG, "jni_mid_PrefRemove is null");
565 OIC_LOG(DEBUG, TAG, "CALL API - request remove for SharedPreferences.Editor");
566 (*env)->CallObjectMethod(env, jni_obj_prefEdit, jni_mid_PrefRemove, jni_str_prefKey);
568 // get commit method interface
569 jmethodID jni_mid_PrefCommit = (*env)->GetMethodID(env, jni_cls_edit, "commit",
571 if (!jni_mid_PrefCommit)
573 OIC_LOG(ERROR, TAG, "jni_mid_PrefCommit is null");
577 jboolean res = (*env)->CallBooleanMethod(env, jni_obj_prefEdit, jni_mid_PrefCommit);
579 OIC_LOG(DEBUG, TAG, "OUT-CAManagerAddConnectedDeviceAddress");
583 bool CAManagerAddConnectedDeviceAddress(JNIEnv *env, jobject context,
584 jstring address, jobject set)
586 OIC_LOG(DEBUG, TAG, "IN-CAManagerAddConnectedDeviceAddress");
588 VERIFY_NON_NULL_RET(env, TAG, "env", false);
589 VERIFY_NON_NULL_RET(context, TAG, "context", false);
590 VERIFY_NON_NULL_RET(address, TAG, "address", false);
591 VERIFY_NON_NULL_RET(set, TAG, "set", false);
593 if (CAManagerCallFuncSetString(env, address, set, CM_CONTAINS))
595 OIC_LOG(DEBUG, TAG, "it's already done");
599 if (!CAManagerCallFuncSetString(env, address, set, CM_ADD))
601 OIC_LOG(ERROR, TAG, "CAManagerAddSetString has failed");
605 return CAManagerUpdatePrefStringSet(env, context, set);
608 bool CAManagerIsConnectedDeviceAddress(JNIEnv *env, jobject context,
609 jstring address, jobject set)
611 VERIFY_NON_NULL_RET(env, TAG, "env", false);
612 VERIFY_NON_NULL_RET(context, TAG, "context", false);
614 return CAManagerCallFuncSetString(env, address, set, CM_CONTAINS);
617 jobject CAManagerGetConnectedDeviceAddress(JNIEnv *env, jobject context)
619 OIC_LOG(DEBUG, TAG, "CAManagerGetConnectedDeviceAddress");
621 if (!CAManagerContainsPrefStringSet(env, context))
623 OIC_LOG(DEBUG, TAG, "there is no set data");
627 return CAManagerGetPrefStringSet(env, context);
630 bool CAManagerRemoveConnectedDeviceAddress(JNIEnv *env, jobject context,
631 jstring address, jobject set)
633 OIC_LOG(DEBUG, TAG, "CAManagerRemoveConnectedDeviceAddress");
635 VERIFY_NON_NULL_RET(env, TAG, "env", false);
636 VERIFY_NON_NULL_RET(context, TAG, "context", false);
637 VERIFY_NON_NULL_RET(address, TAG, "address", false);
638 VERIFY_NON_NULL_RET(set, TAG, "set", false);
640 if (!CAManagerCallFuncSetString(env, address, set, CM_CONTAINS))
642 OIC_LOG(DEBUG, TAG, "it's already done");
646 if (!CAManagerCallFuncSetString(env, address, set, CM_REMOVE))
648 OIC_LOG(ERROR, TAG, "CAManagerAddSetString has failed");
652 return CAManagerUpdatePrefStringSet(env, context, set);
655 jboolean CAManagerCheckBTAddress(JNIEnv *env, jstring address)
657 OIC_LOG(DEBUG, TAG, "CAManagerCheckBTAddress");
659 VERIFY_NON_NULL_RET(env, TAG, "env is null", JNI_FALSE);
660 VERIFY_NON_NULL_RET(address, TAG, "address is null", JNI_FALSE);
662 jclass jni_cid_BTAdapter = (*env)->FindClass(env, CLASSPATH_BT_ADAPTER);
663 if (!jni_cid_BTAdapter)
665 OIC_LOG(ERROR, TAG, "jni_cid_BTAdapter is null");
669 // get remote bt adapter method
670 jmethodID jni_mid_checkBTAddress =
671 (*env)->GetStaticMethodID(env, jni_cid_BTAdapter,
672 "checkBluetoothAddress",
673 METHODID_BOOLEAN_RET_STRING_PARAM);
674 if (!jni_mid_checkBTAddress)
676 OIC_LOG(ERROR, TAG, "jni_mid_checkBTAddress is null");
680 jboolean jni_obj_isAddress = (*env)->CallStaticBooleanMethod(env, jni_cid_BTAdapter,
681 jni_mid_checkBTAddress,
683 return jni_obj_isAddress;
686 jobject CAManagerCreateSetString(JNIEnv *env)
688 OIC_LOG(DEBUG, TAG, "CAManagerCallFuncSetString");
690 VERIFY_NON_NULL_RET(env, TAG, "env", NULL);
692 jclass jclazzMap = (*env)->FindClass(env, "java/util/HashSet" );
695 OIC_LOG(ERROR, TAG, "jclazzMap is null");
699 jmethodID jinitMap = (*env)->GetMethodID(env, jclazzMap, "<init>", "()V");
702 OIC_LOG(ERROR, TAG, "jinitMap is null");
706 jobject jpropertyMap = (*env)->NewObject(env, jclazzMap, jinitMap);
709 OIC_LOG(ERROR, TAG, "jpropertyMap is null");
716 bool CAManagerCallFuncSetString(JNIEnv *env, jstring address, jobject set,
717 CASetMethod_t method_type)
719 VERIFY_NON_NULL_RET(env, TAG, "env", false);
720 VERIFY_NON_NULL_RET(address, TAG, "address", false);
721 VERIFY_NON_NULL_RET(set, TAG, "set", false);
723 jclass jni_cls_set = (*env)->FindClass(env, "java/util/HashSet");
726 OIC_LOG(ERROR, TAG, "jni_cls_set is null");
730 jmethodID jni_mid_setMethod = NULL;
734 jni_mid_setMethod = (*env)->GetMethodID(env, jni_cls_set, "contains",
735 "(Ljava/lang/Object;)Z");
738 jni_mid_setMethod = (*env)->GetMethodID(env, jni_cls_set, "add",
739 "(Ljava/lang/Object;)Z");
742 jni_mid_setMethod = (*env)->GetMethodID(env, jni_cls_set, "remove",
743 "(Ljava/lang/Object;)Z");
748 if (!jni_mid_setMethod)
750 OIC_LOG(ERROR, TAG, "jni_mid_setMethod is null");
754 jboolean res = (*env)->CallBooleanMethod(env, set, jni_mid_setMethod, address);