summaryrefslogtreecommitdiffstats
path: root/src/com/android/bluetooth
diff options
context:
space:
mode:
authorHemant Gupta <hemantg@codeaurora.org>2015-09-29 20:35:40 +0200
committerAndre Eisenbach <eisenbach@google.com>2015-10-07 11:40:33 -0700
commitfaf199e456dbb987f343c829c603c035df10add7 (patch)
tree8776b6bbe72db0c0e2853500b78850eba1fdaafd /src/com/android/bluetooth
parent704e3f3af7cf84f51e9fbed82559f40b390ef62c (diff)
downloadandroid_packages_apps_Bluetooth-faf199e456dbb987f343c829c603c035df10add7.tar.gz
android_packages_apps_Bluetooth-faf199e456dbb987f343c829c603c035df10add7.tar.bz2
android_packages_apps_Bluetooth-faf199e456dbb987f343c829c603c035df10add7.zip
SAP: Fix missing connect response when call ongoing at connect
The CALL_ONGOING_STATE was set twice, causing the connect response not to be sent to the peer device when there was an ongoing call on DUT. This was violating the SAP Spec. Bug: 24520367 Change-Id: I290d924870381a82a4abd8b6c42a6d0ebf55652f
Diffstat (limited to 'src/com/android/bluetooth')
-rw-r--r--src/com/android/bluetooth/sap/SapServer.java35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/com/android/bluetooth/sap/SapServer.java b/src/com/android/bluetooth/sap/SapServer.java
index 87856b3d8..339f67631 100644
--- a/src/com/android/bluetooth/sap/SapServer.java
+++ b/src/com/android/bluetooth/sap/SapServer.java
@@ -422,7 +422,10 @@ public class SapServer extends Thread implements Callback {
* - Initiate a FORCED shutdown
* - Wait for RIL deinit to complete
*/
- if(mState != SAP_STATE.DISCONNECTED) {
+ if (mState == SAP_STATE.CONNECTING_CALL_ONGOING) {
+ /* Most likely remote device closed rfcomm, update state */
+ changeState(SAP_STATE.DISCONNECTED);
+ } else if (mState != SAP_STATE.DISCONNECTED) {
if(mState != SAP_STATE.DISCONNECTING &&
mIsLocalInitDisconnect != true) {
sendDisconnectInd(SapMessage.DISC_FORCED);
@@ -509,7 +512,6 @@ public class SapServer extends Thread implements Callback {
if (isCallOngoing() == true) {
/* If a call is ongoing we set the state, inform the SAP client and wait for a state
* change intent from the TelephonyManager with state IDLE. */
- changeState(SAP_STATE.CONNECTING_CALL_ONGOING);
reply.setConnectionStatus(SapMessage.CON_STATUS_OK_ONGOING_CALL);
} else {
/* no call is ongoing, initiate the connect sequence:
@@ -651,11 +653,12 @@ public class SapServer extends Thread implements Callback {
if(DEBUG) Log.i(TAG_HANDLER, "in Shutdown()");
try {
- mRfcommOut.close();
+ if (mRfcommOut != null)
+ mRfcommOut.close();
} catch (IOException e) {}
try {
- mRfcommIn.close();
-
+ if (mRfcommIn != null)
+ mRfcommIn.close();
} catch (IOException e) {}
mRfcommIn = null;
mRfcommOut = null;
@@ -714,19 +717,25 @@ public class SapServer extends Thread implements Callback {
switch(sapMsg.getMsgType()) {
case SapMessage.ID_CONNECT_RESP:
- if (sapMsg.getConnectionStatus() == SapMessage.CON_STATUS_OK) {
- // This is successful connect response from RIL/modem.
- changeState(SAP_STATE.CONNECTED);
- } else if(sapMsg.getConnectionStatus() == SapMessage.CON_STATUS_OK_ONGOING_CALL
- && mState != SAP_STATE.CONNECTING_CALL_ONGOING) {
- changeState(SAP_STATE.CONNECTING_CALL_ONGOING);
- } else if(mState == SAP_STATE.CONNECTING_CALL_ONGOING) {
+ if(mState == SAP_STATE.CONNECTING_CALL_ONGOING) {
/* Hold back the connect resp if a call was ongoing when the connect req
- * was received.
+ * was received.
+ * A response with status call-ongoing was sent, and the connect response
+ * received from the RIL when call ends must be discarded.
*/
+ if (sapMsg.getConnectionStatus() == SapMessage.CON_STATUS_OK) {
+ // This is successful connect response from RIL/modem.
+ changeState(SAP_STATE.CONNECTED);
+ }
if(VERBOSE) Log.i(TAG, "Hold back the connect resp, as a call was ongoing" +
" when the initial response were sent.");
sapMsg = null;
+ } else if (sapMsg.getConnectionStatus() == SapMessage.CON_STATUS_OK) {
+ // This is successful connect response from RIL/modem.
+ changeState(SAP_STATE.CONNECTED);
+ } else if(sapMsg.getConnectionStatus() ==
+ SapMessage.CON_STATUS_OK_ONGOING_CALL) {
+ changeState(SAP_STATE.CONNECTING_CALL_ONGOING);
} else if(sapMsg.getConnectionStatus() != SapMessage.CON_STATUS_OK) {
/* Most likely the peer will try to connect again, hence we keep the
* connection to RIL open and stay in connecting state.