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

Commit ac50637a authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10071751 from a5a1e076 to udc-qpr1-release

Change-Id: I8a73af2287acb2ed8d6474ba72187711cb804bed
parents 04804e16 a5a1e076
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -40,4 +40,5 @@ cc_library {
    srcs: ["src/BindToDeviceSocketMutator.cpp"],
    export_include_dirs: ["include"],
    defaults: ["BindToDeviceSocketMutatorDefaults"],
    header_libs: ["libgrpc++_internal_headers"],
}
+2 −64
Original line number Diff line number Diff line
@@ -60,14 +60,12 @@ void BluetoothAudioSession::OnSessionStarted(
    LOG(ERROR) << __func__ << " - SessionType=" << toString(session_type_)
               << " MqDescriptor Invalid";
    audio_config_ = nullptr;
    leaudio_connection_map_ = nullptr;
  } else {
    stack_iface_ = stack_iface;
    latency_modes_ = latency_modes;
    LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_)
              << ", AudioConfiguration=" << audio_config.toString();
    ReportSessionStatus();
    is_streaming_ = false;
  }
}

@@ -76,13 +74,11 @@ void BluetoothAudioSession::OnSessionEnded() {
  bool toggled = IsSessionReady();
  LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_);
  audio_config_ = nullptr;
  leaudio_connection_map_ = nullptr;
  stack_iface_ = nullptr;
  UpdateDataPath(nullptr);
  if (toggled) {
    ReportSessionStatus();
  }
  is_streaming_ = false;
}

/***
@@ -110,14 +106,6 @@ const AudioConfiguration BluetoothAudioSession::GetAudioConfig() {
  return *audio_config_;
}

const AudioConfiguration BluetoothAudioSession::GetLeAudioConnectionMap() {
  std::lock_guard<std::recursive_mutex> guard(mutex_);
  if (!IsSessionReady()) {
    return AudioConfiguration(LeAudioConfiguration{});
  }
  return *leaudio_connection_map_;
}

void BluetoothAudioSession::ReportAudioConfigChanged(
    const AudioConfiguration& audio_config) {
  if (session_type_ !=
@@ -134,47 +122,7 @@ void BluetoothAudioSession::ReportAudioConfigChanged(
    return;
  }

  if (is_streaming_) {
    if (audio_config_ == nullptr) {
      LOG(ERROR) << __func__ << " for SessionType=" << toString(session_type_)
                 << " audio_config_ is nullptr during streaming. It shouldn't "
                    "be happened";
      return;
    }

    auto new_leaudio_config =
        audio_config.get<AudioConfiguration::leAudioConfig>();
    auto current_leaudio_config =
        (*audio_config_).get<AudioConfiguration::leAudioConfig>();
    if (new_leaudio_config.codecType != current_leaudio_config.codecType) {
      LOG(ERROR)
          << __func__ << " for SessionType=" << toString(session_type_)
          << " codec type changed during streaming. It shouldn't be happened ";
    }
    auto new_lc3_config = new_leaudio_config.leAudioCodecConfig
                              .get<LeAudioCodecConfiguration::lc3Config>();
    auto current_lc3_config = current_leaudio_config.leAudioCodecConfig
                                  .get<LeAudioCodecConfiguration::lc3Config>();
    if ((new_lc3_config.pcmBitDepth != current_lc3_config.pcmBitDepth) ||
        (new_lc3_config.samplingFrequencyHz !=
         current_lc3_config.samplingFrequencyHz) ||
        (new_lc3_config.frameDurationUs !=
         current_lc3_config.frameDurationUs) ||
        (new_lc3_config.octetsPerFrame != current_lc3_config.octetsPerFrame) ||
        (new_lc3_config.blocksPerSdu != current_lc3_config.blocksPerSdu)) {
      LOG(ERROR)
          << __func__ << " for SessionType=" << toString(session_type_)
          << " lc3 config changed during streaming. It shouldn't be happened";
      return;
    }

    leaudio_connection_map_ =
        std::make_unique<AudioConfiguration>(audio_config);
  } else {
  audio_config_ = std::make_unique<AudioConfiguration>(audio_config);
    leaudio_connection_map_ =
        std::make_unique<AudioConfiguration>(audio_config);
  }

  if (observers_.empty()) {
    LOG(WARNING) << __func__ << " - SessionType=" << toString(session_type_)
@@ -187,11 +135,7 @@ void BluetoothAudioSession::ReportAudioConfigChanged(
    LOG(INFO) << __func__ << " for SessionType=" << toString(session_type_)
              << ", bluetooth_audio=0x"
              << ::android::base::StringPrintf("%04x", cookie);
    if (is_streaming_) {
      if (cb->soft_audio_configuration_changed_cb_ != nullptr) {
        cb->soft_audio_configuration_changed_cb_(cookie);
      }
    } else if (cb->audio_configuration_changed_cb_ != nullptr) {
    if (cb->audio_configuration_changed_cb_ != nullptr) {
      cb->audio_configuration_changed_cb_(cookie);
    }
  }
@@ -481,12 +425,6 @@ void BluetoothAudioSession::ReportControlStatus(bool start_resp,
                 << " has NO port state observer";
    return;
  }
  if (start_resp && status == BluetoothAudioStatus::SUCCESS) {
    is_streaming_ = true;
  } else if (!start_resp && (status == BluetoothAudioStatus::SUCCESS ||
                             status == BluetoothAudioStatus::RECONFIGURATION)) {
    is_streaming_ = false;
  }
  for (auto& observer : observers_) {
    uint16_t cookie = observer.first;
    std::shared_ptr<PortStatusCallbacks> callback = observer.second;
+0 −16
Original line number Diff line number Diff line
@@ -102,13 +102,6 @@ struct PortStatusCallbacks {
   ***/
  std::function<void(uint16_t cookie, bool allowed)>
      low_latency_mode_allowed_cb_;
  /***
   * soft_audio_configuration_changed_cb_ - when the Bluetooth stack change
   * the streamMap during the streaming, the BluetoothAudioProvider will invoke
   * this callback to report to the bluetooth_audio module.
   * @param: cookie - indicates which bluetooth_audio output should handle
   ***/
  std::function<void(uint16_t cookie)> soft_audio_configuration_changed_cb_;
};

class BluetoothAudioSession {
@@ -165,12 +158,6 @@ class BluetoothAudioSession {
   ***/
  const AudioConfiguration GetAudioConfig();

  /***
   * The control function is for the bluetooth_audio module to get the current
   * LE audio connection map
   ***/
  const AudioConfiguration GetLeAudioConnectionMap();

  /***
   * The report function is used to report that the Bluetooth stack has notified
   * the audio configuration changed, and will invoke
@@ -219,11 +206,8 @@ class BluetoothAudioSession {
  std::unique_ptr<DataMQ> data_mq_;
  // audio data configuration for both software and offloading
  std::unique_ptr<AudioConfiguration> audio_config_;
  std::unique_ptr<AudioConfiguration> leaudio_connection_map_;
  std::vector<LatencyMode> latency_modes_;
  bool low_latency_allowed_ = true;
  // saving those steaming state based on the session_type
  bool is_streaming_ = false;

  // saving those registered bluetooth_audio's callbacks
  std::unordered_map<uint16_t, std::shared_ptr<struct PortStatusCallbacks>>
+0 −19
Original line number Diff line number Diff line
@@ -94,25 +94,6 @@ class BluetoothAudioSessionControl {
    }
  }

  /***
   * The control API for the bluetooth_audio module to get current
   * LE audio connection map
   ***/
  static const AudioConfiguration GetLeAudioConnectionMap(
      const SessionType& session_type) {
    std::shared_ptr<BluetoothAudioSession> session_ptr =
        BluetoothAudioSessionInstance::GetSessionInstance(session_type);
    if ((session_type ==
             SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH ||
         session_type ==
             SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH) &&
        session_ptr != nullptr) {
      return session_ptr->GetLeAudioConnectionMap();
    }

    return AudioConfiguration(LeAudioConfiguration{});
  }

  /***
   * Those control APIs for the bluetooth_audio module to start / suspend /
  stop
+18 −4
Original line number Diff line number Diff line
@@ -75,6 +75,12 @@ class WifiRttControllerAidlTest : public testing::TestWithParam<std::string> {
        return rtt_controller;
    }

    RttCapabilities getCapabilities() {
        RttCapabilities caps = {};
        EXPECT_TRUE(wifi_rtt_controller_->getCapabilities(&caps).isOk());
        return caps;
    }

    std::shared_ptr<IWifiRttController> wifi_rtt_controller_;

  private:
@@ -117,6 +123,11 @@ TEST_P(WifiRttControllerAidlTest, GetCapabilities) {
 * GetResponderInfo
 */
TEST_P(WifiRttControllerAidlTest, GetResponderInfo) {
    RttCapabilities caps = getCapabilities();
    if (!caps.responderSupported) {
        GTEST_SKIP() << "Skipping because responder is not supported";
    }

    RttResponder responder = {};
    EXPECT_TRUE(wifi_rtt_controller_->getResponderInfo(&responder).isOk());
}
@@ -125,6 +136,11 @@ TEST_P(WifiRttControllerAidlTest, GetResponderInfo) {
 * EnableResponder
 */
TEST_P(WifiRttControllerAidlTest, EnableResponder) {
    RttCapabilities caps = getCapabilities();
    if (!caps.responderSupported) {
        GTEST_SKIP() << "Skipping because responder is not supported";
    }

    int cmdId = 55;
    WifiChannelInfo channelInfo;
    channelInfo.width = WifiChannelWidthInMhz::WIDTH_80;
@@ -142,8 +158,7 @@ TEST_P(WifiRttControllerAidlTest, EnableResponder) {
 * Tests the two sided ranging - 802.11mc FTM protocol.
 */
TEST_P(WifiRttControllerAidlTest, Request2SidedRangeMeasurement) {
    RttCapabilities caps = {};
    EXPECT_TRUE(wifi_rtt_controller_->getCapabilities(&caps).isOk());
    RttCapabilities caps = getCapabilities();
    if (!caps.rttFtmSupported) {
        GTEST_SKIP() << "Skipping two sided RTT since driver/fw does not support";
    }
@@ -179,8 +194,7 @@ TEST_P(WifiRttControllerAidlTest, Request2SidedRangeMeasurement) {
 * RangeRequest
 */
TEST_P(WifiRttControllerAidlTest, RangeRequest) {
    RttCapabilities caps = {};
    EXPECT_TRUE(wifi_rtt_controller_->getCapabilities(&caps).isOk());
    RttCapabilities caps = getCapabilities();
    if (!caps.rttOneSidedSupported) {
        GTEST_SKIP() << "Skipping one sided RTT since driver/fw does not support";
    }