Merge branch 'master' into 'security-basecamp'
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_edr_adapter / android / caedrutils.h
1 /* ****************************************************************
2  *
3  * Copyright 2014 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 /**
22  * @file
23  * This file contains the APIs for BT communications.
24  */
25 #ifndef CA_EDR_UTILS_H_
26 #define CA_EDR_UTILS_H_
27
28 #include "cacommon.h"
29 #include "cathreadpool.h"
30 #include "uarraylist.h"
31 #include "caedrinterface.h"
32 #include "jni.h"
33
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38
39 /**
40  * Get address from device socket.
41  * @param[in]   env                 JNI interface pointer.
42  * @param[in]   bluetoothSocketObj  bluetooth socket object.
43  * @return  Bluetooth device address.
44  */
45 jstring CAEDRNativeGetAddressFromDeviceSocket(JNIEnv *env, jobject bluetoothSocketObj);
46
47 /**
48  * Get local device address.
49  * @param[in]   env                 JNI interface pointer.
50  * @return  Bluetooth device address.
51  */
52 jstring CAEDRNativeGetLocalDeviceAddress(JNIEnv *env);
53
54 /**
55  * Get bonded devices list.
56  * @param[in]   env                 JNI interface pointer.
57  * @return  Bonded devices list.
58  */
59 jobjectArray CAEDRNativeGetBondedDevices(JNIEnv *env);
60
61 /**
62  * Get Bluetooth device state.
63  * @param[in]   env                 JNI interface pointer.
64  * @return  Bluetooth device state.
65  */
66 jint CAEDRNativeGetBTStateOnInfo(JNIEnv *env);
67
68 /**
69  * Check the BT Adapter enable.
70  * @param[in]   env                 JNI interface pointer.
71  * @return  JNI_TRUE or JNI_FALSE.
72  */
73 jboolean CAEDRNativeIsEnableBTAdapter(JNIEnv *env);
74
75 /**
76  * Get address from BT device.
77  * @param[in]   env                 JNI interface pointer.
78  * @param[in]   bluetoothDevice     bluetooth socket object.
79  * @return  Bluetooth device address.
80  */
81 jstring CAEDRNativeGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice);
82
83 /**
84  * This function will create the device state list.
85  */
86 void CAEDRNativeCreateDeviceStateList();
87
88 /**
89  * Update connection state of device.
90  * @param[in]  state            connection state.
91  * @param[in]  address          remote address.
92  */
93 void CAEDRUpdateDeviceState(CAConnectedState_t state, const char *address);
94
95 /**
96  * Add device object to the list.
97  * @param[in]  state            connection state object.
98  */
99 void CAEDRNativeAddDeviceStateToList(state_t *state);
100
101 /**
102  * Check whether the device exist in the list or not.
103  * @param[in]  remoteAddress    remote address.
104  * @return true or false.
105  */
106 bool CAEDRNativeIsDeviceInList(const char *remoteAddress);
107
108 /**
109  * Close all socket.
110  * @param[in]   env       JNI interface pointer.
111  */
112 void CAEDRNativeSocketCloseToAll(JNIEnv *env);
113
114 /**
115  * Remove all device objects in the list.
116  */
117 void CAEDRNativeRemoveAllDeviceState();
118
119 /**
120  * Remove target device in the list.
121  * @param[in]   remoteAddress    remote address.
122  */
123 void CAEDRNativeRemoveDevice(const char *remoteAddress);
124
125 /**
126  * Get current device connection state.
127  * @param[in]   remoteAddress    remote address.
128  * @return  STATE_DISCONNECTED or STATE_CONNECTED.
129  */
130 CAConnectedState_t CAEDRIsConnectedDevice(const char *remoteAddress);
131
132 /**
133  * Reordering for the list.
134  * @param[in]   index           index of device list that want to reordering.
135  */
136 void CAEDRReorderingDeviceList(uint32_t index);
137
138 /**
139  * This function will create the device socket list.
140  */
141 void CAEDRNativeCreateDeviceSocketList();
142
143 /**
144  * Add device object to the list.
145  * @param[in]  env              JNI interface pointer.
146  * @param[in]  deviceSocket     device socket object.
147  */
148 void CAEDRNativeAddDeviceSocketToList(JNIEnv *env, jobject deviceSocket);
149
150 /**
151  * Add device object to the list.
152  * @param[in]  env              JNI interface pointer.
153  * @param[in]  remoteAddress    remote address.
154  * @return true or false.
155  */
156 bool CAEDRNativeIsDeviceSocketInList(JNIEnv *env, const char *remoteAddress);
157
158 /**
159  * Add device object to the list.
160  * @param[in]  env              JNI interface pointer.
161  */
162 void CAEDRNativeRemoveAllDeviceSocket(JNIEnv *env);
163
164 /**
165  * Add device object to the list.
166  * @param[in]  env              JNI interface pointer.
167  * @param[in]  deviceSocket     device socket object.
168  */
169 void CAEDRNativeRemoveDeviceSocket(JNIEnv *env, jobject deviceSocket);
170
171 /**
172  * Remove device socket.
173  * @param[in]   env             JNI interface pointer.
174  * @param[in]   address         remote address.
175  */
176 void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address);
177
178 /**
179  * Get device socket object from the list.
180  * @param[in]  idx              index of device list.
181  * @return Device socket object or NULL.
182  */
183 jobject CAEDRNativeGetDeviceSocket(uint32_t idx);
184
185 /**
186  * Get device socket address.
187  * @param[in]   env             JNI interface pointer.
188  * @param[in]   remoteAddress   remote address.
189  * @return  Device socket object or NULL.
190  */
191 jobject CAEDRNativeGetDeviceSocketBaseAddr(JNIEnv *env, const char* remoteAddress);
192
193 /**
194  * Get length of device socket list.
195  * @return length of list.
196  */
197 uint32_t CAEDRGetSocketListLength();
198
199 /**
200  * Reordering for the list.
201  * @param[in]   index           index of device list that want to reordering.
202  */
203 void CAEDRReorderingDeviceSocketList(uint32_t index);
204 #ifdef __cplusplus
205 } /* extern "C" */
206 #endif
207
208 #endif /* CA_EDR_UTILS_H_ */
209