CRAS: Enable Noise Cancellation as default
Enabled Noise Cancellation as default. This change has minimum impact
to users and is clean in code path without UI interaction, to help
collecting dogfooder feedbacks on delbin/drobit.
BUG=b:170281884
BUG=chromium:1199218
TEST=Manual test
TEST=FEATURES="test" emerge-volteer adhd
Change-Id: I82ad3038b636bf83fdb59ac16a7a70ed75c11c22
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2921789
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Pin-chih Lin <johnylin@chromium.org>
Auto-Submit: Pin-chih Lin <johnylin@chromium.org>
Commit-Queue: Pin-chih Lin <johnylin@chromium.org>
(cherry picked from commit d4cef057d77ee2488e5928863ae02cd6e208804f)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2942533
Reviewed-by: Pin-chih Lin <johnylin@chromium.org>
diff --git a/cras/src/server/cras_system_state.c b/cras/src/server/cras_system_state.c
index 1b605a0..3cc704d 100644
--- a/cras/src/server/cras_system_state.c
+++ b/cras/src/server/cras_system_state.c
@@ -162,7 +162,8 @@
exp_state->bt_wbs_enabled = board_config.bt_wbs_enabled;
exp_state->deprioritize_bt_wbs_mic =
board_config.deprioritize_bt_wbs_mic;
- exp_state->noise_cancellation_enabled = 0;
+ /* Enable Noise Cancellation as default. */
+ exp_state->noise_cancellation_enabled = 1;
exp_state->noise_cancellation_supported = 0;
exp_state->hotword_pause_at_suspend =
board_config.hotword_pause_at_suspend;
diff --git a/cras/src/tests/system_state_unittest.cc b/cras/src/tests/system_state_unittest.cc
index 45224bc..9d24d62 100644
--- a/cras/src/tests/system_state_unittest.cc
+++ b/cras/src/tests/system_state_unittest.cc
@@ -440,24 +440,24 @@
ResetStubData();
do_sys_init();
- EXPECT_EQ(0, cras_system_get_noise_cancellation_enabled());
+ bool enabled = cras_system_get_noise_cancellation_enabled();
- cras_system_set_noise_cancellation_enabled(0);
- EXPECT_EQ(0, cras_system_get_noise_cancellation_enabled());
+ cras_system_set_noise_cancellation_enabled(enabled);
+ EXPECT_EQ(enabled, cras_system_get_noise_cancellation_enabled());
EXPECT_EQ(0, cras_iodev_list_reset_for_noise_cancellation_called);
- cras_system_set_noise_cancellation_enabled(1);
- EXPECT_EQ(1, cras_system_get_noise_cancellation_enabled());
+ cras_system_set_noise_cancellation_enabled(!enabled);
+ EXPECT_EQ(!enabled, cras_system_get_noise_cancellation_enabled());
EXPECT_EQ(1, cras_iodev_list_reset_for_noise_cancellation_called);
- cras_system_set_noise_cancellation_enabled(1);
- EXPECT_EQ(1, cras_system_get_noise_cancellation_enabled());
+ cras_system_set_noise_cancellation_enabled(!enabled);
+ EXPECT_EQ(!enabled, cras_system_get_noise_cancellation_enabled());
// cras_iodev_list_reset_for_noise_cancellation shouldn't be called if state
// is already enabled/disabled.
EXPECT_EQ(1, cras_iodev_list_reset_for_noise_cancellation_called);
- cras_system_set_noise_cancellation_enabled(0);
- EXPECT_EQ(0, cras_system_get_noise_cancellation_enabled());
+ cras_system_set_noise_cancellation_enabled(enabled);
+ EXPECT_EQ(enabled, cras_system_get_noise_cancellation_enabled());
EXPECT_EQ(2, cras_iodev_list_reset_for_noise_cancellation_called);
cras_system_state_deinit();