blob: 431200a13c049f484428cdd875591f3e4d5f0c9b [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
anyhow::Error,
fidl_fuchsia_settings::{InputDeviceSettings, InputProxy, Microphone},
};
pub async fn command(proxy: InputProxy, mic_muted: Option<bool>) -> Result<String, Error> {
let mut output = String::new();
let mut input_settings = InputDeviceSettings::empty();
let mut microphone = Microphone::empty();
if mic_muted.is_some() {
microphone.muted = mic_muted;
input_settings.microphone = Some(microphone);
}
if input_settings == InputDeviceSettings::empty() {
let setting_value = proxy.watch().await?;
output.push_str(&format!("{:#?}", setting_value));
} else {
if let Err(err) = proxy.set(input_settings).await? {
output.push_str(&format!("{:?}", err));
} else if let Some(muted) = mic_muted {
output.push_str(&format!("Successfully set mic mute to {:?}\n", muted));
}
}
Ok(output)
}