Commit 05715217 authored by Xiaohui Chen's avatar Xiaohui Chen Committed by Commit Bot

Fix voice_interaction_state regressions

Bug: b:112279985
Test: locally build and run, settings disable/enable, hotword
Test: notification
Change-Id: I9d3ec86cf7186f77867386f7cbfeb4efd5a45e15
Reviewed-on: https://chromium-review.googlesource.com/1165798Reviewed-by: default avatarYue Li <updowndota@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Xiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581575}
parent 8c86ba83
...@@ -270,7 +270,7 @@ void AssistantController::NotifyUrlOpened(const GURL& url) { ...@@ -270,7 +270,7 @@ void AssistantController::NotifyUrlOpened(const GURL& url) {
void AssistantController::OnVoiceInteractionStatusChanged( void AssistantController::OnVoiceInteractionStatusChanged(
mojom::VoiceInteractionState state) { mojom::VoiceInteractionState state) {
if (state == mojom::VoiceInteractionState::STOPPED) if (state == mojom::VoiceInteractionState::NOT_READY)
assistant_ui_controller_->HideUi(AssistantSource::kUnspecified); assistant_ui_controller_->HideUi(AssistantSource::kUnspecified);
} }
......
...@@ -363,10 +363,6 @@ void AssistantInteractionController::StartTextInteraction( ...@@ -363,10 +363,6 @@ void AssistantInteractionController::StartTextInteraction(
const std::string text) { const std::string text) {
StopActiveInteraction(); StopActiveInteraction();
if (Shell::Get()->voice_interaction_controller()->voice_interaction_state() !=
mojom::VoiceInteractionState::RUNNING)
return;
assistant_interaction_model_.SetPendingQuery( assistant_interaction_model_.SetPendingQuery(
std::make_unique<AssistantTextQuery>(text)); std::make_unique<AssistantTextQuery>(text));
...@@ -376,10 +372,6 @@ void AssistantInteractionController::StartTextInteraction( ...@@ -376,10 +372,6 @@ void AssistantInteractionController::StartTextInteraction(
void AssistantInteractionController::StartVoiceInteraction() { void AssistantInteractionController::StartVoiceInteraction() {
StopActiveInteraction(); StopActiveInteraction();
if (Shell::Get()->voice_interaction_controller()->voice_interaction_state() !=
mojom::VoiceInteractionState::RUNNING)
return;
assistant_interaction_model_.SetPendingQuery( assistant_interaction_model_.SetPendingQuery(
std::make_unique<AssistantVoiceQuery>()); std::make_unique<AssistantVoiceQuery>());
...@@ -394,9 +386,6 @@ void AssistantInteractionController::StopActiveInteraction() { ...@@ -394,9 +386,6 @@ void AssistantInteractionController::StopActiveInteraction() {
assistant_interaction_model_.SetInteractionState(InteractionState::kInactive); assistant_interaction_model_.SetInteractionState(InteractionState::kInactive);
assistant_interaction_model_.ClearPendingQuery(); assistant_interaction_model_.ClearPendingQuery();
if (Shell::Get()->voice_interaction_controller()->voice_interaction_state() !=
mojom::VoiceInteractionState::RUNNING)
return;
assistant_->StopActiveInteraction(); assistant_->StopActiveInteraction();
// Because we are stopping an interaction in progress, we discard any pending // Because we are stopping an interaction in progress, we discard any pending
......
...@@ -111,17 +111,11 @@ void AssistantNotificationController::SetAssistant( ...@@ -111,17 +111,11 @@ void AssistantNotificationController::SetAssistant(
void AssistantNotificationController::RetrieveNotification( void AssistantNotificationController::RetrieveNotification(
AssistantNotificationPtr notification, AssistantNotificationPtr notification,
int action_index) { int action_index) {
if (Shell::Get()->voice_interaction_controller()->voice_interaction_state() !=
mojom::VoiceInteractionState::RUNNING)
return;
assistant_->RetrieveNotification(std::move(notification), action_index); assistant_->RetrieveNotification(std::move(notification), action_index);
} }
void AssistantNotificationController::DismissNotification( void AssistantNotificationController::DismissNotification(
AssistantNotificationPtr notification) { AssistantNotificationPtr notification) {
if (Shell::Get()->voice_interaction_controller()->voice_interaction_state() !=
mojom::VoiceInteractionState::RUNNING)
return;
assistant_->DismissNotification(std::move(notification)); assistant_->DismissNotification(std::move(notification));
} }
......
...@@ -172,10 +172,6 @@ void AssistantScreenContextController::RequestScreenshot( ...@@ -172,10 +172,6 @@ void AssistantScreenContextController::RequestScreenshot(
void AssistantScreenContextController::RequestScreenContext( void AssistantScreenContextController::RequestScreenContext(
const gfx::Rect& rect) { const gfx::Rect& rect) {
if (Shell::Get()->voice_interaction_controller()->voice_interaction_state() !=
mojom::VoiceInteractionState::RUNNING)
return;
// Abort any request in progress and update request state. // Abort any request in progress and update request state.
screen_context_request_factory_.InvalidateWeakPtrs(); screen_context_request_factory_.InvalidateWeakPtrs();
assistant_screen_context_model_.SetRequestState( assistant_screen_context_model_.SetRequestState(
......
...@@ -218,6 +218,11 @@ void AssistantUiController::ShowUi(AssistantSource source) { ...@@ -218,6 +218,11 @@ void AssistantUiController::ShowUi(AssistantSource source) {
if (!Shell::Get()->voice_interaction_controller()->settings_enabled()) if (!Shell::Get()->voice_interaction_controller()->settings_enabled())
return; return;
if (Shell::Get()->voice_interaction_controller()->voice_interaction_state() ==
mojom::VoiceInteractionState::NOT_READY) {
return;
}
if (!assistant_) { if (!assistant_) {
ShowToast(kUnboundServiceToastId, IDS_ASH_ASSISTANT_ERROR_GENERIC); ShowToast(kUnboundServiceToastId, IDS_ASH_ASSISTANT_ERROR_GENERIC);
return; return;
......
...@@ -96,7 +96,7 @@ void AssistantSetup::StartAssistantOptInFlow( ...@@ -96,7 +96,7 @@ void AssistantSetup::StartAssistantOptInFlow(
} }
void AssistantSetup::OnStateChanged(ash::mojom::VoiceInteractionState state) { void AssistantSetup::OnStateChanged(ash::mojom::VoiceInteractionState state) {
if (state != ash::mojom::VoiceInteractionState::RUNNING) if (state == ash::mojom::VoiceInteractionState::NOT_READY)
return; return;
// If the optin flow is active, no need to show the notification since it is // If the optin flow is active, no need to show the notification since it is
...@@ -110,6 +110,7 @@ void AssistantSetup::OnStateChanged(ash::mojom::VoiceInteractionState state) { ...@@ -110,6 +110,7 @@ void AssistantSetup::OnStateChanged(ash::mojom::VoiceInteractionState state) {
->IsDefaultValue()) { ->IsDefaultValue()) {
return; return;
} }
// TODO(xiaohuic): need better ways to decide when to show the notification.
// Avoid the notification from keep showing up. // Avoid the notification from keep showing up.
prefs->SetBoolean(arc::prefs::kVoiceInteractionHotwordEnabled, false); prefs->SetBoolean(arc::prefs::kVoiceInteractionHotwordEnabled, false);
......
...@@ -241,8 +241,8 @@ void AssistantOptInHandler::RegisterMessages() { ...@@ -241,8 +241,8 @@ void AssistantOptInHandler::RegisterMessages() {
} }
void AssistantOptInHandler::Initialize() { void AssistantOptInHandler::Initialize() {
if (arc::VoiceInteractionControllerClient::Get()->voice_interaction_state() != if (arc::VoiceInteractionControllerClient::Get()->voice_interaction_state() ==
ash::mojom::VoiceInteractionState::RUNNING) { ash::mojom::VoiceInteractionState::NOT_READY) {
arc::VoiceInteractionControllerClient::Get()->AddObserver(this); arc::VoiceInteractionControllerClient::Get()->AddObserver(this);
} else { } else {
BindAssistantSettingsManager(); BindAssistantSettingsManager();
...@@ -282,8 +282,10 @@ void AssistantOptInHandler::OnEmailOptInResult(bool opted_in) { ...@@ -282,8 +282,10 @@ void AssistantOptInHandler::OnEmailOptInResult(bool opted_in) {
void AssistantOptInHandler::OnStateChanged( void AssistantOptInHandler::OnStateChanged(
ash::mojom::VoiceInteractionState state) { ash::mojom::VoiceInteractionState state) {
if (state == ash::mojom::VoiceInteractionState::RUNNING) if (state != ash::mojom::VoiceInteractionState::NOT_READY) {
BindAssistantSettingsManager(); BindAssistantSettingsManager();
arc::VoiceInteractionControllerClient::Get()->RemoveObserver(this);
}
} }
void AssistantOptInHandler::BindAssistantSettingsManager() { void AssistantOptInHandler::BindAssistantSettingsManager() {
......
...@@ -729,11 +729,6 @@ void AssistantManagerServiceImpl::OnSpeechLevelUpdatedOnMainThread( ...@@ -729,11 +729,6 @@ void AssistantManagerServiceImpl::OnSpeechLevelUpdatedOnMainThread(
[&speech_level](auto* ptr) { ptr->OnSpeechLevelUpdated(speech_level); }); [&speech_level](auto* ptr) { ptr->OnSpeechLevelUpdated(speech_level); });
} }
void AssistantManagerServiceImpl::IsVoiceInteractionSetupCompleted(
ash::mojom::VoiceInteractionController::IsSetupCompletedCallback callback) {
voice_interaction_controller_->IsSetupCompleted(std::move(callback));
}
void AssistantManagerServiceImpl::OnAssistantStructureReceived( void AssistantManagerServiceImpl::OnAssistantStructureReceived(
base::OnceClosure on_done, base::OnceClosure on_done,
ax::mojom::AssistantExtraPtr assistant_extra, ax::mojom::AssistantExtraPtr assistant_extra,
......
...@@ -176,9 +176,6 @@ class AssistantManagerServiceImpl ...@@ -176,9 +176,6 @@ class AssistantManagerServiceImpl
void OnSpeechLevelUpdatedOnMainThread(const float speech_level); void OnSpeechLevelUpdatedOnMainThread(const float speech_level);
void OnModifySettingsAction(const std::string& modify_setting_args_proto); void OnModifySettingsAction(const std::string& modify_setting_args_proto);
void IsVoiceInteractionSetupCompleted(
ash::mojom::VoiceInteractionController::IsSetupCompletedCallback
callback);
void RegisterFallbackMediaHandler(); void RegisterFallbackMediaHandler();
void SendContextQueryAndRunCallback(RequestScreenContextCallback callback); void SendContextQueryAndRunCallback(RequestScreenContextCallback callback);
......
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