diff --git a/android/gatt.c b/android/gatt.c
index ecae2d8..2c725f1 100644
--- a/android/gatt.c
+++ b/android/gatt.c
return true;
}
+static uint8_t unregister_client(int client_if)
+{
+ struct gatt_app *cl;
+
+ cl = queue_remove_if(gatt_apps, match_app_by_id, INT_TO_PTR(client_if));
+ if (!cl) {
+ error("gatt: client_if=%d not found", client_if);
+
+ return HAL_STATUS_FAILED;
+ }
+
+ /*
+ * Check if there is any connect request or connected device
+ * for this client. If so, remove this client from those lists.
+ */
+ app_disconnect_devices(cl);
+ destroy_gatt_app(cl);
+
+ return HAL_STATUS_SUCCESS;
+}
+
static void handle_client_unregister(const void *buf, uint16_t len)
{
const struct hal_cmd_gatt_client_unregister *cmd = buf;
uint8_t status;
- struct gatt_app *cl;
DBG("");
- cl = queue_remove_if(gatt_apps, match_app_by_id,
- INT_TO_PTR(cmd->client_if));
- if (!cl) {
- error("gatt: client_if=%d not found", cmd->client_if);
- status = HAL_STATUS_FAILED;
- } else {
- /*
- * Check if there is any connect request or connected device
- * for this client. If so, remove this client from those lists.
- */
- app_disconnect_devices(cl);
- destroy_gatt_app(cl);
- status = HAL_STATUS_SUCCESS;
- }
+ status = unregister_client(cmd->client_if);
ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
HAL_OP_GATT_CLIENT_UNREGISTER, status);