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

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

Merge cherrypicks of ['android-review.googlesource.com/3285554',...

Merge cherrypicks of ['android-review.googlesource.com/3285554', 'android-review.googlesource.com/3285555', 'android-review.googlesource.com/3284617', 'android-review.googlesource.com/3284516', 'android-review.googlesource.com/3294791', 'android-review.googlesource.com/3295153', 'googleplex-android-review.googlesource.com/29827197'] into 24Q4-release.

Change-Id: I989412fbe1c341a41d577cce51d6f0c68583a114
parents 937e96b8 25b2f1e8
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ public class GattService extends ProfileService {

    private static final Integer GATT_MTU_MAX = 517;
    private static final Map<String, Integer> EARLY_MTU_EXCHANGE_PACKAGES =
            Map.of("com.teslamotors.tesla", GATT_MTU_MAX);
            Map.of("com.teslamotors", GATT_MTU_MAX);

    @VisibleForTesting static final int GATT_CLIENT_LIMIT_PER_APP = 32;

@@ -2150,14 +2150,19 @@ public class GattService extends ProfileService {

        // Some applications expect MTU to be exchanged immediately on connections
        String packageName = attributionSource.getPackageName();
        if (packageName != null && EARLY_MTU_EXCHANGE_PACKAGES.containsKey(packageName)) {
            preferredMtu = EARLY_MTU_EXCHANGE_PACKAGES.get(packageName);
        if (packageName != null) {
            for (Map.Entry<String, Integer> entry : EARLY_MTU_EXCHANGE_PACKAGES.entrySet()) {
                if (packageName.contains(entry.getKey())) {
                    preferredMtu = entry.getValue();
                    Log.i(
                            TAG,
                            "Early MTU exchange preference ("
                                    + preferredMtu
                                    + ") requested for "
                                    + packageName);
                    break;
                }
            }
        }

        mNativeInterface.gattClientConnect(
+12 −1
Original line number Diff line number Diff line
@@ -31,8 +31,10 @@

#include "bta/dm/bta_dm_disc_int.h"
#include "bta/include/bta_gatt_api.h"
#include "btif/include/btif_storage.h"
#include "common/circular_buffer.h"
#include "common/strings.h"
#include "device/include/interop.h"
#include "internal_include/bt_target.h"
#include "main/shim/dumpsys.h"
#include "os/logging/log_adapter.h"
@@ -273,8 +275,17 @@ static void bta_dm_disc_result(tBTA_DM_SVC_RES& disc_result) {
    bta_dm_discovery_cb.service_search_cbacks.on_service_discovery_results(r.bd_addr, r.uuids,
                                                                           r.result);
  } else {
    char remote_name[BD_NAME_LEN] = "";
    bta_dm_discovery_cb.transports &= ~BT_TRANSPORT_LE;
    if (btif_storage_get_stored_remote_name(bta_dm_discovery_cb.peer_bdaddr, remote_name) &&
        interop_match_name(INTEROP_DISABLE_LE_CONN_PREFERRED_PARAMS, remote_name)) {
      // Some devices provide PPCP values that are incompatible with the device-side firmware.
      log::info("disable PPCP read: interop matched name {} address {}", remote_name,
                bta_dm_discovery_cb.peer_bdaddr);
    } else {
      log::info("reading PPCP");
      GAP_BleReadPeerPrefConnParams(bta_dm_discovery_cb.peer_bdaddr);
    }

    bta_dm_discovery_cb.service_search_cbacks.on_gatt_results(bta_dm_discovery_cb.peer_bdaddr,
                                                              disc_result.gatt_uuids,
+12 −11
Original line number Diff line number Diff line
@@ -4570,8 +4570,6 @@ public:
    /* Set the remote sink metadata context from the playback tracks metadata */
    local_metadata_context_types_.source = GetAudioContextsFromSourceMetadata(source_metadata);

    local_metadata_context_types_.sink =
            ChooseMetadataContextType(local_metadata_context_types_.sink);
    local_metadata_context_types_.source =
            ChooseMetadataContextType(local_metadata_context_types_.source);

@@ -4705,8 +4703,6 @@ public:

    local_metadata_context_types_.sink =
            ChooseMetadataContextType(local_metadata_context_types_.sink);
    local_metadata_context_types_.source =
            ChooseMetadataContextType(local_metadata_context_types_.source);

    /* Reconfigure or update only if the stream is already started
     * otherwise wait for the local sink to resume.
@@ -4753,20 +4749,25 @@ public:
      SetInVoipCall(false);
    }

    BidirectionalPair<AudioContexts> remote_metadata = {
            .sink = local_metadata_context_types_.source,
            .source = local_metadata_context_types_.sink};

    /* Make sure we have CONVERSATIONAL when in a call and it is not mixed
     * with any other bidirectional context
     */
    if (IsInCall() || IsInVoipCall()) {
      log::debug("In Call preference used: {}, voip call: {}", IsInCall(), IsInVoipCall());
      local_metadata_context_types_.sink.unset_all(kLeAudioContextAllBidir);
      local_metadata_context_types_.source.unset_all(kLeAudioContextAllBidir);
      local_metadata_context_types_.sink.set(LeAudioContextType::CONVERSATIONAL);
      local_metadata_context_types_.source.set(LeAudioContextType::CONVERSATIONAL);
      remote_metadata.sink.unset_all(kLeAudioContextAllBidir);
      remote_metadata.source.unset_all(kLeAudioContextAllBidir);
      remote_metadata.sink.set(LeAudioContextType::CONVERSATIONAL);
      remote_metadata.source.set(LeAudioContextType::CONVERSATIONAL);
    }

    BidirectionalPair<AudioContexts> remote_metadata = {
            .sink = local_metadata_context_types_.source,
            .source = local_metadata_context_types_.sink};
    if (!com::android::bluetooth::flags::leaudio_speed_up_reconfiguration_between_call()) {
      local_metadata_context_types_.sink = remote_metadata.source;
      local_metadata_context_types_.source = remote_metadata.sink;
    }

    if (IsInVoipCall()) {
      log::debug("Unsetting RINGTONE from remote sink");
+20 −14
Original line number Diff line number Diff line
@@ -1004,9 +1004,13 @@ protected:
                                          metadata_context_types,
                                  types::BidirectionalPair<std::vector<uint8_t>> ccid_lists) {
              auto group_state = group->GetState();
              log::info("group {} state {}, context type {}", group->group_id_,
                        bluetooth::common::ToString(group_state),
                        bluetooth::common::ToString(context_type));
              log::info(
                      "StartStream: group {} state {}, context type {} sink metadata_ctx {}, "
                      "source metadata_ctx {}",
                      group->group_id_, bluetooth::common::ToString(group_state),
                      bluetooth::common::ToString(context_type),
                      bluetooth::common::ToString(metadata_context_types.sink),
                      bluetooth::common::ToString(metadata_context_types.source));
              /* Do nothing if already streaming - the implementation would
               * probably update the metadata.
@@ -10304,7 +10308,7 @@ TEST_F(UnicastTest, MusicDuringCallContextTypes) {
  available_snk_context_types_ =
          (types::LeAudioContextType::CONVERSATIONAL | types::LeAudioContextType::RINGTONE |
           types::LeAudioContextType::GAME | types::LeAudioContextType::MEDIA |
           types::LeAudioContextType::LIVE)
           types::LeAudioContextType::LIVE | types::LeAudioContextType::NOTIFICATIONS)
                  .value();
  supported_snk_context_types_ =
          available_snk_context_types_ |
@@ -10335,7 +10339,7 @@ TEST_F(UnicastTest, MusicDuringCallContextTypes) {
  LeAudioClient::Get()->GroupSetActive(group_id);
  SyncOnMainLoop();
  // 1) Start with the call first
  log::info("TESTPOINT 1: Start with the call first");
  // -----------------------------
  // CONVERSATIONAL is from In Call preference, and RINGTONE is from metadata
  LeAudioClient::Get()->SetInCall(true);
@@ -10361,7 +10365,7 @@ TEST_F(UnicastTest, MusicDuringCallContextTypes) {
  uint8_t cis_count_in = 1;
  TestAudioDataTransfer(group_id, cis_count_out, cis_count_in, 1920, 40);
  // 2) Start MEDIA during the call, expect MEDIA only on the remote sink
  log::info("TESTPOINT 2: Start MEDIA during the call, expect MEDIA only on the remote sink");
  contexts = {.sink = types::AudioContexts(types::LeAudioContextType::CONVERSATIONAL |
                                           types::LeAudioContextType::MEDIA),
              .source = types::AudioContexts(types::LeAudioContextType::CONVERSATIONAL)};
@@ -10376,25 +10380,27 @@ TEST_F(UnicastTest, MusicDuringCallContextTypes) {
  Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
  Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
  // 2) Disable In Call preference but do not suspend the local sink
  // We should stay in CONVERSATIONAL until the local sink suspends
  log::info(
          "TESTPOINT 3: Disable In Call preference but do not suspend the local sink. Play "
          "notification on the same stream.");
  // Verify both context are sent as the metadata.
  // ---------------------------------------
  LeAudioClient::Get()->SetInCall(false);
  EXPECT_CALL(mock_state_machine_, StopStream(_)).Times(0);
  contexts = {.sink = types::AudioContexts(types::LeAudioContextType::MEDIA |
  contexts = {.sink = types::AudioContexts(types::LeAudioContextType::NOTIFICATIONS |
                                           types::LeAudioContextType::CONVERSATIONAL),
              .source = types::AudioContexts(types::LeAudioContextType::CONVERSATIONAL)};
  EXPECT_CALL(mock_state_machine_,
              StartStream(_, types::LeAudioContextType::CONVERSATIONAL, contexts, _))
          .Times(1);
  UpdateLocalSourceMetadata(AUDIO_USAGE_MEDIA, AUDIO_CONTENT_TYPE_MUSIC,
  UpdateLocalSourceMetadata(AUDIO_USAGE_NOTIFICATION, AUDIO_CONTENT_TYPE_UNKNOWN,
                            /*reconfigure=*/false);
  Mock::VerifyAndClearExpectations(&mock_state_machine_);
  Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
  Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
  // 3) Disable call so we could go back to MEDIA
  log::info("TESTPOING 4: Disable call so we could go back to MEDIA");
  // ---------------------------------------
  // Suspend should stop the stream
  EXPECT_CALL(mock_state_machine_, StopStream(_)).Times(1);
@@ -10421,7 +10427,7 @@ TEST_F(UnicastTest, MusicDuringCallContextTypes) {
  Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
  Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
  // 4) Stop streaming
  log::info("TESTPOINT 5: Stop streaming");
  // ------------------
  StopStreaming(group_id);
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
@@ -10445,7 +10451,7 @@ TEST_F(UnicastTest, MusicDuringCallContextTypes_SpeedUpReconfigFlagEnabled) {
  available_snk_context_types_ =
          (types::LeAudioContextType::CONVERSATIONAL | types::LeAudioContextType::RINGTONE |
           types::LeAudioContextType::GAME | types::LeAudioContextType::MEDIA |
           types::LeAudioContextType::LIVE)
           types::LeAudioContextType::LIVE | types::LeAudioContextType::NOTIFICATIONS)
                  .value();
  supported_snk_context_types_ =
          available_snk_context_types_ |
@@ -10531,7 +10537,7 @@ TEST_F(UnicastTest, MusicDuringCallContextTypes_SpeedUpReconfigFlagEnabled) {
  Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
  Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
  log::info("Step 2) Disable call so we could go back to MEDIA");
  log::info("Step 3) Disable call so we could go back to MEDIA");
  // ---------------------------------------
  // Suspend should stop the stream
  EXPECT_CALL(mock_state_machine_, StopStream(_)).Times(1);
+4 −0
Original line number Diff line number Diff line
@@ -766,6 +766,10 @@ public:

    /* It is possible that ACL disconnection came before CIS disconnect event */
    for (auto& ase : leAudioDevice->ases_) {
      if (ase.data_path_state == DataPathState::CONFIGURED ||
          ase.data_path_state == DataPathState::CONFIGURING) {
        RemoveDataPathByCisHandle(leAudioDevice, ase.cis_conn_hdl);
      }
      group->RemoveCisFromStreamIfNeeded(leAudioDevice, ase.cis_conn_hdl);
    }

Loading