Commit d6a3ec92 authored by Yue Li's avatar Yue Li Committed by Commit Bot

Handle hotword enable/disable in assistant service

- Restart the Assistant when hotword enable state changes
- Add mojom methods for hotword_enabled pref.

Bug: b/110219351
Test: Manual test
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: If45adaab50f412d08b43fdc7b6883acecc2441d8
Reviewed-on: https://chromium-review.googlesource.com/1117849
Commit-Queue: Yue Li <updowndota@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574295}
parent 1f63bf22
......@@ -55,6 +55,9 @@ interface VoiceInteractionObserver {
// the "context" (text and graphic content that is currently on screen).
OnVoiceInteractionContextEnabled(bool enabled);
// Called when hotword listening is enabled/disabled.
OnVoiceInteractionHotwordEnabled(bool enabled);
// Called when voice interaction setup flow completed.
OnVoiceInteractionSetupCompleted(bool completed);
......@@ -76,6 +79,9 @@ interface VoiceInteractionController {
// interaction session.
NotifyContextEnabled(bool enabled);
// Called when the hotword listening is enabled/disabled.
NotifyHotwordEnabled(bool enabled);
// Called when the voice interaction setup complete status is changed.
NotifySetupCompleted(bool completed);
......@@ -89,6 +95,9 @@ interface VoiceInteractionController {
// Return the voice interaction setup complete status.
IsSetupCompleted() => (bool completed);
// Return the voice interaction hotword listening status.
IsHotwordEnabled() => (bool enabled);
// Add an observer.
AddObserver(VoiceInteractionObserver observer);
};
......@@ -74,6 +74,7 @@ class ASH_EXPORT AppListButton : public views::ImageButton,
mojom::VoiceInteractionState state) override;
void OnVoiceInteractionSettingsEnabled(bool enabled) override;
void OnVoiceInteractionContextEnabled(bool enabled) override {}
void OnVoiceInteractionHotwordEnabled(bool enabled) override {}
void OnVoiceInteractionSetupCompleted(bool completed) override;
void OnAssistantFeatureAllowedChanged(
mojom::AssistantAllowedState state) override {}
......
......@@ -68,6 +68,7 @@ class ASH_EXPORT MetalayerMode : public CommonPaletteTool,
mojom::VoiceInteractionState state) override;
void OnVoiceInteractionSettingsEnabled(bool enabled) override;
void OnVoiceInteractionContextEnabled(bool enabled) override;
void OnVoiceInteractionHotwordEnabled(bool enabled) override {}
void OnVoiceInteractionSetupCompleted(bool completed) override {}
void OnAssistantFeatureAllowedChanged(
mojom::AssistantAllowedState state) override;
......
......@@ -38,6 +38,13 @@ void VoiceInteractionController::NotifyContextEnabled(bool enabled) {
});
}
void VoiceInteractionController::NotifyHotwordEnabled(bool enabled) {
hotword_enabled_ = enabled;
observers_.ForAllPtrs([enabled](auto* observer) {
observer->OnVoiceInteractionHotwordEnabled(enabled);
});
}
void VoiceInteractionController::NotifySetupCompleted(bool completed) {
setup_completed_ = completed;
observers_.ForAllPtrs([completed](auto* observer) {
......@@ -63,6 +70,11 @@ void VoiceInteractionController::IsSetupCompleted(
std::move(callback).Run(setup_completed_);
}
void VoiceInteractionController::IsHotwordEnabled(
IsHotwordEnabledCallback callback) {
std::move(callback).Run(hotword_enabled_);
}
void VoiceInteractionController::AddObserver(
mojom::VoiceInteractionObserverPtr observer) {
observers_.AddPtr(std::move(observer));
......
......@@ -26,10 +26,12 @@ class ASH_EXPORT VoiceInteractionController
void NotifyStatusChanged(mojom::VoiceInteractionState state) override;
void NotifySettingsEnabled(bool enabled) override;
void NotifyContextEnabled(bool enabled) override;
void NotifyHotwordEnabled(bool enabled) override;
void NotifySetupCompleted(bool completed) override;
void NotifyFeatureAllowed(mojom::AssistantAllowedState state) override;
void IsSettingEnabled(IsSettingEnabledCallback callback) override;
void IsSetupCompleted(IsSetupCompletedCallback callback) override;
void IsHotwordEnabled(IsHotwordEnabledCallback callback) override;
void AddObserver(mojom::VoiceInteractionObserverPtr observer) override;
mojom::VoiceInteractionState voice_interaction_state() const {
......@@ -56,6 +58,9 @@ class ASH_EXPORT VoiceInteractionController
// Whether voice intearction setup flow has completed.
bool setup_completed_ = false;
// Whether hotword listening is enabled.
bool hotword_enabled_ = false;
// Whether voice intearction feature is allowed or disallowed for what reason.
mojom::AssistantAllowedState allowed_state_ =
mojom::AssistantAllowedState::ALLOWED;
......
......@@ -31,6 +31,9 @@ class TestVoiceInteractionObserver : public mojom::VoiceInteractionObserver {
void OnVoiceInteractionContextEnabled(bool enabled) override {
context_enabled_ = enabled;
}
void OnVoiceInteractionHotwordEnabled(bool enabled) override {
hotword_enabled_ = enabled;
}
void OnVoiceInteractionSetupCompleted(bool completed) override {
setup_completed_ = completed;
}
......@@ -42,6 +45,7 @@ class TestVoiceInteractionObserver : public mojom::VoiceInteractionObserver {
}
bool settings_enabled() const { return settings_enabled_; }
bool context_enabled() const { return context_enabled_; }
bool hotword_enabled() const { return hotword_enabled_; }
bool setup_completed() const { return setup_completed_; }
void SetVoiceInteractionController(VoiceInteractionController* controller) {
......@@ -54,6 +58,7 @@ class TestVoiceInteractionObserver : public mojom::VoiceInteractionObserver {
mojom::VoiceInteractionState state_ = mojom::VoiceInteractionState::STOPPED;
bool settings_enabled_ = false;
bool context_enabled_ = false;
bool hotword_enabled_ = false;
bool setup_completed_ = false;
mojo::Binding<mojom::VoiceInteractionObserver> voice_interaction_binding_;
......@@ -122,6 +127,13 @@ TEST_F(VoiceInteractionControllerTest, NotifyContextEnabled) {
EXPECT_TRUE(observer()->context_enabled());
}
TEST_F(VoiceInteractionControllerTest, NotifyHotwordEnabled) {
controller()->NotifyHotwordEnabled(true);
controller()->FlushForTesting();
// The observers should be notified.
EXPECT_TRUE(observer()->hotword_enabled());
}
TEST_F(VoiceInteractionControllerTest, NotifySetupCompleted) {
controller()->NotifySetupCompleted(true);
controller()->FlushForTesting();
......
......@@ -31,6 +31,10 @@ void FakeVoiceInteractionController::NotifyContextEnabled(bool enabled) {
voice_interaction_context_enabled_ = enabled;
}
void FakeVoiceInteractionController::NotifyHotwordEnabled(bool enabled) {
voice_interaction_hotword_enabled_ = enabled;
}
void FakeVoiceInteractionController::NotifySetupCompleted(bool completed) {
voice_interaction_setup_completed_ = completed;
}
......@@ -50,4 +54,9 @@ void FakeVoiceInteractionController::IsSetupCompleted(
std::move(callback).Run(voice_interaction_setup_completed_);
}
void FakeVoiceInteractionController::IsHotwordEnabled(
IsHotwordEnabledCallback callback) {
std::move(callback).Run(voice_interaction_hotword_enabled_);
}
} // namespace arc
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_ARC_VOICE_INTERACTION_TEST_VOICE_INTERACTION_CONTROLLER_H_
#define CHROME_BROWSER_CHROMEOS_ARC_VOICE_INTERACTION_TEST_VOICE_INTERACTION_CONTROLLER_H_
#ifndef CHROME_BROWSER_CHROMEOS_ARC_VOICE_INTERACTION_FAKE_VOICE_INTERACTION_CONTROLLER_H_
#define CHROME_BROWSER_CHROMEOS_ARC_VOICE_INTERACTION_FAKE_VOICE_INTERACTION_CONTROLLER_H_
#include "ash/public/interfaces/voice_interaction_controller.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
......@@ -22,10 +22,12 @@ class FakeVoiceInteractionController
void NotifyStatusChanged(ash::mojom::VoiceInteractionState state) override;
void NotifySettingsEnabled(bool enabled) override;
void NotifyContextEnabled(bool enabled) override;
void NotifyHotwordEnabled(bool enabled) override;
void NotifySetupCompleted(bool completed) override;
void NotifyFeatureAllowed(ash::mojom::AssistantAllowedState state) override;
void IsSettingEnabled(IsSettingEnabledCallback callback) override;
void IsSetupCompleted(IsSetupCompletedCallback callback) override;
void IsHotwordEnabled(IsHotwordEnabledCallback callback) override;
void AddObserver(ash::mojom::VoiceInteractionObserverPtr observer) override {}
ash::mojom::VoiceInteractionState voice_interaction_state() const {
......@@ -37,6 +39,9 @@ class FakeVoiceInteractionController
bool voice_interaction_context_enabled() const {
return voice_interaction_context_enabled_;
}
bool voice_interaction_hotword_enabled() const {
return voice_interaction_hotword_enabled_;
}
bool voice_interaction_setup_completed() const {
return voice_interaction_setup_completed_;
}
......@@ -49,6 +54,7 @@ class FakeVoiceInteractionController
ash::mojom::VoiceInteractionState::STOPPED;
bool voice_interaction_settings_enabled_ = false;
bool voice_interaction_context_enabled_ = false;
bool voice_interaction_hotword_enabled_ = false;
bool voice_interaction_setup_completed_ = false;
ash::mojom::AssistantAllowedState assistant_allowed_state_ =
ash::mojom::AssistantAllowedState::DISALLOWED_BY_INCOGNITO;
......@@ -60,4 +66,4 @@ class FakeVoiceInteractionController
} // namespace arc
#endif // CHROME_BROWSER_CHROMEOS_ARC_VOICE_INTERACTION_TEST_VOICE_INTERACTION_CONTROLLER_H_
#endif // CHROME_BROWSER_CHROMEOS_ARC_VOICE_INTERACTION_FAKE_VOICE_INTERACTION_CONTROLLER_H_
......@@ -95,6 +95,15 @@ void VoiceInteractionControllerClient::NotifyContextEnabled() {
voice_interaction_controller_->NotifyContextEnabled(enabled);
}
void VoiceInteractionControllerClient::NotifyHotwordEnabled() {
DCHECK(profile_);
PrefService* prefs = profile_->GetPrefs();
// Make sure voice interaction is enabled.
DCHECK(prefs->GetBoolean(prefs::kVoiceInteractionEnabled));
bool enabled = prefs->GetBoolean(prefs::kVoiceInteractionHotwordEnabled);
voice_interaction_controller_->NotifyHotwordEnabled(enabled);
}
void VoiceInteractionControllerClient::NotifySetupCompleted() {
DCHECK(profile_);
PrefService* prefs = profile_->GetPrefs();
......@@ -153,10 +162,17 @@ void VoiceInteractionControllerClient::SetProfile(Profile* profile) {
base::BindRepeating(
&VoiceInteractionControllerClient::NotifyContextEnabled,
base::Unretained(this)));
pref_change_registrar_->Add(
prefs::kVoiceInteractionHotwordEnabled,
base::BindRepeating(
&VoiceInteractionControllerClient::NotifyHotwordEnabled,
base::Unretained(this)));
NotifySetupCompleted();
NotifySettingsEnabled();
NotifyContextEnabled();
if (prefs->GetBoolean(prefs::kVoiceInteractionEnabled))
NotifyHotwordEnabled();
NotifyFeatureAllowed();
}
......
......@@ -55,6 +55,7 @@ class VoiceInteractionControllerClient
// Notify the controller about state changes.
void NotifySettingsEnabled();
void NotifyContextEnabled();
void NotifyHotwordEnabled();
void NotifySetupCompleted();
void NotifyFeatureAllowed();
......
......@@ -118,6 +118,14 @@ TEST_F(VoiceInteractionControllerClientTest, PrefChangeSendsNotification) {
true,
voice_interaction_controller()->voice_interaction_context_enabled());
ASSERT_EQ(false, prefs->GetBoolean(prefs::kVoiceInteractionHotwordEnabled));
prefs->SetBoolean(prefs::kVoiceInteractionHotwordEnabled, true);
ASSERT_EQ(true, prefs->GetBoolean(prefs::kVoiceInteractionHotwordEnabled));
voice_interaction_controller_client()->FlushMojoForTesting();
EXPECT_EQ(
true,
voice_interaction_controller()->voice_interaction_hotword_enabled());
ASSERT_EQ(false,
prefs->GetBoolean(prefs::kArcVoiceInteractionValuePropAccepted));
prefs->SetBoolean(prefs::kArcVoiceInteractionValuePropAccepted, true);
......
......@@ -22,12 +22,6 @@ cr.define('settings', function() {
*/
setGoogleAssistantContextEnabled(enabled) {}
/**
* Enables or disables hotword detection for the Google Assistant.
* @param {boolean} enabled
*/
setGoogleAssistantHotwordEnabled(enabled) {}
/** Launches into the Google Assistant app settings. */
launchGoogleAssistantSettings() {}
}
......@@ -44,11 +38,6 @@ cr.define('settings', function() {
chrome.send('setGoogleAssistantContextEnabled', [enabled]);
}
/** @override */
setGoogleAssistantHotwordEnabled(enabled) {
chrome.send('setGoogleAssistantHotwordEnabled', [enabled]);
}
/** @override */
showGoogleAssistantSettings() {
chrome.send('showGoogleAssistantSettings');
......
......@@ -34,8 +34,7 @@
class="continuation indented"
pref="{{prefs.settings.voice_interaction.hotword.enabled}}"
label="$i18n{googleAssistantEnableHotword}"
sub-label="$i18n{googleAssistantEnableHotwordDescription}"
on-change="onGoogleAssistantHotwordEnableChange_">
sub-label="$i18n{googleAssistantEnableHotwordDescription}">
</settings-toggle-button>
</template>
<div id="googleAssistantSettings" class="settings-box"
......
......@@ -50,12 +50,6 @@ Polymer({
!!this.getPref('settings.voice_interaction.context.enabled.value'));
},
/** @private */
onGoogleAssistantHotwordEnableChange_: function() {
this.browserProxy_.setGoogleAssistantHotwordEnabled(
!!this.getPref('settings.voice_interaction.hotword.enabled.value'));
},
/** @private */
onGoogleAssistantSettingsTapped_: function() {
this.browserProxy_.showGoogleAssistantSettings();
......
......@@ -37,13 +37,6 @@ void GoogleAssistantHandler::RegisterMessages() {
base::BindRepeating(
&GoogleAssistantHandler::HandleSetGoogleAssistantContextEnabled,
base::Unretained(this)));
if (chromeos::switches::IsAssistantEnabled()) {
web_ui()->RegisterMessageCallback(
"setGoogleAssistantHotwordEnabled",
base::BindRepeating(
&GoogleAssistantHandler::HandleSetGoogleAssistantHotwordEnabled,
base::Unretained(this)));
}
web_ui()->RegisterMessageCallback(
"showGoogleAssistantSettings",
base::BindRepeating(
......@@ -79,17 +72,6 @@ void GoogleAssistantHandler::HandleSetGoogleAssistantContextEnabled(
service->SetVoiceInteractionContextEnabled(enabled);
}
void GoogleAssistantHandler::HandleSetGoogleAssistantHotwordEnabled(
const base::ListValue* args) {
CHECK(chromeos::switches::IsAssistantEnabled());
CHECK_EQ(1U, args->GetSize());
bool enabled;
CHECK(args->GetBoolean(0, &enabled));
// TODO(b/110219351) Handle toggle hotword.
}
void GoogleAssistantHandler::HandleShowGoogleAssistantSettings(
const base::ListValue* args) {
auto* service =
......
......@@ -27,8 +27,6 @@ class GoogleAssistantHandler : public ::settings::SettingsPageUIHandler {
void HandleSetGoogleAssistantEnabled(const base::ListValue* args);
// WebUI call to enable context for the Google Assistant.
void HandleSetGoogleAssistantContextEnabled(const base::ListValue* args);
// WebUI call to enable hotword detection for the Google Assistant.
void HandleSetGoogleAssistantHotwordEnabled(const base::ListValue* args);
// WebUI call to launch into the Google Assistant app settings.
void HandleShowGoogleAssistantSettings(const base::ListValue* args);
// WebUI call to launch assistant runtime flow.
......
......@@ -42,13 +42,13 @@ const char kBluetoothDeviceSettingId[] = "BLUETOOTH";
AssistantManagerServiceImpl::AssistantManagerServiceImpl(
service_manager::Connector* connector,
device::mojom::BatteryMonitorPtr battery_monitor,
Service* service)
: platform_api_(CreateLibAssistantConfig(),
connector,
std::move(battery_monitor)),
Service* service,
const std::string& config_str)
: platform_api_(config_str, connector, std::move(battery_monitor)),
config_str_(config_str),
action_module_(std::make_unique<action::CrosActionModule>(this)),
display_connection_(std::make_unique<CrosDisplayConnection>(this)),
main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
display_connection_(std::make_unique<CrosDisplayConnection>(this)),
voice_interaction_observer_binding_(this),
service_(service),
background_thread_("background thread"),
......@@ -394,8 +394,8 @@ void AssistantManagerServiceImpl::StartAssistantInternal(
const std::string& arc_version) {
DCHECK(background_thread_.task_runner()->BelongsToCurrentThread());
assistant_manager_.reset(assistant_client::AssistantManager::Create(
&platform_api_, CreateLibAssistantConfig()));
assistant_manager_.reset(
assistant_client::AssistantManager::Create(&platform_api_, config_str_));
assistant_manager_internal_ =
UnwrapAssistantManagerInternal(assistant_manager_.get());
......
......@@ -62,7 +62,8 @@ class AssistantManagerServiceImpl
// |service| owns this class and must outlive this class.
AssistantManagerServiceImpl(service_manager::Connector* connector,
device::mojom::BatteryMonitorPtr battery_monitor,
Service* service);
Service* service,
const std::string& config_str);
~AssistantManagerServiceImpl() override;
......@@ -124,6 +125,7 @@ class AssistantManagerServiceImpl
ash::mojom::VoiceInteractionState state) override {}
void OnVoiceInteractionSettingsEnabled(bool enabled) override;
void OnVoiceInteractionContextEnabled(bool enabled) override;
void OnVoiceInteractionHotwordEnabled(bool enabled) override {}
void OnVoiceInteractionSetupCompleted(bool completed) override;
void OnAssistantFeatureAllowedChanged(
ash::mojom::AssistantAllowedState state) override {}
......@@ -186,6 +188,7 @@ class AssistantManagerServiceImpl
State state_ = State::STOPPED;
PlatformApiImpl platform_api_;
const std::string config_str_;
std::unique_ptr<action::CrosActionModule> action_module_;
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
std::unique_ptr<assistant_client::AssistantManager> assistant_manager_;
......
......@@ -25,9 +25,11 @@
#include "services/service_manager/public/cpp/service_context.h"
#if BUILDFLAG(ENABLE_CROS_LIBASSISTANT)
#include "ash/public/interfaces/constants.mojom.h"
#include "chromeos/assistant/internal/internal_constants.h"
#include "chromeos/services/assistant/assistant_manager_service_impl.h"
#include "chromeos/services/assistant/assistant_settings_manager_impl.h"
#include "chromeos/services/assistant/utils.h"
#include "services/device/public/mojom/battery_monitor.mojom.h"
#include "services/device/public/mojom/constants.mojom.h"
#else
......@@ -57,6 +59,7 @@ Service::Service()
token_refresh_timer_(std::make_unique<base::OneShotTimer>()),
main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
power_manager_observer_(this),
voice_interaction_observer_binding_(this),
weak_ptr_factory_(this) {
registry_.AddInterface<mojom::AssistantPlatform>(base::BindRepeating(
&Service::BindAssistantPlatformConnection, base::Unretained(this)));
......@@ -128,6 +131,15 @@ void Service::OnLockStateChanged(bool locked) {
UpdateListeningState();
}
void Service::OnVoiceInteractionHotwordEnabled(bool enabled) {
if (assistant_manager_service_->GetState() !=
AssistantManagerService::State::RUNNING) {
return;
}
CreateAssistantManagerService(enabled);
RequestAccessToken();
}
void Service::BindAssistantSettingsManager(
mojom::AssistantSettingsManagerRequest request) {
DCHECK(assistant_settings_manager_);
......@@ -164,11 +176,13 @@ void Service::Init(mojom::ClientPtr client,
client_ = std::move(client);
device_actions_ = std::move(device_actions);
#if BUILDFLAG(ENABLE_CROS_LIBASSISTANT)
device::mojom::BatteryMonitorPtr battery_monitor;
context()->connector()->BindInterface(device::mojom::kServiceName,
mojo::MakeRequest(&battery_monitor));
assistant_manager_service_ = std::make_unique<AssistantManagerServiceImpl>(
context()->connector(), std::move(battery_monitor), this);
context()->connector()->BindInterface(ash::mojom::kServiceName,
&voice_interaction_controller_);
ash::mojom::VoiceInteractionObserverPtr ptr;
voice_interaction_observer_binding_.Bind(mojo::MakeRequest(&ptr));
voice_interaction_controller_->IsHotwordEnabled(base::BindOnce(
&Service::CreateAssistantManagerService, weak_ptr_factory_.GetWeakPtr()));
voice_interaction_controller_->AddObserver(std::move(ptr));
#else
assistant_manager_service_ =
std::make_unique<FakeAssistantManagerServiceImpl>();
......@@ -229,6 +243,18 @@ void Service::GetAccessTokenCallback(const base::Optional<std::string>& token,
this, &Service::RequestAccessToken);
}
void Service::CreateAssistantManagerService(bool enable_hotword) {
#if BUILDFLAG(ENABLE_CROS_LIBASSISTANT)
// TODO(updowndota): Check settings enabled pref when start Assistant.
device::mojom::BatteryMonitorPtr battery_monitor;
context()->connector()->BindInterface(device::mojom::kServiceName,
mojo::MakeRequest(&battery_monitor));
assistant_manager_service_ = std::make_unique<AssistantManagerServiceImpl>(
context()->connector(), std::move(battery_monitor), this,
CreateLibAssistantConfig(!enable_hotword));
#endif
}
void Service::FinalizeAssistantManagerService() {
DCHECK(assistant_manager_service_->GetState() ==
AssistantManagerService::State::RUNNING);
......
......@@ -10,6 +10,7 @@
#include "ash/public/interfaces/assistant_controller.mojom.h"
#include "ash/public/interfaces/session_controller.mojom.h"
#include "ash/public/interfaces/voice_interaction_controller.mojom.h"
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
......@@ -41,7 +42,8 @@ class AssistantSettingsManager;
class Service : public service_manager::Service,
public chromeos::PowerManagerClient::Observer,
public ash::mojom::SessionActivationObserver,
public mojom::AssistantPlatform {
public mojom::AssistantPlatform,
public ash::mojom::VoiceInteractionObserver {
public:
Service();
~Service() override;
......@@ -81,6 +83,16 @@ class Service : public service_manager::Service,
void OnSessionActivated(bool activated) override;
void OnLockStateChanged(bool locked) override;
// ash::mojom::VoiceInteractionObserver:
void OnVoiceInteractionStatusChanged(
ash::mojom::VoiceInteractionState state) override {}
void OnVoiceInteractionSettingsEnabled(bool enabled) override {}
void OnVoiceInteractionContextEnabled(bool enabled) override {}
void OnVoiceInteractionHotwordEnabled(bool enabled) override;
void OnVoiceInteractionSetupCompleted(bool completed) override {}
void OnAssistantFeatureAllowedChanged(
ash::mojom::AssistantAllowedState state) override {}
void BindAssistantSettingsManager(
mojom::AssistantSettingsManagerRequest request);
......@@ -100,6 +112,8 @@ class Service : public service_manager::Service,
void UpdateListeningState();
void CreateAssistantManagerService(bool enable_hotword);
void FinalizeAssistantManagerService();
void RetryRefreshToken();
......@@ -131,6 +145,9 @@ class Service : public service_manager::Service,
bool locked_ = false;
ash::mojom::AssistantControllerPtr assistant_controller_;
ash::mojom::VoiceInteractionControllerPtr voice_interaction_controller_;
mojo::Binding<ash::mojom::VoiceInteractionObserver>
voice_interaction_observer_binding_;
base::WeakPtrFactory<Service> weak_ptr_factory_;
......
......@@ -14,7 +14,7 @@
namespace chromeos {
namespace assistant {
std::string CreateLibAssistantConfig() {
std::string CreateLibAssistantConfig(bool disable_hotword) {
using Value = base::Value;
using Type = base::Value::Type;
......@@ -38,6 +38,14 @@ std::string CreateLibAssistantConfig() {
internal.SetKey("disable_log_files", Value(true));
config.SetKey("internal", std::move(internal));
Value audio_input(Type::DICTIONARY);
Value sources(Type::LIST);
Value dict(Type::DICTIONARY);
dict.SetKey("disable_hotword", Value(disable_hotword));
sources.GetList().push_back(std::move(dict));
audio_input.SetKey("sources", std::move(sources));
config.SetKey("audio_input", std::move(audio_input));
std::string json;
base::JSONWriter::Write(config, &json);
return json;
......
......@@ -12,7 +12,7 @@
namespace chromeos {
namespace assistant {
std::string CreateLibAssistantConfig();
std::string CreateLibAssistantConfig(bool disable_hotword);
} // namespace assistant
} // namespace chromeos
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment