Commit 498d336c authored by wutao's avatar wutao Committed by Commit Bot

Assistant: Update device locale when pref changes

This patch updates device_settings' locale when user changes the voice
interaction pref kArcVoiceInteractionValuePropAccepted.

Bug: b/110094434, b/80431063
Test: manual. Can see updated locale in the log.
Change-Id: I80c90aca6c2e7c57cd2fd96ba998f43812e685c8
Reviewed-on: https://chromium-review.googlesource.com/1112617
Commit-Queue: Tao Wu <wutao@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569794}
parent 90bfef65
...@@ -43,9 +43,14 @@ AssistantManagerServiceImpl::AssistantManagerServiceImpl( ...@@ -43,9 +43,14 @@ AssistantManagerServiceImpl::AssistantManagerServiceImpl(
action_module_(std::make_unique<action::CrosActionModule>(this)), action_module_(std::make_unique<action::CrosActionModule>(this)),
display_connection_(std::make_unique<CrosDisplayConnection>(this)), display_connection_(std::make_unique<CrosDisplayConnection>(this)),
main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
voice_interaction_observer_binding_(this),
weak_factory_(this) { weak_factory_(this) {
connector->BindInterface(ash::mojom::kServiceName, connector->BindInterface(ash::mojom::kServiceName,
&voice_interaction_controller_); &voice_interaction_controller_);
ash::mojom::VoiceInteractionObserverPtr ptr;
voice_interaction_observer_binding_.Bind(mojo::MakeRequest(&ptr));
voice_interaction_controller_->AddObserver(std::move(ptr));
} }
AssistantManagerServiceImpl::~AssistantManagerServiceImpl() {} AssistantManagerServiceImpl::~AssistantManagerServiceImpl() {}
...@@ -246,6 +251,11 @@ bool AssistantManagerServiceImpl::IsSettingSupported( ...@@ -246,6 +251,11 @@ bool AssistantManagerServiceImpl::IsSettingSupported(
setting_id == kBluetoothDeviceSettingId); setting_id == kBluetoothDeviceSettingId);
} }
void AssistantManagerServiceImpl::OnVoiceInteractionSetupCompleted(
bool completed) {
UpdateDeviceLocale(completed);
}
void AssistantManagerServiceImpl::StartAssistantInternal( void AssistantManagerServiceImpl::StartAssistantInternal(
base::OnceCallback<void()> callback, base::OnceCallback<void()> callback,
const std::string& access_token, const std::string& access_token,
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "libassistant/contrib/core/macros.h" #include "libassistant/contrib/core/macros.h"
#include "libassistant/shared/internal_api/assistant_manager_delegate.h" #include "libassistant/shared/internal_api/assistant_manager_delegate.h"
#include "libassistant/shared/public/conversation_state_listener.h" #include "libassistant/shared/public/conversation_state_listener.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/interface_ptr_set.h" #include "mojo/public/cpp/bindings/interface_ptr_set.h"
#include "services/device/public/mojom/battery_monitor.mojom.h" #include "services/device/public/mojom/battery_monitor.mojom.h"
...@@ -46,7 +47,8 @@ class AssistantManagerServiceImpl ...@@ -46,7 +47,8 @@ class AssistantManagerServiceImpl
public ::chromeos::assistant::action::AssistantActionObserver, public ::chromeos::assistant::action::AssistantActionObserver,
public AssistantEventObserver, public AssistantEventObserver,
public assistant_client::ConversationStateListener, public assistant_client::ConversationStateListener,
public assistant_client::AssistantManagerDelegate { public assistant_client::AssistantManagerDelegate,
public ash::mojom::VoiceInteractionObserver {
public: public:
AssistantManagerServiceImpl(service_manager::Connector* connector, AssistantManagerServiceImpl(service_manager::Connector* connector,
device::mojom::BatteryMonitorPtr battery_monitor); device::mojom::BatteryMonitorPtr battery_monitor);
...@@ -98,6 +100,15 @@ class AssistantManagerServiceImpl ...@@ -98,6 +100,15 @@ class AssistantManagerServiceImpl
const std::string& modify_setting_args_proto) override; const std::string& modify_setting_args_proto) override;
bool IsSettingSupported(const std::string& setting_id) override; bool IsSettingSupported(const std::string& setting_id) override;
// ash::mojom::VoiceInteractionObserver:
void OnVoiceInteractionStatusChanged(
ash::mojom::VoiceInteractionState state) override {}
void OnVoiceInteractionSettingsEnabled(bool enabled) override {}
void OnVoiceInteractionContextEnabled(bool enabled) override {}
void OnVoiceInteractionSetupCompleted(bool completed) override;
void OnAssistantFeatureAllowedChanged(
ash::mojom::AssistantAllowedState state) override {}
private: private:
void StartAssistantInternal( void StartAssistantInternal(
base::OnceClosure callback, base::OnceClosure callback,
...@@ -147,6 +158,8 @@ class AssistantManagerServiceImpl ...@@ -147,6 +158,8 @@ class AssistantManagerServiceImpl
mojo::InterfacePtrSet<mojom::AssistantEventSubscriber> subscribers_; mojo::InterfacePtrSet<mojom::AssistantEventSubscriber> subscribers_;
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
ash::mojom::VoiceInteractionControllerPtr voice_interaction_controller_; ash::mojom::VoiceInteractionControllerPtr voice_interaction_controller_;
mojo::Binding<ash::mojom::VoiceInteractionObserver>
voice_interaction_observer_binding_;
base::WeakPtrFactory<AssistantManagerServiceImpl> weak_factory_; base::WeakPtrFactory<AssistantManagerServiceImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(AssistantManagerServiceImpl); DISALLOW_COPY_AND_ASSIGN(AssistantManagerServiceImpl);
......
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