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) {
void AssistantController::OnVoiceInteractionStatusChanged(
mojom::VoiceInteractionState state) {
if (state == mojom::VoiceInteractionState::STOPPED)
if (state == mojom::VoiceInteractionState::NOT_READY)
assistant_ui_controller_->HideUi(AssistantSource::kUnspecified);
}
......
......@@ -363,10 +363,6 @@ void AssistantInteractionController::StartTextInteraction(
const std::string text) {
StopActiveInteraction();
if (Shell::Get()->voice_interaction_controller()->voice_interaction_state() !=
mojom::VoiceInteractionState::RUNNING)
return;
assistant_interaction_model_.SetPendingQuery(
std::make_unique<AssistantTextQuery>(text));
......@@ -376,10 +372,6 @@ void AssistantInteractionController::StartTextInteraction(
void AssistantInteractionController::StartVoiceInteraction() {
StopActiveInteraction();
if (Shell::Get()->voice_interaction_controller()->voice_interaction_state() !=
mojom::VoiceInteractionState::RUNNING)
return;
assistant_interaction_model_.SetPendingQuery(
std::make_unique<AssistantVoiceQuery>());
......@@ -394,9 +386,6 @@ void AssistantInteractionController::StopActiveInteraction() {
assistant_interaction_model_.SetInteractionState(InteractionState::kInactive);
assistant_interaction_model_.ClearPendingQuery();
if (Shell::Get()->voice_interaction_controller()->voice_interaction_state() !=
mojom::VoiceInteractionState::RUNNING)
return;
assistant_->StopActiveInteraction();
// Because we are stopping an interaction in progress, we discard any pending
......
......@@ -111,17 +111,11 @@ void AssistantNotificationController::SetAssistant(
void AssistantNotificationController::RetrieveNotification(
AssistantNotificationPtr notification,
int action_index) {
if (Shell::Get()->voice_interaction_controller()->voice_interaction_state() !=
mojom::VoiceInteractionState::RUNNING)
return;
assistant_->RetrieveNotification(std::move(notification), action_index);
}
void AssistantNotificationController::DismissNotification(
AssistantNotificationPtr notification) {
if (Shell::Get()->voice_interaction_controller()->voice_interaction_state() !=
mojom::VoiceInteractionState::RUNNING)
return;
assistant_->DismissNotification(std::move(notification));
}
......
......@@ -172,10 +172,6 @@ void AssistantScreenContextController::RequestScreenshot(
void AssistantScreenContextController::RequestScreenContext(
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.
screen_context_request_factory_.InvalidateWeakPtrs();
assistant_screen_context_model_.SetRequestState(
......
......@@ -218,6 +218,11 @@ void AssistantUiController::ShowUi(AssistantSource source) {
if (!Shell::Get()->voice_interaction_controller()->settings_enabled())
return;
if (Shell::Get()->voice_interaction_controller()->voice_interaction_state() ==
mojom::VoiceInteractionState::NOT_READY) {
return;
}
if (!assistant_) {
ShowToast(kUnboundServiceToastId, IDS_ASH_ASSISTANT_ERROR_GENERIC);
return;
......
......@@ -96,7 +96,7 @@ void AssistantSetup::StartAssistantOptInFlow(
}
void AssistantSetup::OnStateChanged(ash::mojom::VoiceInteractionState state) {
if (state != ash::mojom::VoiceInteractionState::RUNNING)
if (state == ash::mojom::VoiceInteractionState::NOT_READY)
return;
// 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) {
->IsDefaultValue()) {
return;
}
// TODO(xiaohuic): need better ways to decide when to show the notification.
// Avoid the notification from keep showing up.
prefs->SetBoolean(arc::prefs::kVoiceInteractionHotwordEnabled, false);
......
......@@ -241,8 +241,8 @@ void AssistantOptInHandler::RegisterMessages() {
}
void AssistantOptInHandler::Initialize() {
if (arc::VoiceInteractionControllerClient::Get()->voice_interaction_state() !=
ash::mojom::VoiceInteractionState::RUNNING) {
if (arc::VoiceInteractionControllerClient::Get()->voice_interaction_state() ==
ash::mojom::VoiceInteractionState::NOT_READY) {
arc::VoiceInteractionControllerClient::Get()->AddObserver(this);
} else {
BindAssistantSettingsManager();
......@@ -282,8 +282,10 @@ void AssistantOptInHandler::OnEmailOptInResult(bool opted_in) {
void AssistantOptInHandler::OnStateChanged(
ash::mojom::VoiceInteractionState state) {
if (state == ash::mojom::VoiceInteractionState::RUNNING)
if (state != ash::mojom::VoiceInteractionState::NOT_READY) {
BindAssistantSettingsManager();
arc::VoiceInteractionControllerClient::Get()->RemoveObserver(this);
}
}
void AssistantOptInHandler::BindAssistantSettingsManager() {
......
......@@ -729,11 +729,6 @@ void AssistantManagerServiceImpl::OnSpeechLevelUpdatedOnMainThread(
[&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(
base::OnceClosure on_done,
ax::mojom::AssistantExtraPtr assistant_extra,
......
......@@ -176,9 +176,6 @@ class AssistantManagerServiceImpl
void OnSpeechLevelUpdatedOnMainThread(const float speech_level);
void OnModifySettingsAction(const std::string& modify_setting_args_proto);
void IsVoiceInteractionSetupCompleted(
ash::mojom::VoiceInteractionController::IsSetupCompletedCallback
callback);
void RegisterFallbackMediaHandler();
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