Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 28faf875 authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

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
parent d7e8cd7a
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -88,6 +88,11 @@ bool btif_a2dp_on_started(const RawAddress& peer_addr,
          }
          }
          ack = true;
          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 */
      /* media task is autostarted upon a2dp audiopath connection */
+9 −3
Original line number Original line Diff line number Diff line
@@ -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 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 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",
        BTIF_TRACE_WARNING("%s: Peer %s : trigger Suspend as remote initiated",
                           __PRETTY_FUNCTION__,
                           __PRETTY_FUNCTION__,
                           peer_.PeerAddress().ToString().c_str());
                           peer_.PeerAddress().ToString().c_str());
        btif_av_source_dispatch_sm_event(peer_.PeerAddress(),
        should_suspend = true;
                                         BTIF_AV_SUSPEND_STREAM_REQ_EVT);
      }
      }


      // If peer is A2DP Source, we do not want to ACK commands on UIPC
      // 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);
        btif_a2dp_on_started(peer_.PeerAddress(), nullptr, true);
        // Pending start flag will be cleared when exit current state
        // 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);
      peer_.StateMachine().TransitionTo(BtifAvStateMachine::kStateStarted);


    } break;
    } break;