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

Commit adc751c9 authored by Michael Sun's avatar Michael Sun
Browse files

btif: introduce a error struct for btav

Introduce an error struct that contains status, error code, and
optional error message. This struct is intended to be used by all btif_av
interface to provide better status/state updates.

BUG: 240781725
Tag: #floss
Test: ./build.py
Test: emerge-${BOARD} floss
Test: gd/cert/run
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines

Change-Id: Ifeb95d18420b933018712d9beadd9f5e4428591c
parent 44e07188
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -50,7 +50,8 @@ static jobject mCallbacksObj = nullptr;
static std::shared_timed_mutex callbacks_mutex;

static void bta2dp_connection_state_callback(const RawAddress& bd_addr,
                                             btav_connection_state_t state) {
                                             btav_connection_state_t state,
                                             const btav_error_t& error) {
  ALOGI("%s", __func__);

  std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex);
+2 −1
Original line number Diff line number Diff line
@@ -31,7 +31,8 @@ static const btav_sink_interface_t* sBluetoothA2dpInterface = NULL;
static jobject mCallbacksObj = NULL;

static void bta2dp_connection_state_callback(const RawAddress& bd_addr,
                                             btav_connection_state_t state) {
                                             btav_connection_state_t state,
                                             const btav_error_t& error) {
  ALOGI("%s", __func__);
  CallbackEnv sCallbackEnv(__func__);
  if (!sCallbackEnv.valid()) return;
+6 −6
Original line number Diff line number Diff line
@@ -1741,8 +1741,7 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event,
        state = BTAV_CONNECTION_STATE_DISCONNECTED;
        av_state = BtifAvStateMachine::kStateIdle;
        log_counter_metrics_btif(
              android::bluetooth::CodePathCounterKeyEnum::
              A2DP_CONNECTION_FAILURE,
            android::bluetooth::CodePathCounterKeyEnum::A2DP_CONNECTION_FAILURE,
            1);
      }

@@ -2440,11 +2439,11 @@ static void btif_report_connection_state(const RawAddress& peer_address,
  if (btif_av_source.Enabled()) {
    do_in_jni_thread(FROM_HERE,
                     base::Bind(btif_av_source.Callbacks()->connection_state_cb,
                                peer_address, state));
                                peer_address, state, btav_error_t{}));
  } else if (btif_av_sink.Enabled()) {
    do_in_jni_thread(FROM_HERE,
                     base::Bind(btif_av_sink.Callbacks()->connection_state_cb,
                                peer_address, state));
                                peer_address, state, btav_error_t{}));
  }
}

@@ -3455,7 +3454,8 @@ static void btif_debug_av_peer_dump(int fd, const BtifAvPeer& peer) {
  dprintf(fd, "    Support 3Mbps: %s\n", peer.Is3Mbps() ? "true" : "false");
  dprintf(fd, "    Self Initiated Connection: %s\n",
          peer.SelfInitiatedConnection() ? "true" : "false");
  dprintf(fd, "    Delay Reporting: %u (in 1/10 milliseconds) \n", peer.GetDelayReport());
  dprintf(fd, "    Delay Reporting: %u (in 1/10 milliseconds) \n",
          peer.GetDelayReport());
  dprintf(fd, "    Codec Preferred: %s\n",
          peer.IsMandatoryCodecPreferred() ? "Mandatory" : "Optional");
}
+2 −1
Original line number Diff line number Diff line
@@ -152,7 +152,8 @@ static ::rust::Vec<A2dpCodecConfig> to_rust_codec_config_vec(const std::vector<b
  return rconfigs;
}

static void connection_state_cb(const RawAddress& bd_addr, btav_connection_state_t state) {
static void connection_state_cb(
    const RawAddress& bd_addr, btav_connection_state_t state, [[maybe_unused]] const btav_error_t& error) {
  RustRawAddress addr = rusty::CopyToRustAddress(bd_addr);
  rusty::connection_state_callback(addr, state);
}
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ namespace rust {
namespace internal {
static A2dpSinkIntf* g_a2dp_sink_if;

static void connection_state_cb(const RawAddress&, btav_connection_state_t) {}
static void connection_state_cb(const RawAddress&, btav_connection_state_t, const btav_error_t&) {}
static void audio_state_cb(const RawAddress&, btav_audio_state_t) {}
static void audio_config_cb(const RawAddress&, uint32_t, uint8_t) {}

Loading