Skip to content

Commit

Permalink
CRAS: Fix handle_get_voice_isolation_ui_appearance
Browse files Browse the repository at this point in the history
handle_get_voice_isolation_ui_appearance() handles the D-Bus
method call GetVoiceIsolationUIAppearance.

In https://crrev.com/c/5919890 , this method missed
to add DBUS_TYPE_INVALID at the end when calling
dbus_message_append_args(), so the client would get no reply.

Added DBUS_TYPE_INVALID, and also fixed the args by casting
them to dbus types.

BUG=b:353627012
TEST=bazel test //cras/src/tests:dbus_control_unittest
TEST=(on DUT) dbus-send --system --print-reply \
  --type=method_call --dest=org.chromium.cras \
  /org/chromium/cras \
  org.chromium.cras.Control.GetVoiceIsolationUIAppearance

Change-Id: I38d0742902f4db3ad2887f798d770dfcf1115286
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5937164
Commit-Queue: Hung-Hsien Chen <[email protected]>
Tested-by: [email protected] <[email protected]>
Reviewed-by: Li-Yu Yu <[email protected]>
  • Loading branch information
hunghsienchen authored and Chromeos LUCI committed Oct 22, 2024
1 parent 76b09f1 commit 0b700af
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cras/src/server/cras_dbus_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,10 +1115,15 @@ static DBusHandlerResult handle_get_voice_isolation_ui_appearance(

struct CrasEffectUIAppearance appearance =
cras_s2_get_audio_effect_ui_appearance();
dbus_uint32_t toggle_type = appearance.toggle_type;
dbus_uint32_t effect_mode_options = appearance.effect_mode_options;
// boolean size must be fixed at 4 bytes due to wire protocol!
dbus_bool_t show_effect_fallback_message =
appearance.show_effect_fallback_message;
if (!dbus_message_append_args(
reply, DBUS_TYPE_UINT32, &appearance.toggle_type, DBUS_TYPE_UINT32,
&appearance.effect_mode_options, DBUS_TYPE_BOOLEAN,
&appearance.show_effect_fallback_message)) {
reply, DBUS_TYPE_UINT32, &toggle_type, DBUS_TYPE_UINT32,
&effect_mode_options, DBUS_TYPE_BOOLEAN,
&show_effect_fallback_message, DBUS_TYPE_INVALID)) {
ret = DBUS_HANDLER_RESULT_NEED_MEMORY;
goto unref_reply;
}
Expand Down
9 changes: 9 additions & 0 deletions cras/src/tests/dbus_control_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ TEST_F(DBusControlTestSuite, GetFeatureFlagForTestBadArgs) {
WaitForMatches();
}

TEST_F(DBusControlTestSuite, GetVoiceIsolationUIAppearance) {
CreateMessageCall(CRAS_ROOT_OBJECT_PATH, CRAS_CONTROL_INTERFACE,
"GetVoiceIsolationUIAppearance")
.Send();
// WaitForMatches() will check each of the argument's type is matched
// with the specified DBUS_TYPE.
WaitForMatches();
}

} // namespace

extern "C" {
Expand Down

0 comments on commit 0b700af

Please sign in to comment.