Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / resource / csdk / connectivity / util / src / camanager / 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  * get address from gatt profile object.
46  * @param[in]   env                   JNI interface pointer.
47  * @param[in]   gatt                  gatt profile object.
48  * @return  LE address.
49  */
50 jstring CAManagerGetAddressFromGatt(JNIEnv *env, jobject gatt);
51
52 /**
53  * check whether the devie is bonded or not.
54  * @param[in]   env                   JNI interface pointer.
55  * @param[in]   btDevice              bluetooth device object.
56  * @return  true(bonded) or false(bond none)
57  */
58 bool CAManagerIsDeviceBonded(JNIEnv *env, jobject btDevice);
59
60 /**
61  * change bluetooth adapter state.
62  * @param[in]   env                   JNI interface pointer.
63  * @param[in]   controlFlag           true : enable(), false : disable()
64  * @return  true or false
65  */
66 bool CAManagerControlAdapter(JNIEnv *env, bool controlFlag);
67
68 /**
69  * request to get rssi value from bluetooth
70  * @param[in]   env                   JNI interface pointer.
71  * @param[in]   bluetoothGatt         connected gatt object.
72  * @return  ::CA_STATUS_OK or Appropriate error code.
73  */
74 CAResult_t CAManagerReadRemoteRssi(JNIEnv *env, jobject bluetoothGatt);
75
76 /**
77  * get SharedPreference from context of application.
78  * @param[in]   env                   JNI interface pointer.
79  * @param[in]   context               Application context interface.
80  * @param[in]   prefName              preferences name.
81  * @return  SharedPreferences object.
82  */
83 jobject CAManagerGetSharedPreference(JNIEnv *env, jobject context, jstring prefName);
84
85 /**
86  * check whether the device is already put or not.
87  * @param[in]   env                   JNI interface pointer.
88  * @param[in]   context               Application context interface.
89  * @param[in]   address               LE address.
90  * @param[in]   set                   set<String> object related to connected list.
91  * @return  true or false
92  */
93 bool CAManagerIsConnectedDeviceAddress(JNIEnv *env, jobject context,
94                                        jstring address, jobject set);
95
96 /**
97  * get SharedPreferences.Editor object.
98  * @param[in]   env                   JNI interface pointer.
99  * @param[in]   context               Application context interface.
100  * @return  SharedPreferences.Editor object.
101  */
102 jobject CAManagerGetPrefStringSet(JNIEnv *env, jobject context);
103
104 /**
105  * update SharedPreferences for set<String> object.
106  * @param[in]   env                   JNI interface pointer.
107  * @param[in]   context               Application context interface.
108  * @param[in]   set                   set<String> object related to connected list.
109  * @return  true or false
110  */
111 bool CAManagerUpdatePrefStringSet(JNIEnv *env, jobject context, jobject set);
112
113 /**
114  * get SharedPreferences for set<String> object.
115  * @param[in]   env                   JNI interface pointer.
116  * @param[in]   context               Application context interface.
117  * @return  set<String> object from SharedPreferences
118  */
119 jobject CAManagerGetPrefStringSet(JNIEnv *env, jobject context);
120
121 /**
122  * checks whether the preferences contains a preference.
123  * @param[in]   env                   JNI interface pointer.
124  * @param[in]   context               Application context interface.
125  * @return  true or false
126  */
127 bool CAManagerContainsPrefStringSet(JNIEnv *env, jobject context);
128
129 /**
130  * add connected device into SharedPreference.
131  * @param[in]   env                   JNI interface pointer.
132  * @param[in]   context               Application context interface.
133  * @param[in]   address               ble address.
134  * @param[in]   set                   set<String> object related to connected list.
135  * @return  true or false
136  */
137 bool CAManagerAddConnectedDeviceAddress(JNIEnv *env, jobject context,
138                                         jstring address, jobject set);
139
140 /**
141  * get connected device from SharedPreference.
142  * @param[in]   env                   JNI interface pointer.
143  * @param[in]   context               Application context interface.
144  * @return  LE address of connected device.
145  */
146 jobject CAManagerGetConnectedDeviceAddress(JNIEnv *env, jobject context);
147
148 /**
149  * remove connected device to SharedPreference.
150  * @param[in]   env                   JNI interface pointer.
151  * @param[in]   context               Application context interface.
152  * @param[in]   address               LE address.
153  * @param[in]   set                   set<String> object related to connected list.
154  * @return  true or false
155  */
156 bool CAManagerRemoveConnectedDeviceAddress(JNIEnv *env, jobject context,
157                                            jstring address, jobject set);
158
159 /**
160  * Vaildate a String bluetooth address.
161  * @param[in]   env                   JNI interface pointer.
162  * @param[in]   address               LE address.
163  * @return  JNI_TRUE or JNI_FALSE
164  */
165 jboolean CAManagerCheckBTAddress(JNIEnv *env, jstring address);
166
167 /**
168  * create new set<String> object.
169  * @param[in]   env                   JNI interface pointer.
170  * @return  set<String> object
171  */
172 jobject CAManagerCreateSetString(JNIEnv *env);
173
174 /**
175  * remove connected device to SharedPreference.
176  * @param[in]   env                   JNI interface pointer.
177  * @param[in]   address               LE address.
178  * @param[in]   set                   set<String> object related to connected list.
179  * @param[in]   method_type           method name to get its ID.
180  * @return  true or false
181  */
182 bool CAManagerCallFuncSetString(JNIEnv *env, jstring address,
183                                 jobject set, CASetMethod_t method_type);
184
185 #ifdef __cplusplus
186 } /* extern "C" */
187 #endif
188
189 #endif /* CA_MANAGER_LE_UTILS_H_ */