From bb8496ae763c3a3a2edb2f7eec13fe41f6090cdf Mon Sep 17 00:00:00 2001 From: Pavlin Radoslavov Date: Thu, 28 Jun 2018 20:10:36 -0700 Subject: [PATCH] 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) --- btif/src/btif_a2dp.cc | 5 +++++ btif/src/btif_av.cc | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/btif/src/btif_a2dp.cc b/btif/src/btif_a2dp.cc index 7bb79eb81..d96ad5bd8 100644 --- a/btif/src/btif_a2dp.cc +++ b/btif/src/btif_a2dp.cc @@ -88,6 +88,11 @@ bool btif_a2dp_on_started(const RawAddress& peer_addr, } 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 ed10733cc..8d416c132 100644 --- a/btif/src/btif_av.cc +++ b/btif/src/btif_av.cc @@ -1756,12 +1756,13 @@ bool BtifAvStateMachine::StateOpened::ProcessEvent(uint32_t event, // 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 @@ bool BtifAvStateMachine::StateOpened::ProcessEvent(uint32_t event, 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; -- 2.11.0