Add the privilege check for registering HDP sink app 69/74869/1
authorHyuk Lee <hyuk0512.lee@samsung.com>
Thu, 16 Jun 2016 02:36:05 +0000 (11:36 +0900)
committerHyuk Lee <hyuk0512.lee@samsung.com>
Thu, 16 Jun 2016 02:36:05 +0000 (11:36 +0900)
Change-Id: I960082035b23834527c36fe9066b6f8629c28185
Signed-off-by: Hyuk Lee <hyuk0512.lee@samsung.com>
bt-api/bt-hdp.c
bt-service/bt-request-handler.c
include/bt-internal-types.h

index 3c50195..e9e35fa 100755 (executable)
@@ -120,6 +120,12 @@ BT_EXPORT_API int bluetooth_hdp_activate(unsigned short data_type,
                return BLUETOOTH_ERROR_INVALID_PARAM;
        }
 
+       if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_HDP_REGISTER_SINK_APP)
+            == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+               BT_ERR("Don't have a privilege to use this API");
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       }
+
        result = __bt_hdp_internal_create_application(data_type, role,
                                                channel_type, app_handle);
 
@@ -700,6 +706,12 @@ BT_EXPORT_API int bluetooth_hdp_deactivate(const char *app_handle)
        BT_CHECK_ENABLED(return);
        BT_CHECK_PARAMETER(app_handle, return);
 
+       if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_HDP_UNREGISTER_SINK_APP)
+            == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+               BT_ERR("Don't have a privilege to use this API");
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       }
+
        return __bt_hdp_internal_destroy_application(app_handle);
 }
 
index d064cc4..2a97c5f 100644 (file)
@@ -2537,6 +2537,8 @@ gboolean __bt_service_check_privilege(int function_name,
         case BT_HDP_CONNECT:
         case BT_HDP_DISCONNECT:
         case BT_HDP_SEND_DATA:
+        case BT_HDP_REGISTER_SINK_APP:
+        case BT_HDP_UNREGISTER_SINK_APP:
 
         case BT_DPM_SET_ALLOW_BT_MODE:
         case BT_DPM_GET_ALLOW_BT_MODE:
index 936f73b..0709514 100644 (file)
@@ -281,6 +281,8 @@ typedef enum {
        BT_HDP_CONNECT = BT_FUNC_HDP_BASE,
        BT_HDP_DISCONNECT,
        BT_HDP_SEND_DATA,
+       BT_HDP_REGISTER_SINK_APP,
+       BT_HDP_UNREGISTER_SINK_APP,
        BT_GATT_GET_PRIMARY_SERVICES = BT_FUNC_GATT_BASE,
        BT_GATT_DISCOVER_CHARACTERISTICS,
        BT_GATT_SET_PROPERTY_REQUEST,