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

Commit 9514f9fc authored by Bao Do's avatar Bao Do Committed by Gerrit Code Review
Browse files

Merge "Fix test run for GSI" into main

parents d1386c8c b487a859
Loading
Loading
Loading
Loading
+116 −33
Original line number Diff line number Diff line
@@ -120,6 +120,16 @@ static constexpr ChannelMode a2dp_channel_modes[] = {
    ChannelMode::UNKNOWN, ChannelMode::MONO, ChannelMode::STEREO};
static std::vector<LatencyMode> latency_modes = {LatencyMode::FREE};

enum class BluetoothAudioHalVersion : int32_t {
  VERSION_UNAVAILABLE = 0,
  VERSION_2_0,
  VERSION_2_1,
  VERSION_AIDL_V1,
  VERSION_AIDL_V2,
  VERSION_AIDL_V3,
  VERSION_AIDL_V4,
};

// Some valid configs for HFP PCM configuration (software sessions)
static constexpr int32_t hfp_sample_rates_[] = {8000, 16000, 32000};
static constexpr int8_t hfp_bits_per_samples_[] = {16};
@@ -221,7 +231,6 @@ class BluetoothAudioProviderFactoryAidl
    temp_provider_info_ = std::nullopt;
    auto aidl_reval =
        provider_factory_->getProviderInfo(session_type, &temp_provider_info_);
    ASSERT_TRUE(aidl_reval.isOk());
  }

  void GetProviderCapabilitiesHelper(const SessionType& session_type) {
@@ -623,9 +632,38 @@ class BluetoothAudioProviderFactoryAidl
      SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH,
      SessionType::A2DP_SOFTWARE_DECODING_DATAPATH,
      SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH,
  };

  static constexpr SessionType kAndroidVSessionType[] = {
      SessionType::HFP_SOFTWARE_ENCODING_DATAPATH,
      SessionType::HFP_SOFTWARE_DECODING_DATAPATH,
  };

  BluetoothAudioHalVersion GetProviderFactoryInterfaceVersion() {
    int32_t aidl_version = 0;
    if (provider_factory_ == nullptr) {
      return BluetoothAudioHalVersion::VERSION_UNAVAILABLE;
    }

    auto aidl_retval = provider_factory_->getInterfaceVersion(&aidl_version);
    if (!aidl_retval.isOk()) {
      return BluetoothAudioHalVersion::VERSION_UNAVAILABLE;
    }
    switch (aidl_version) {
      case 1:
        return BluetoothAudioHalVersion::VERSION_AIDL_V1;
      case 2:
        return BluetoothAudioHalVersion::VERSION_AIDL_V2;
      case 3:
        return BluetoothAudioHalVersion::VERSION_AIDL_V3;
      case 4:
        return BluetoothAudioHalVersion::VERSION_AIDL_V4;
      default:
        return BluetoothAudioHalVersion::VERSION_UNAVAILABLE;
    }

    return BluetoothAudioHalVersion::VERSION_UNAVAILABLE;
  }
};

/**
@@ -647,6 +685,15 @@ TEST_P(BluetoothAudioProviderFactoryAidl,
    EXPECT_TRUE(temp_provider_capabilities_.empty() ||
                audio_provider_ != nullptr);
  }
  if (GetProviderFactoryInterfaceVersion() >=
      BluetoothAudioHalVersion::VERSION_AIDL_V4) {
    for (auto session_type : kAndroidVSessionType) {
      GetProviderCapabilitiesHelper(session_type);
      OpenProviderHelper(session_type);
      EXPECT_TRUE(temp_provider_capabilities_.empty() ||
                  audio_provider_ != nullptr);
    }
  }
}

/**
@@ -1464,8 +1511,8 @@ TEST_P(BluetoothAudioProviderA2dpEncodingSoftwareAidl,

/**
 * Test whether each provider of type
 * SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH can be started and stopped with
 * different PCM config
 * SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH can be started and stopped
 * with different PCM config
 */
TEST_P(BluetoothAudioProviderA2dpEncodingSoftwareAidl,
       StartAndEndA2dpEncodingSoftwareSessionWithPossiblePcmConfig) {
@@ -1502,6 +1549,10 @@ class BluetoothAudioProviderHfpSoftwareEncodingAidl
 public:
  virtual void SetUp() override {
    BluetoothAudioProviderFactoryAidl::SetUp();
    if (GetProviderFactoryInterfaceVersion() <
        BluetoothAudioHalVersion::VERSION_AIDL_V4) {
      GTEST_SKIP();
    }
    GetProviderCapabilitiesHelper(SessionType::HFP_SOFTWARE_ENCODING_DATAPATH);
    OpenProviderHelper(SessionType::HFP_SOFTWARE_ENCODING_DATAPATH);
    ASSERT_NE(audio_provider_, nullptr);
@@ -1569,6 +1620,10 @@ class BluetoothAudioProviderHfpSoftwareDecodingAidl
 public:
  virtual void SetUp() override {
    BluetoothAudioProviderFactoryAidl::SetUp();
    if (GetProviderFactoryInterfaceVersion() <
        BluetoothAudioHalVersion::VERSION_AIDL_V4) {
      GTEST_SKIP();
    }
    GetProviderCapabilitiesHelper(SessionType::HFP_SOFTWARE_DECODING_DATAPATH);
    OpenProviderHelper(SessionType::HFP_SOFTWARE_DECODING_DATAPATH);
    ASSERT_NE(audio_provider_, nullptr);
@@ -1657,8 +1712,8 @@ TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,

/**
 * Test whether each provider of type
 * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
 * SBC hardware encoding config
 * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped
 * with SBC hardware encoding config
 */
TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,
       StartAndEndA2dpSbcEncodingHardwareSession) {
@@ -1687,8 +1742,8 @@ TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,

/**
 * Test whether each provider of type
 * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
 * AAC hardware encoding config
 * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped
 * with AAC hardware encoding config
 */
TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,
       StartAndEndA2dpAacEncodingHardwareSession) {
@@ -1717,8 +1772,8 @@ TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,

/**
 * Test whether each provider of type
 * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
 * LDAC hardware encoding config
 * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped
 * with LDAC hardware encoding config
 */
TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,
       StartAndEndA2dpLdacEncodingHardwareSession) {
@@ -1747,8 +1802,8 @@ TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,

/**
 * Test whether each provider of type
 * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
 * Opus hardware encoding config
 * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped
 * with Opus hardware encoding config
 */
TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,
       StartAndEndA2dpOpusEncodingHardwareSession) {
@@ -1777,8 +1832,8 @@ TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,

/**
 * Test whether each provider of type
 * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
 * AptX hardware encoding config
 * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped
 * with AptX hardware encoding config
 */
TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,
       StartAndEndA2dpAptxEncodingHardwareSession) {
@@ -1813,8 +1868,8 @@ TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,

/**
 * Test whether each provider of type
 * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
 * an invalid codec config
 * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped
 * with an invalid codec config
 */
TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,
       StartAndEndA2dpEncodingHardwareSessionInvalidCodecConfig) {
@@ -1885,6 +1940,10 @@ class BluetoothAudioProviderHfpHardwareAidl
 public:
  virtual void SetUp() override {
    BluetoothAudioProviderFactoryAidl::SetUp();
    if (GetProviderFactoryInterfaceVersion() <
        BluetoothAudioHalVersion::VERSION_AIDL_V4) {
      GTEST_SKIP();
    }
    OpenProviderHelper(SessionType::HFP_HARDWARE_OFFLOAD_DATAPATH);
    // Can open or empty capability
    ASSERT_TRUE(temp_provider_capabilities_.empty() ||
@@ -2418,6 +2477,10 @@ TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl,
TEST_P(
    BluetoothAudioProviderLeAudioOutputHardwareAidl,
    StartAndEndLeAudioOutputSessionWithPossibleUnicastConfigFromProviderInfo) {
  if (GetProviderFactoryInterfaceVersion() <
      BluetoothAudioHalVersion::VERSION_AIDL_V4) {
    GTEST_SKIP();
  }
  if (!IsOffloadOutputProviderInfoSupported()) {
    GTEST_SKIP();
  }
@@ -2443,6 +2506,10 @@ TEST_P(

TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl,
       GetEmptyAseConfigurationEmptyCapability) {
  if (GetProviderFactoryInterfaceVersion() <
      BluetoothAudioHalVersion::VERSION_AIDL_V4) {
    GTEST_SKIP();
  }
  std::vector<std::optional<LeAudioDeviceCapabilities>> empty_capability;
  std::vector<LeAudioConfigurationRequirement> empty_requirement;
  std::vector<LeAudioAseConfigurationSetting> configurations;
@@ -2464,6 +2531,10 @@ TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl,

TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl,
       GetEmptyAseConfigurationMismatchedRequirement) {
  if (GetProviderFactoryInterfaceVersion() <
      BluetoothAudioHalVersion::VERSION_AIDL_V4) {
    GTEST_SKIP();
  }
  std::vector<std::optional<LeAudioDeviceCapabilities>> capabilities = {
      GetDefaultRemoteCapability()};

@@ -2488,6 +2559,10 @@ TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl,
}

TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl, GetQoSConfiguration) {
  if (GetProviderFactoryInterfaceVersion() <
      BluetoothAudioHalVersion::VERSION_AIDL_V4) {
    GTEST_SKIP();
  }
  IBluetoothAudioProvider::LeAudioAseQosConfigurationRequirement requirement;
  std::vector<IBluetoothAudioProvider::LeAudioAseQosConfiguration>
      QoSConfigurations;
@@ -2862,16 +2937,16 @@ class BluetoothAudioProviderLeAudioBroadcastSoftwareAidl

/**
 * Test whether each provider of type
 * SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH can be started and
 * stopped
 * SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH can be started
 * and stopped
 */
TEST_P(BluetoothAudioProviderLeAudioBroadcastSoftwareAidl,
       OpenLeAudioOutputSoftwareProvider) {}

/**
 * Test whether each provider of type
 * SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH can be started and
 * stopped with different PCM config
 * SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH can be started
 * and stopped with different PCM config
 */
TEST_P(BluetoothAudioProviderLeAudioBroadcastSoftwareAidl,
       StartAndEndLeAudioOutputSessionWithPossiblePcmConfig) {
@@ -3045,6 +3120,10 @@ TEST_P(BluetoothAudioProviderLeAudioBroadcastHardwareAidl,
TEST_P(
    BluetoothAudioProviderLeAudioBroadcastHardwareAidl,
    StartAndEndLeAudioBroadcastSessionWithPossibleUnicastConfigFromProviderInfo) {
  if (GetProviderFactoryInterfaceVersion() <
      BluetoothAudioHalVersion::VERSION_AIDL_V4) {
    GTEST_SKIP();
  }
  if (!IsBroadcastOffloadProviderInfoSupported()) {
    return;
  }
@@ -3076,6 +3155,10 @@ TEST_P(

TEST_P(BluetoothAudioProviderLeAudioBroadcastHardwareAidl,
       GetEmptyBroadcastConfigurationEmptyCapability) {
  if (GetProviderFactoryInterfaceVersion() <
      BluetoothAudioHalVersion::VERSION_AIDL_V4) {
    GTEST_SKIP();
  }
  std::vector<std::optional<LeAudioDeviceCapabilities>> empty_capability;
  IBluetoothAudioProvider::LeAudioBroadcastConfigurationRequirement
      empty_requirement;
@@ -3190,8 +3273,8 @@ TEST_P(BluetoothAudioProviderA2dpDecodingSoftwareAidl,

/**
 * Test whether each provider of type
 * SessionType::A2DP_SOFTWARE_DECODING_DATAPATH can be started and stopped with
 * different PCM config
 * SessionType::A2DP_SOFTWARE_DECODING_DATAPATH can be started and stopped
 * with different PCM config
 */
TEST_P(BluetoothAudioProviderA2dpDecodingSoftwareAidl,
       StartAndEndA2dpDecodingSoftwareSessionWithPossiblePcmConfig) {
@@ -3252,8 +3335,8 @@ TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,

/**
 * Test whether each provider of type
 * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped with
 * SBC hardware encoding config
 * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped
 * with SBC hardware encoding config
 */
TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,
       StartAndEndA2dpSbcDecodingHardwareSession) {
@@ -3282,8 +3365,8 @@ TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,

/**
 * Test whether each provider of type
 * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped with
 * AAC hardware encoding config
 * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped
 * with AAC hardware encoding config
 */
TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,
       StartAndEndA2dpAacDecodingHardwareSession) {
@@ -3312,8 +3395,8 @@ TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,

/**
 * Test whether each provider of type
 * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped with
 * LDAC hardware encoding config
 * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped
 * with LDAC hardware encoding config
 */
TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,
       StartAndEndA2dpLdacDecodingHardwareSession) {
@@ -3342,8 +3425,8 @@ TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,

/**
 * Test whether each provider of type
 * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped with
 * Opus hardware encoding config
 * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped
 * with Opus hardware encoding config
 */
TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,
       StartAndEndA2dpOpusDecodingHardwareSession) {
@@ -3372,8 +3455,8 @@ TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,

/**
 * Test whether each provider of type
 * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped with
 * AptX hardware encoding config
 * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped
 * with AptX hardware encoding config
 */
TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,
       StartAndEndA2dpAptxDecodingHardwareSession) {
@@ -3408,8 +3491,8 @@ TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,

/**
 * Test whether each provider of type
 * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped with
 * an invalid codec config
 * SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped
 * with an invalid codec config
 */
TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,
       StartAndEndA2dpDecodingHardwareSessionInvalidCodecConfig) {