Loading system/bta/test/bta_ag_test.cc +25 −8 Original line number Original line Diff line number Diff line Loading @@ -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> Loading Loading @@ -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 { Loading Loading @@ -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, Loading Loading @@ -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))) { Loading Loading
system/bta/test/bta_ag_test.cc +25 −8 Original line number Original line Diff line number Diff line Loading @@ -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> Loading Loading @@ -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 { Loading Loading @@ -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, Loading Loading @@ -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))) { Loading