Commit edb517a4 authored by David Black's avatar David Black Committed by Commit Bot

Respect user preference to open mic on Assistant launch.

Previously a voice interaction was only started if in tablet mode. Now,
we'll also factor in user preference to start a voice interaction on
Assistant entry.

This CL is reliant on and cannot be submitted before:
https://chromium-review.googlesource.com/c/chromium/src/+/1244441

Bug: b:115843337
Change-Id: Ia50b992843e542027e26faa2b522f3d4d48aa58e
Reviewed-on: https://chromium-review.googlesource.com/1252631
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595633}
parent 7b76fce3
......@@ -162,13 +162,7 @@ void AssistantInteractionController::OnUiVisibilityChanged(
model_.SetInputModality(InputModality::kKeyboard);
break;
case AssistantVisibility::kVisible:
if (source == AssistantSource::kLauncherSearchBox ||
source == AssistantSource::kLongPressLauncher) {
if (IsTabletMode())
StartVoiceInteraction();
} else if (source == AssistantSource::kStylus) {
model_.SetInputModality(InputModality::kStylus);
}
OnUiVisible(source);
break;
}
}
......@@ -451,6 +445,34 @@ void AssistantInteractionController::OnDialogPlateContentsCommitted(
StartTextInteraction(text);
}
void AssistantInteractionController::OnUiVisible(AssistantSource source) {
DCHECK_EQ(AssistantVisibility::kVisible,
assistant_controller_->ui_controller()->model()->visibility());
switch (source) {
case AssistantSource::kHotkey:
case AssistantSource::kLauncherSearchBox:
case AssistantSource::kLongPressLauncher: {
// When the user prefers it or when we are in tablet mode, launching
// Assistant UI will immediately start a voice interaction.
const bool launch_with_mic_open =
Shell::Get()->voice_interaction_controller()->launch_with_mic_open();
if (launch_with_mic_open || IsTabletMode())
StartVoiceInteraction();
break;
}
case AssistantSource::kStylus:
model_.SetInputModality(InputModality::kStylus);
break;
case AssistantSource::kUnspecified:
case AssistantSource::kDeepLink:
case AssistantSource::kHotword:
case AssistantSource::kSetup:
// No action necessary.
break;
}
}
void AssistantInteractionController::StartMetalayerInteraction(
const gfx::Rect& region) {
StopActiveInteraction(false);
......
......@@ -99,6 +99,8 @@ class AssistantInteractionController
void OnSuggestionChipPressed(const AssistantSuggestion* suggestion);
private:
void OnUiVisible(AssistantSource source);
void StartMetalayerInteraction(const gfx::Rect& region);
void StartScreenContextInteraction();
void StartTextInteraction(const std::string text);
......
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