+
+int _bt_set_passkey_notification(const char *sender, gboolean enable)
+{
+ int result;
+
+ BT_INFO("Set passkey notification(sender:%s, %s)",
+ sender, enable ? "Enable" : "Disable");
+
+ result = device_enable_gap_auth_notifications(OAL_PASSKEY_DISPLAY,enable);
+ if (OAL_STATUS_SUCCESS != result) {
+ BT_ERR("device_enable_gap_auth_notifications error: [%d]", result);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ g_free(passkey_watcher);
+ if (enable == TRUE)
+ passkey_watcher = g_strdup(sender);
+ else
+ passkey_watcher = NULL;
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+static int __bt_get_device_pin_code(const char *address, char *pin_code)
+{
+ GSList *l = NULL;
+
+ BT_CHECK_PARAMETER(address, return);
+ BT_CHECK_PARAMETER(pin_code, return);
+
+ for (l = pin_info_list; l != NULL; l = l->next) {
+ bt_pin_code_info_t *pin_info = l->data;
+
+ if (!pin_info || !pin_info->address)
+ continue;
+
+ if (g_strcmp0(pin_info->address, address) == 0) {
+ g_strlcpy(pin_code, pin_info->pin_code,
+ BLUETOOTH_PIN_CODE_MAX_LENGTH + 1);
+ return BLUETOOTH_ERROR_NONE;
+ }
+ }
+
+ return BLUETOOTH_ERROR_NOT_FOUND;
+}
+
+int _bt_set_pin_code(bluetooth_device_address_t *device_address,
+ bluetooth_device_pin_code_t *pin_code)
+{
+ char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+ bt_pin_code_info_t *pin_info = NULL;
+ GSList *l = NULL;
+
+ BT_CHECK_PARAMETER(device_address, return);
+ BT_CHECK_PARAMETER(pin_code, return);
+ retv_if(g_slist_length(pin_info_list) >= BT_DEVICE_PIN_CODE_SLOT_MAX,
+ BLUETOOTH_ERROR_NO_RESOURCES);
+
+ _bt_convert_addr_type_to_string(address, device_address->addr);
+
+ for (l = pin_info_list; l != NULL; l = l->next) {
+ pin_info = l->data;
+
+ if (!pin_info || !pin_info->address)
+ continue;
+
+ if (g_strcmp0(pin_info->address, address) == 0) {
+ g_free(pin_info->pin_code);
+ pin_info->pin_code = g_strdup(pin_code->pin_code);
+ return BLUETOOTH_ERROR_NONE;
+ }
+ }
+
+ pin_info = g_malloc0(sizeof(bt_pin_code_info_t));
+ pin_info->address = g_strdup(address);
+ pin_info->pin_code = g_strdup(pin_code->pin_code);
+ pin_info_list = g_slist_append(pin_info_list, pin_info);
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_unset_pin_code(bluetooth_device_address_t *device_address)
+{
+ char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+ bt_pin_code_info_t *pin_info = NULL;
+ GSList *l = NULL;
+
+ BT_DBG("+");
+
+ BT_CHECK_PARAMETER(device_address, return);
+
+ _bt_convert_addr_type_to_string(address, device_address->addr);
+
+ for (l = pin_info_list; l != NULL; l = l->next) {
+ pin_info = l->data;
+
+ if (!pin_info || !pin_info->address)
+ continue;
+
+ if (g_strcmp0(pin_info->address, address) == 0) {
+ pin_info_list = g_slist_remove(pin_info_list, pin_info);
+ g_free(pin_info->pin_code);
+ g_free(pin_info->pin_code);
+ g_free(pin_info);
+ break;
+ }
+ }
+
+ BT_DBG("-");
+ return BLUETOOTH_ERROR_NONE;
+}