Don't trigger AVDTP Suspend in response to AVDTP Suspend+Start from remote
If the remote device sent us AVDTP Suspend, and then AVDTP Start, don't
trigger AVDTP Suspend from the local device in response to the AVDTP Start.
Also:
* Add a call btif_av_stream_start_offload() inside btif_a2dp_on_started()
if we were started remotely.
* Fix the order of calling btif_a2dp_on_started() and triggering
an internal BTIF_AV_SUSPEND_STREAM_REQ_EVT event. Otherwise,
BTA Suspend might be called before btif_av_stream_start_offload()
Bug: 110015851
Bug: 110186160
Test: Manual
Change-Id: I908d19f8caf5130b96a64153ff39bd4b52879713
Merged-In: I908d19f8caf5130b96a64153ff39bd4b52879713
(cherry picked from commit 7e425cef6df8fc45b1aa54fb5d39d3afeb7bb369)
diff --git a/btif/src/btif_a2dp.cc b/btif/src/btif_a2dp.cc
index 7bb79eb..d96ad5b 100644
--- a/btif/src/btif_a2dp.cc
+++ b/btif/src/btif_a2dp.cc
@@ -88,6 +88,11 @@
}
ack = true;
}
+ } else {
+ // We were started remotely
+ if (btif_av_is_a2dp_offload_enabled()) {
+ btif_av_stream_start_offload();
+ }
}
/* media task is autostarted upon a2dp audiopath connection */
diff --git a/btif/src/btif_av.cc b/btif/src/btif_av.cc
index ed10733..8d416c1 100644
--- a/btif/src/btif_av.cc
+++ b/btif/src/btif_av.cc
@@ -1756,12 +1756,13 @@
// If remote tries to start A2DP when DUT is A2DP Source, then Suspend.
// If A2DP is Sink and call is active, then disconnect the AVDTP channel.
- if (peer_.IsSink() && !peer_.CheckFlags(BtifAvPeer::kFlagPendingStart)) {
+ bool should_suspend = false;
+ if (peer_.IsSink() && !peer_.CheckFlags(BtifAvPeer::kFlagPendingStart |
+ BtifAvPeer::kFlagRemoteSuspend)) {
BTIF_TRACE_WARNING("%s: Peer %s : trigger Suspend as remote initiated",
__PRETTY_FUNCTION__,
peer_.PeerAddress().ToString().c_str());
- btif_av_source_dispatch_sm_event(peer_.PeerAddress(),
- BTIF_AV_SUSPEND_STREAM_REQ_EVT);
+ should_suspend = true;
}
// If peer is A2DP Source, we do not want to ACK commands on UIPC
@@ -1786,6 +1787,11 @@
btif_a2dp_on_started(peer_.PeerAddress(), nullptr, true);
// Pending start flag will be cleared when exit current state
}
+
+ if (should_suspend) {
+ btif_av_source_dispatch_sm_event(peer_.PeerAddress(),
+ BTIF_AV_SUSPEND_STREAM_REQ_EVT);
+ }
peer_.StateMachine().TransitionTo(BtifAvStateMachine::kStateStarted);
} break;