aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukasz Rymanowski <lukasz.rymanowski@tieto.com>2011-11-07 15:57:10 +0100
committerJohan Hedberg <johan.hedberg@intel.com>2011-11-10 10:24:46 +0200
commit519ff20d9e0c5c9ba9305e33f77fd5db64c78dc4 (patch)
treec66115834ed913d9ba143d020c3e56507806957e
parent2d6ca05225233510fcd6e241629c0953c276251c (diff)
downloadbluez-519ff20d9e0c5c9ba9305e33f77fd5db64c78dc4.tar.gz
bluez-519ff20d9e0c5c9ba9305e33f77fd5db64c78dc4.tar.xz
bluez-519ff20d9e0c5c9ba9305e33f77fd5db64c78dc4.zip
SAP: Fix handling ongoing call
If device is in ongoing call SAP server shall response on connect with connection status 0x04 and once call is ended shall send reset status indication. With this patch, when reset status indication comes from backend and SAP server is in connection in progreess state, SAP server changes state to connected.
-rw-r--r--sap/server.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/sap/server.c b/sap/server.c
index 06a4361e..b8aa8a5c 100644
--- a/sap/server.c
+++ b/sap/server.c
@@ -60,6 +60,7 @@
enum {
SAP_STATE_DISCONNECTED,
SAP_STATE_CONNECT_IN_PROGRESS,
+ SAP_STATE_CONNECT_MODEM_BUSY,
SAP_STATE_CONNECTED,
SAP_STATE_GRACEFUL_DISCONNECT,
SAP_STATE_IMMEDIATE_DISCONNECT,
@@ -349,7 +350,8 @@ static int disconnect_req(struct sap_connection *conn, uint8_t disc_type)
switch (disc_type) {
case SAP_DISCONNECTION_TYPE_GRACEFUL:
if (conn->state == SAP_STATE_DISCONNECTED ||
- conn->state == SAP_STATE_CONNECT_IN_PROGRESS)
+ conn->state == SAP_STATE_CONNECT_IN_PROGRESS ||
+ conn->state == SAP_STATE_CONNECT_MODEM_BUSY)
return -EPERM;
if (conn->state == SAP_STATE_CONNECTED) {
@@ -365,7 +367,8 @@ static int disconnect_req(struct sap_connection *conn, uint8_t disc_type)
case SAP_DISCONNECTION_TYPE_IMMEDIATE:
if (conn->state == SAP_STATE_DISCONNECTED ||
- conn->state == SAP_STATE_CONNECT_IN_PROGRESS)
+ conn->state == SAP_STATE_CONNECT_IN_PROGRESS ||
+ conn->state == SAP_STATE_CONNECT_MODEM_BUSY)
return -EPERM;
if (conn->state == SAP_STATE_CONNECTED ||
@@ -602,6 +605,17 @@ static gboolean guard_timeout(gpointer data)
return FALSE;
}
+static void sap_set_connected(struct sap_connection *conn)
+{
+ gboolean connected = TRUE;
+
+ emit_property_changed(connection, server->path,
+ SAP_SERVER_INTERFACE,
+ "Connected", DBUS_TYPE_BOOLEAN, &connected);
+
+ conn->state = SAP_STATE_CONNECTED;
+}
+
int sap_connect_rsp(void *sap_device, uint8_t status, uint16_t maxmsgsize)
{
struct sap_connection *conn = sap_device;
@@ -643,13 +657,10 @@ int sap_connect_rsp(void *sap_device, uint8_t status, uint16_t maxmsgsize)
}
if (status == SAP_STATUS_OK) {
- gboolean connected = TRUE;
-
- emit_property_changed(connection, server->path,
- SAP_SERVER_INTERFACE,
- "Connected", DBUS_TYPE_BOOLEAN, &connected);
-
- conn->state = SAP_STATE_CONNECTED;
+ sap_set_connected(conn);
+ } else if (status == SAP_STATUS_OK_ONGOING_CALL) {
+ DBG("ongoing call. Wait for reset indication!");
+ conn->state = SAP_STATE_CONNECT_MODEM_BUSY;
} else {
conn->state = SAP_STATE_DISCONNECTED;
@@ -962,6 +973,11 @@ int sap_status_ind(void *sap_device, uint8_t status_change)
DBG("state %d pr 0x%02x sc 0x%02x", conn->state, conn->processing_req,
status_change);
+ /* Might be need to change state to connected after ongoing call.*/
+ if (conn->state == SAP_STATE_CONNECT_MODEM_BUSY &&
+ status_change == SAP_STATUS_CHANGE_CARD_RESET)
+ sap_set_connected(conn);
+
if (conn->state != SAP_STATE_CONNECTED &&
conn->state != SAP_STATE_GRACEFUL_DISCONNECT)
return 0;
@@ -1111,12 +1127,14 @@ static void sap_io_destroy(void *data)
stop_guard_timer(conn);
- if (conn->state != SAP_STATE_CONNECT_IN_PROGRESS)
+ if (conn->state != SAP_STATE_CONNECT_IN_PROGRESS &&
+ conn->state != SAP_STATE_CONNECT_MODEM_BUSY)
emit_property_changed(connection, server->path,
SAP_SERVER_INTERFACE, "Connected",
DBUS_TYPE_BOOLEAN, &connected);
if (conn->state == SAP_STATE_CONNECT_IN_PROGRESS ||
+ conn->state == SAP_STATE_CONNECT_MODEM_BUSY ||
conn->state == SAP_STATE_CONNECTED ||
conn->state == SAP_STATE_GRACEFUL_DISCONNECT)
sap_disconnect_req(NULL, 1);