replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / connectivity / util / src / camanager / bt_le_manager / android / camanagerleutil.h
1 /* ****************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  ******************************************************************/
20
21 #ifndef CA_MANAGER_LE_UTILS_H_
22 #define CA_MANAGER_LE_UTILS_H_
23
24 #include <jni.h>
25
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30
31 typedef enum {
32     CM_CONTAINS = 1,
33     CM_ADD,
34     CM_REMOVE
35 } CASetMethod_t;
36 /**
37  * get bluetooth device object from bluetooth adapter.
38  * @param[in]   env                   JNI interface pointer.
39  * @param[in]   remote_address        remote address.
40  * @return  bluetooth device object.
41  */
42 jobject CAManagerGetRemoteDevice(JNIEnv *env, jstring address);
43
44 /**
45  * check whether the devie is bonded or not.
46  * @param[in]   env                   JNI interface pointer.
47  * @param[in]   btDevice              bluetooth device object.
48  * @return  true(bonded) or false(bond none)
49  */
50 bool CAManagerIsDeviceBonded(JNIEnv *env, jobject btDevice);
51
52 /**
53  * change bluetooth adapter state.
54  * @param[in]   env                   JNI interface pointer.
55  * @param[in]   controlFlag           true : enable(), false : disable()
56  * @return  true or false
57  */
58 bool CAManagerControlAdapter(JNIEnv *env, bool controlFlag);
59
60 /**
61  * request to get rssi value from bluetooth
62  * @param[in]   env                   JNI interface pointer.
63  * @param[in]   bluetoothGatt         connected gatt object.
64  * @return  ::CA_STATUS_OK or Appropriate error code.
65  */
66 CAResult_t CAManagerReadRemoteRssi(JNIEnv *env, jobject bluetoothGatt);
67
68 /**
69  * get SharedPreference from context of application.
70  * @param[in]   env                   JNI interface pointer.
71  * @param[in]   context               Application context interface.
72  * @param[in]   prefName              preferences name.
73  * @return  SharedPreferences object.
74  */
75 jobject CAManagerGetSharedPreference(JNIEnv *env, jobject context, jstring prefName);
76
77 /**
78  * check whether the device is already put or not.
79  * @param[in]   env                   JNI interface pointer.
80  * @param[in]   context               Application context interface.
81  * @param[in]   address               LE address.
82  * @param[in]   set                   set<String> object related to connected list.
83  * @return  true or false
84  */
85 bool CAManagerIsConnectedDeviceAddress(JNIEnv *env, jobject context,
86                                        jstring address, jobject set);
87
88 /**
89  * get SharedPreferences.Editor object.
90  * @param[in]   env                   JNI interface pointer.
91  * @param[in]   context               Application context interface.
92  * @return  SharedPreferences.Editor object.
93  */
94 jobject CAManagerGetPrefStringSet(JNIEnv *env, jobject context);
95
96 /**
97  * update SharedPreferences for set<String> object.
98  * @param[in]   env                   JNI interface pointer.
99  * @param[in]   context               Application context interface.
100  * @param[in]   set                   set<String> object related to connected list.
101  * @return  true or false
102  */
103 bool CAManagerUpdatePrefStringSet(JNIEnv *env, jobject context, jobject set);
104
105 /**
106  * get SharedPreferences for set<String> object.
107  * @param[in]   env                   JNI interface pointer.
108  * @param[in]   context               Application context interface.
109  * @return  set<String> object from SharedPreferences
110  */
111 jobject CAManagerGetPrefStringSet(JNIEnv *env, jobject context);
112
113 /**
114  * checks whether the preferences contains a preference.
115  * @param[in]   env                   JNI interface pointer.
116  * @param[in]   context               Application context interface.
117  * @return  true or false
118  */
119 bool CAManagerContainsPrefStringSet(JNIEnv *env, jobject context);
120
121 /**
122  * add connected device into SharedPreference.
123  * @param[in]   env                   JNI interface pointer.
124  * @param[in]   context               Application context interface.
125  * @param[in]   address               ble address.
126  * @param[in]   set                   set<String> object related to connected list.
127  * @return  true or false
128  */
129 bool CAManagerAddConnectedDeviceAddress(JNIEnv *env, jobject context,
130                                         jstring address, jobject set);
131
132 /**
133  * get connected device from SharedPreference.
134  * @param[in]   env                   JNI interface pointer.
135  * @param[in]   context               Application context interface.
136  * @return  LE address of connected device.
137  */
138 jobject CAManagerGetConnectedDeviceAddress(JNIEnv *env, jobject context);
139
140 /**
141  * remove connected device to SharedPreference.
142  * @param[in]   env                   JNI interface pointer.
143  * @param[in]   context               Application context interface.
144  * @param[in]   address               LE address.
145  * @param[in]   set                   set<String> object related to connected list.
146  * @return  true or false
147  */
148 bool CAManagerRemoveConnectedDeviceAddress(JNIEnv *env, jobject context,
149                                            jstring address, jobject set);
150
151 /**
152  * Vaildate a String bluetooth address.
153  * @param[in]   env                   JNI interface pointer.
154  * @param[in]   address               LE address.
155  * @return  JNI_TRUE or JNI_FALSE
156  */
157 jboolean CAManagerCheckBTAddress(JNIEnv *env, jstring address);
158
159 /**
160  * create new set<String> object.
161  * @param[in]   env                   JNI interface pointer.
162  * @return  set<String> object
163  */
164 jobject CAManagerCreateSetString(JNIEnv *env);
165
166 /**
167  * remove connected device to SharedPreference.
168  * @param[in]   env                   JNI interface pointer.
169  * @param[in]   address               LE address.
170  * @param[in]   set                   set<String> object related to connected list.
171  * @param[in]   method_type           method name to get its ID.
172  * @return  true or false
173  */
174 bool CAManagerCallFuncSetString(JNIEnv *env, jstring address,
175                                 jobject set, CASetMethod_t method_type);
176
177 #ifdef __cplusplus
178 } /* extern "C" */
179 #endif
180
181 #endif /* CA_MANAGER_LE_UTILS_H_ */