Knox Tizen Wearable SDK
bluetooth.h
1 /*
2  * Copyright (c) 2000-2017 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * PROPRIETARY/CONFIDENTIAL
5  *
6  * This software is the confidential and proprietary information of
7  * SAMSUNG ELECTRONICS ("Confidential Information").
8  * You shall not disclose such Confidential Information and shall
9  * use it only in accordance with the terms of the license agreement
10  * you entered into with SAMSUNG ELECTRONICS.
11  * SAMSUNG make no representations or warranties about the suitability
12  * of the software, either express or implied, including but not
13  * limited to the implied warranties of merchantability, fitness for
14  * a particular purpose, or non-infringement.
15  * SAMSUNG shall not be liable for any damages suffered by licensee as
16  * a result of using, modifying or distributing this software or its derivatives.
17  */
18 
19 #ifndef LIBMDM_MDM_BLUETOOTH_H
20 #define LIBMDM_MDM_BLUETOOTH_H
21 
22 #include "mdm_client_type.h"
23 
34 typedef enum {
35  MDM_BT_ERROR = -1,
40 
46 typedef enum {
50  /* profile changed */
70 
76 typedef enum {
98  BLUETOOTH_PROFILE_END
100 
106 typedef enum {
111 
112 #ifdef __cplusplus
113 extern "C" {
114 #endif
115 
116 /*
117  * @brief API to start the discovery process of remote Bluetooth devices.
118  *
119  * @since_mdm 1.0.0
120  *
121  * @since_tizen 2.3.2.3
122  *
123  * @feature %http://developer.samsung.com/tizen/feature/mdm
124  *
125  * @par Usage:
126  * The discovery process usually involves an inquiry scan of about 12 seconds,
127  * followed by a page scan of each new device to retrieve its Bluetooth name.
128  * This is an asynchronous call that returns immediately.
129  * If Bluetooth state is not On, this API will return @c #MDM_RESULT_FAIL.
130  *
131  * @code{.c}
132 
133  mdm_result_t ret = mdm_start_bluetooth_discovery();
134  if (ret == MDM_RESULT_SUCCESS){
135  // Started Bluetooth discovery
136  } else {
137  // Failed to start Bluetooth discovery
138  }
139 
140  * @endcode
141  *
142  * @privlevel public
143  * @privilege %http://developer.samsung.com/tizen/privilege/mdm.bluetooth
144  *
145  * @return #mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
146  *
147  * @retval #MDM_RESULT_SUCCESS Successful
148  * @retval #MDM_RESULT_FAIL General failure
149  * @retval #MDM_RESULT_NOT_SUPPORTED Not supported
150  * @retval #MDM_RESULT_INVALID_PARAM Invalid parameter
151  * @retval #MDM_RESULT_ACCESS_DENIED The application does not have the privilege to call this function.
152  *
153  * @par Permission:
154  * This API is restricted to registered clients only.
155  *
156  * @see mdm_cancel_bluetooth_discovery()
157  *
158  */
159 mdm_result_t mdm_start_bluetooth_discovery(void);
160 
161 /*
162  * @brief API to cancel the current discovery process of Bluetooth remote devices.
163  *
164  * @since_mdm 1.0.0
165  *
166  * @since_tizen 2.3.2.3
167  *
168  * @feature %http://developer.samsung.com/tizen/feature/mdm
169  *
170  * @par Usage:
171  * Because discovery is a heavyweight procedure for the Bluetooth adapter,
172  * this method should always be called before attempting to connect to a remote
173  * device.
174  * If Bluetooth state is Off, this API returns @c #MDM_RESULT_FAIL.
175  *
176  * @code{.c}
177 
178  mdm_result_t ret = mdm_cancel_bluetooth_discovery();
179  if (ret == MDM_RESULT_SUCCESS){
180  // success
181  } else {
182  // fail to cancel Bluetooth discovery
183  }
184 
185  * @endcode
186  *
187  * @privlevel public
188  * @privilege %http://developer.samsung.com/tizen/privilege/mdm.bluetooth
189  *
190  * @return #mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
191  *
192  * @retval #MDM_RESULT_SUCCESS Successful
193  * @retval #MDM_RESULT_FAIL General failure
194  * @retval #MDM_RESULT_NOT_SUPPORTED Not supported
195  * @retval #MDM_RESULT_INVALID_PARAM Invalid parameter
196  * @retval #MDM_RESULT_ACCESS_DENIED The application does not have the privilege to call this function.
197  *
198  * @par Permission:
199  * This API is restricted to registered clients only.
200  *
201  * @see mdm_start_bluetooth_discovery()
202  *
203  */
204 mdm_result_t mdm_cancel_bluetooth_discovery(void);
205 
247 
248 
308 
347 
406 
442 
498 
536 
537 /*
538  * @brief API to set whether to allow Bluetooth connections from computers.
539  *
540  * @since_mdm 1.0.0
541  *
542  * @since_tizen 2.3.2.3
543  *
544  * @feature %http://developer.samsung.com/tizen/feature/mdm
545  *
546  * @par Usage:
547  * Admins can use this API to block Bluetooth connections between the
548  * device and computers (desktops or laptops).
549  * Calling this API blocks all connections to the device from any type of
550  * computer via Bluetooth.
551  *
552  * @remark
553  * Bluetooth status #mdm_bt_policy_changed_t is written to #MDM_POLICY_ON_BT notification file.
554  * You can register a callback for this event using #mdm_register_policy_receiver.
555  *
556  * @code{.c}
557 
558  mdm_result_t ret = mdm_set_bluetooth_desktop_connectivity_state(MDM_ALLOWED);
559  if (ret == MDM_RESULT_SUCCESS){
560  // success
561  }
562  else{
563  // fail
564  }
565 
566  * @endcode
567  *
568  * @privlevel public
569  * @privilege %http://developer.samsung.com/tizen/privilege/mdm.bluetooth
570  *
571  * @param[in] value Whether to allow Bluetooth connections with computers. Set
572  * to @c #MDM_ALLOWED to allow these connections, or @c
573  * #MDM_RESTRICTED to block these connections.
574  *
575  * @return #mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
576  *
577  * @retval #MDM_RESULT_SUCCESS Successful
578  * @retval #MDM_RESULT_FAIL General failure
579  * @retval #MDM_RESULT_NOT_SUPPORTED Not supported
580  * @retval #MDM_RESULT_INVALID_PARAM Invalid parameter
581  * @retval #MDM_RESULT_ACCESS_DENIED The application does not have the privilege to call this function.
582  *
583  * @par Permission:
584  * This API is restricted to registered clients only.
585  *
586  * @see mdm_get_bluetooth_desktop_connectivity_state()
587  *
588  */
589 mdm_result_t mdm_set_bluetooth_desktop_connectivity_state(mdm_status_t value);
590 
591 /*
592  * @brief API to check whether Bluetooth connections with computers are allowed.
593  *
594  * @since_mdm 1.0.0
595  *
596  * @since_tizen 2.3.2.3
597  *
598  * @feature %http://developer.samsung.com/tizen/feature/mdm
599  *
600  * @par Usage:
601  * An admin can use this API to check if it is possible to connect to a
602  * computer via Bluetooth.
603  *
604  *
605  * @code{.c}
606 
607  mdm_status_t ret = mdm_get_bluetooth_desktop_connectivity_state();
608  if (ret == MDM_ALLOWED) {
609  // allowed
610  } else if (ret == MDM_RESTRICTED) {
611  // restricted
612  } else (ret == MDM_STATUS_ERROR){
613  // error
614  }
615 
616  * @endcode
617  *
618  * @return mdm_status_t : Whether Bluetooth connections with computers are allowed.
619  *
620  * @retval #MDM_ALLOWED Connections are allowed
621  * @retval #MDM_RESTRICTED Otherwise
622  *
623  * @see mdm_set_bluetooth_desktop_connectivity_state()
624  *
625  */
626 mdm_status_t mdm_get_bluetooth_desktop_connectivity_state(void);
627 
680 
716 
770 
806 
807 /*
808  * @brief API to set whether to allow limited discoverable mode.
809  *
810  * @since_mdm 1.0.0
811  *
812  * @since_tizen 2.3.2.3
813  *
814  * @feature %http://developer.samsung.com/tizen/feature/mdm
815  *
816  * @par Usage:
817  * An admin can use this API to silently allow or restrict limited
818  * discoverable mode.
819  * If limited discoverable mode is restricted, Bluetooth will always be in
820  * discoverable mode when turned on.
821  * By default, the device is in limited discoverable mode (that is, the device
822  * can be discovered by other devices for limited period of time).
823  *
824  * @remark
825  * Bluetooth status #mdm_bt_policy_changed_t is written to #MDM_POLICY_ON_BT notification file.
826  * You can register a callback for this event using #mdm_register_policy_receiver.
827  *
828  * @code{.c}
829 
830  mdm_result_t ret = mdm_set_bluetooth_limited_discoverable_state(MDM_ALLOWED);
831  if (ret == MDM_RESULT_SUCCESS){
832  // success
833  } else {
834  // fail
835  }
836 
837  * @endcode
838  *
839  * @privlevel public
840  * @privilege %http://developer.samsung.com/tizen/privilege/mdm.bluetooth
841  *
842  * @param[in] value Whether to allow Bluetooth limited discoverable mode. Set
843  * to @c #MDM_ALLOWED to allow limited discovery, or
844  * @c #MDM_RESTRICTED to set it to restricted.
845  *
846  * @return #mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
847  *
848  * @retval #MDM_RESULT_SUCCESS Successful
849  * @retval #MDM_RESULT_FAIL General failure
850  * @retval #MDM_RESULT_NOT_SUPPORTED Not supported
851  * @retval #MDM_RESULT_INVALID_PARAM Invalid parameter
852  * @retval #MDM_RESULT_ACCESS_DENIED The application does not have the privilege to call this function.
853  *
854  * @par Permission:
855  * This API is restricted to registered clients only.
856  *
857  * @see mdm_get_bluetooth_limited_discoverable_state()
858  *
859  */
860 mdm_result_t mdm_set_bluetooth_limited_discoverable_state(mdm_status_t value);
861 
862 /*
863  * @brief API to check whether limited discoverable mode is allowed.
864  *
865  * @since_mdm 1.0.0
866  *
867  * @since_tizen 2.3.2.3
868  *
869  * @feature %http://developer.samsung.com/tizen/feature/mdm
870  *
871  * @par Usage:
872  * An admin can use this API to check whether limited discoverable mode is allowed.
873  * If limited discoverable mode is restricted, Bluetooth will always be in discoverable mode when turned on.
874  * By default, this API returns allowed, and device is in limited discoverable mode (i.e., device can be discovered by
875  other devices for a limited period of time).
876  *
877  * @code{.c}
878 
879  mdm_status_t ret = mdm_get_bluetooth_limited_discoverable_state();
880  if (ret == MDM_ALLOWED) {
881  // allowed
882  } else if (ret == MDM_RESTRICTED) {
883  // restricted
884  } else (ret == MDM_STATUS_ERROR){
885  // error
886  }
887 
888  * @endcode
889  *
890  * @return #mdm_status_t : Whether Bluetooth limited discoverable mode is allowed.
891  *
892  * @retval #MDM_ALLOWED Allowed
893  * @retval #MDM_RESTRICTED Restricted
894  *
895  * @see mdm_set_bluetooth_limited_discoverable_state()
896  *
897  */
898 mdm_status_t mdm_get_bluetooth_limited_discoverable_state(void);
899 
951 
986 
1047 
1107 
1159 
1198 
1256 
1314 
1365 
1403 
1455 
1489 
1549 
1604 
1653 
1689 
1747 
1800 
1849 
1886 
1935 
1969 
2010 
2011 /*
2012  * @brief Function to block end users from modifying Bluetooth configurations.
2013  *
2014  * @since_mdm 2.2.0
2015  *
2016  * @since_tizen 3.0.0.1
2017  *
2018  * @feature %http://developer.samsung.com/tizen/feature/mdm
2019  *
2020  * @par Usage:
2021  * Use this API to restrict end users from modifying Bluetooth configurations.
2022  * \n NOTE — This API call blocks change from any source.
2023  *
2024  * @remark
2025  * Policy value is written to #MDM_POLICY_ON_BT_CHANGE notification file.
2026  * You can register a callback for this event using #mdm_register_policy_receiver.
2027  *
2028  * @code{.c}
2029  mdm_result_t result = knox_mdm_set_allow_bluetooth_change(MDM_RESTRICTED);
2030  if(result == MDM_RESULT_SUCCESS) {
2031  // Success
2032  ...
2033  } else {
2034  // Error
2035  ...
2036  }
2037  * @endcode
2038  *
2039  * @privlevel public
2040  * @privilege %http://developer.samsung.com/tizen/privilege/mdm.bluetooth
2041  *
2042  * @param[in] status #MDM_RESTRICTED — Restricts the end user from modifying Bluetooth settings.
2043  * \n #MDM_ALLOWED — Allows the end user to modify Bluetooth settings.
2044  *
2045  * @return #mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
2046  *
2047  * @retval #MDM_RESULT_SUCCESS Successful
2048  * @retval #MDM_RESULT_FAIL General failure
2049  * @retval #MDM_RESULT_NOT_SUPPORTED Not supported
2050  * @retval #MDM_RESULT_INVALID_PARAM Invalid parameter
2051  * @retval #MDM_RESULT_ACCESS_DENIED The application does not have the privilege to call this function.
2052  *
2053  * @see knox_mdm_get_allow_bluetooth_change
2054  */
2055 mdm_result_t knox_mdm_set_allow_bluetooth_change(const mdm_status_t status);
2056 
2057 /*
2058  * @brief Function to check if end users have permission to change Bluetooth configurations.
2059  *
2060  * @since_mdm 2.2.0
2061  *
2062  * @since_tizen 3.0.0.1
2063  *
2064  * @feature %http://developer.samsung.com/tizen/feature/mdm
2065  *
2066  * @par Usage:
2067  * Use this API to check if end users have permission to change Bluetooth configurations.
2068  *
2069  * @code{.c}
2070  mdm_status_t status = mdm_get_allow_bluetooth_change();
2071  if(result == MDM_RESTRICTED) {
2072  // Changes are blocked
2073  ...
2074  } else if(result == MDM_ALLOWED) {
2075  // Changes are allowed
2076  ...
2077  }
2078  else
2079  {
2080  // ERROR
2081  ...
2082  }
2083  * @endcode
2084  *
2085  * @return #mdm_status_t : The current prevention status.
2086  *
2087  * @retval #MDM_RESTRICTED – The end user is restricted from modifying Bluetooth configurations.
2088  * @retval #MDM_ALLOWED – The end user is allowed to modify Bluetooth configuratons.
2089  * @retval #MDM_STATUS_ERROR – any error.
2090  *
2091  * @see knox_mdm_set_allow_bluetooth_change
2092  */
2093 mdm_status_t knox_mdm_get_allow_bluetooth_change(void);
2094 
2099 #ifdef __cplusplus
2100 }
2101 #endif
2102 
2103 #endif // LIBMDM_MDM_BLUETOOTH_H
mdm_data_t * mdm_get_bluetooth_devices_from_whitelist(void)
API to retrieve the list of whitelisted Bluetooth devices for all admins.
mdm_status_t mdm_get_bluetooth_discoverable_state(void)
API to check whether discoverable mode is allowed.
mdm_result_t mdm_remove_bluetooth_uuids_from_blacklist(GList *uuids)
API to remove UUIDs from the Bluetooth UUID blacklist.
mdm_data_t * mdm_get_bluetooth_devices_from_blacklist(void)
API to retrieve the list of blacklisted Bluetooth devices for all admins.
This structure is used to store GList.
mdm_status_t mdm_get_bluetooth_data_transfer_state(void)
API to get whether data transfer via Bluetooth is allowed.
mdm_result_t mdm_clear_bluetooth_devices_from_whitelist(void)
API to clear all devices from the Bluetooth device whitelist.
mdm_result_t mdm_remove_bluetooth_uuids_from_whitelist(GList *uuids)
API to remove UUIDs from the Bluetooth UUID whitelist.
mdm_result_t mdm_clear_bluetooth_devices_from_blacklist(void)
API to remove all devices from Bluetooth device blacklist.
mdm_bt_allow_t mdm_get_allow_bluetooth_mode(void)
API to check whether the mode of the Bluetooth capability is allowed, restricted, or set as "hands-fr...
mdm_result_t mdm_set_allow_bluetooth_mode(mdm_bt_allow_t state)
API to set the Bluetooth capability mode on the device.
mdm_bt_allow_t
Enum type for Bluetooth allowance types.
Definition: bluetooth.h:34
mdm_status_t
MDM Policy status.
mdm_result_t mdm_add_bluetooth_uuids_to_blacklist(GList *uuids)
API to add UUIDs to the Bluetooth UUID blacklist.
mdm_data_t * mdm_get_bluetooth_bonded_device_list(void)
API to get a list of the bonded (paired) devices to the local adapter.
mdm_status_t mdm_get_bluetooth_profile_state(mdm_bt_profile_t profile)
API to check whether a specific Bluetooth profile is allowed.
mdm_result_t mdm_set_allow_bluetooth_outgoing_call(mdm_status_t value)
API to set whether to allow the transfer of outgoing calls to Bluetooth headsets. ...
mdm_result_t mdm_activate_bluetooth_uuid_restriction(mdm_status_t value)
API to activate or deactivate Bluetooth UUID restrictions.
mdm_result_t mdm_add_bluetooth_devices_to_blacklist(GList *devices)
API to add devices to the Bluetooth device blacklist.
mdm_result_t mdm_clear_bluetooth_uuids_from_whitelist(void)
API to clear all UUIDs from Bluetooth UUID whitelist.
mdm_status_t mdm_get_bluetooth_pairing_state(void)
API to check whether Bluetooth pairing is allowed.
mdm_status_t mdm_is_bluetooth_uuid_restriction_active(void)
API to check if Bluetooth UUID restrictions are active.
mdm_bt_profile_t
Enum type for Bluetooth profiles.
Definition: bluetooth.h:76
mdm_result_t mdm_set_bluetooth_data_transfer_state(mdm_status_t value)
API to set whether to allow data transfer via Bluetooth.
mdm_result_t
MDM API result.
mdm_result_t mdm_set_bluetooth_profile_state(mdm_status_t state, mdm_bt_profile_t profile)
API to set the state of a Bluetooth profile.
mdm_bt_policy_changed_t
Enum type for Bluetooth profile changes.
Definition: bluetooth.h:46
mdm_result_t mdm_add_bluetooth_devices_to_whitelist(GList *devices)
API to add devices to the Bluetooth device whitelist.
mdm_result_t mdm_activate_bluetooth_device_restriction(mdm_status_t value)
API to activate or deactivate Bluetooth device restrictions.
mdm_result_t mdm_set_bluetooth_pairing_state(mdm_status_t value)
API to set whether to allow Bluetooth pairing with other Bluetooth devices.
mdm_data_t * mdm_get_bluetooth_uuids_from_blacklist(void)
API to retrieve the list of blacklisted Bluetooth UUIDs for all admins.
mdm_result_t mdm_remove_bluetooth_devices_from_whitelist(GList *devices)
API to remove devices from the Bluetooth device whitelist.
mdm_result_t mdm_set_bluetooth_discoverable_state(mdm_status_t value)
API to set whether to allow Bluetooth discovery.
knox_mdm_mobile_wearable_status_t
Enum type for the wearable connection status.
Definition: bluetooth.h:106
mdm_status_t mdm_get_allow_bluetooth_outgoing_call(void)
API to check whether outgoing calls are allowed via a Bluetooth headset.
mdm_result_t mdm_clear_bluetooth_uuids_from_blacklist(void)
API to clear all UUIDs from Bluetooth UUID blacklist.
mdm_result_t mdm_add_bluetooth_uuids_to_whitelist(GList *uuids)
API to add UUIDs to the Bluetooth UUID whitelist.
mdm_result_t mdm_remove_bluetooth_devices_from_blacklist(GList *devices)
API to remove devices from the Bluetooth device blacklist.
mdm_data_t * mdm_get_bluetooth_uuids_from_whitelist(void)
API to retrieve the list of whitelisted Bluetooth UUIDs for all admins.
mdm_status_t mdm_is_bluetooth_device_restriction_active(void)
API to check if Bluetooth device restrictions are active.
mdm_result_t knox_mdm_get_mobile_wearable_connection_status(knox_mdm_mobile_wearable_status_t *status)
API to get the connection status between a wearable device and a mobile device.