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

Commit 593c225f authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "AptxVoice: Allow sysprop to be override in test" into main

parents 9d3894a0 02f80f7d
Loading
Loading
Loading
Loading
+25 −8
Original line number Original line Diff line number Diff line
@@ -14,6 +14,8 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#include <android-base/properties.h>
#include <android_bluetooth_flags.h>
#include <base/functional/bind.h>
#include <base/functional/bind.h>
#include <base/location.h>
#include <base/location.h>
#include <com_android_bluetooth_flags.h>
#include <com_android_bluetooth_flags.h>
@@ -63,12 +65,7 @@ const std::string kBtCodecAptxVoiceEnabled =


static bool enable_aptx_voice_property(bool enable) {
static bool enable_aptx_voice_property(bool enable) {
  const std::string value = enable ? "true" : "false";
  const std::string value = enable ? "true" : "false";
  bool result =
  return android::base::SetProperty(kBtCodecAptxVoiceEnabled, value);
      bluetooth::os::SetSystemProperty(kBtCodecAptxVoiceEnabled, value);
  auto codec_aptx_voice_enabled =
      bluetooth::os::GetSystemProperty(kBtCodecAptxVoiceEnabled);
  return result && codec_aptx_voice_enabled &&
         (codec_aptx_voice_enabled.value() == value);
}
}


class BtaAgTest : public testing::Test {
class BtaAgTest : public testing::Test {
@@ -171,8 +168,6 @@ TEST_F_WITH_FLAGS(BtaAgActTest, set_codec_q0_success,


  bta_ag_setcodec(p_scb, data);
  bta_ag_setcodec(p_scb, data);
  ASSERT_EQ(p_scb->sco_codec, BTA_AG_SCO_APTX_SWB_SETTINGS_Q0);
  ASSERT_EQ(p_scb->sco_codec, BTA_AG_SCO_APTX_SWB_SETTINGS_Q0);
  ASSERT_TRUE(
      bluetooth::os::SetSystemProperty(kBtCodecAptxVoiceEnabled, "false"));
}
}


TEST_F_WITH_FLAGS(BtaAgActTest, set_codec_q1_fail_unsupported,
TEST_F_WITH_FLAGS(BtaAgActTest, set_codec_q1_fail_unsupported,
@@ -204,6 +199,28 @@ class BtaAgCmdTest : public BtaAgTest {
  void TearDown() override { BtaAgTest::TearDown(); }
  void TearDown() override { BtaAgTest::TearDown(); }
};
};


TEST_F_WITH_FLAGS(BtaAgCmdTest, check_flag_disabling_guarding_with_prop,
                  REQUIRES_FLAGS_DISABLED(ACONFIG_FLAG(TEST_BT,
                                                       hfp_codec_aptx_voice))) {
  ASSERT_FALSE(IS_FLAG_ENABLED(hfp_codec_aptx_voice));
  ASSERT_TRUE(enable_aptx_voice_property(false));
  ASSERT_FALSE(is_hfp_aptx_voice_enabled());

  ASSERT_TRUE(enable_aptx_voice_property(true));
  ASSERT_FALSE(is_hfp_aptx_voice_enabled());
}

TEST_F_WITH_FLAGS(BtaAgCmdTest, check_flag_guarding_with_prop,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      hfp_codec_aptx_voice))) {
  ASSERT_TRUE(IS_FLAG_ENABLED(hfp_codec_aptx_voice));
  ASSERT_TRUE(enable_aptx_voice_property(false));
  ASSERT_FALSE(is_hfp_aptx_voice_enabled());

  ASSERT_TRUE(enable_aptx_voice_property(true));
  ASSERT_TRUE(is_hfp_aptx_voice_enabled());
}

TEST_F_WITH_FLAGS(BtaAgCmdTest, at_hfp_cback__qac_ev_codec_disabled,
TEST_F_WITH_FLAGS(BtaAgCmdTest, at_hfp_cback__qac_ev_codec_disabled,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      hfp_codec_aptx_voice))) {
                                                      hfp_codec_aptx_voice))) {