Commit 2a30fbc5 authored by wutao's avatar wutao Committed by Commit Bot

assistant: Do not focus mic button by default

To reduce the ChromeVox interaction in Assistant listening mode,
This patch:
1. Does not focus on the Mic button when showing the voice input UI.
2. Fixes a bug that shows keyboard input UI first and then switch to
   voice input UI.

Bug: b/167501035
Test: Updated tests
Change-Id: I6bdc83a114f4a8a6ebeb691ec0d784ec5696cf44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2532929
Commit-Queue: Tao Wu <wutao@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828389}
parent 066b6ac4
...@@ -296,7 +296,7 @@ views::View* AssistantDialogPlate::FindFirstFocusableView() { ...@@ -296,7 +296,7 @@ views::View* AssistantDialogPlate::FindFirstFocusableView() {
case InputModality::kKeyboard: case InputModality::kKeyboard:
return textfield_; return textfield_;
case InputModality::kVoice: case InputModality::kVoice:
return animated_voice_input_toggle_; return voice_layout_container_;
} }
} }
......
...@@ -430,10 +430,10 @@ TEST_F(AssistantPageViewTest, ...@@ -430,10 +430,10 @@ TEST_F(AssistantPageViewTest,
} }
} }
TEST_F(AssistantPageViewTest, ShouldFocusMicWhenOpeningWithHotword) { TEST_F(AssistantPageViewTest, ShouldNotFocusMicWhenOpeningWithHotword) {
ShowAssistantUi(AssistantEntryPoint::kHotword); ShowAssistantUi(AssistantEntryPoint::kHotword);
EXPECT_HAS_FOCUS(mic_view()); EXPECT_NOT_HAS_FOCUS(mic_view());
} }
TEST_F(AssistantPageViewTest, ShouldShowGreetingLabelWhenOpening) { TEST_F(AssistantPageViewTest, ShouldShowGreetingLabelWhenOpening) {
...@@ -628,12 +628,13 @@ TEST_F(AssistantPageViewTest, ...@@ -628,12 +628,13 @@ TEST_F(AssistantPageViewTest,
EXPECT_FALSE(onboarding_view()->IsDrawn()); EXPECT_FALSE(onboarding_view()->IsDrawn());
} }
TEST_F(AssistantPageViewTest, ShouldFocusMicViewWhenPressingVoiceInputToggle) { TEST_F(AssistantPageViewTest,
ShouldNotFocusMicViewWhenPressingVoiceInputToggle) {
ShowAssistantUiInTextMode(); ShowAssistantUiInTextMode();
ClickOnAndWait(voice_input_toggle()); ClickOnAndWait(voice_input_toggle());
EXPECT_HAS_FOCUS(mic_view()); EXPECT_NOT_HAS_FOCUS(mic_view());
} }
TEST_F(AssistantPageViewTest, TEST_F(AssistantPageViewTest,
...@@ -934,16 +935,17 @@ class AssistantPageViewTabletModeTest : public AssistantPageViewTest { ...@@ -934,16 +935,17 @@ class AssistantPageViewTabletModeTest : public AssistantPageViewTest {
}; };
TEST_F(AssistantPageViewTabletModeTest, TEST_F(AssistantPageViewTabletModeTest,
ShouldFocusMicWhenOpeningWithLongPressLauncher) { ShouldNotFocusMicWhenOpeningWithLongPressLauncher) {
ShowAssistantUi(AssistantEntryPoint::kLongPressLauncher); ShowAssistantUi(AssistantEntryPoint::kLongPressLauncher);
EXPECT_HAS_FOCUS(mic_view()); EXPECT_NOT_HAS_FOCUS(mic_view());
} }
TEST_F(AssistantPageViewTabletModeTest, ShouldFocusMicWhenOpeningWithHotword) { TEST_F(AssistantPageViewTabletModeTest,
ShouldNotFocusMicWhenOpeningWithHotword) {
ShowAssistantUi(AssistantEntryPoint::kHotword); ShowAssistantUi(AssistantEntryPoint::kHotword);
EXPECT_HAS_FOCUS(mic_view()); EXPECT_NOT_HAS_FOCUS(mic_view());
} }
TEST_F(AssistantPageViewTabletModeTest, ShouldFocusTextFieldAfterSendingQuery) { TEST_F(AssistantPageViewTabletModeTest, ShouldFocusTextFieldAfterSendingQuery) {
......
...@@ -282,7 +282,6 @@ void AssistantInteractionControllerImpl::OnUiVisibilityChanged( ...@@ -282,7 +282,6 @@ void AssistantInteractionControllerImpl::OnUiVisibilityChanged(
// reset the interaction state and restore the default input modality. // reset the interaction state and restore the default input modality.
StopActiveInteraction(true); StopActiveInteraction(true);
model_.ClearInteraction(); model_.ClearInteraction();
model_.SetInputModality(GetDefaultInputModality());
break; break;
case AssistantVisibility::kVisible: case AssistantVisibility::kVisible:
OnUiVisible(entry_point.value()); OnUiVisible(entry_point.value());
...@@ -902,12 +901,15 @@ void AssistantInteractionControllerImpl::OnPendingResponseProcessed( ...@@ -902,12 +901,15 @@ void AssistantInteractionControllerImpl::OnPendingResponseProcessed(
void AssistantInteractionControllerImpl::OnUiVisible( void AssistantInteractionControllerImpl::OnUiVisible(
AssistantEntryPoint entry_point) { AssistantEntryPoint entry_point) {
DCHECK(IsVisible()); DCHECK(IsVisible());
const bool is_voice_entry =
assistant::util::IsVoiceEntryPoint(entry_point, IsPreferVoice());
model_.SetInputModality(is_voice_entry ? InputModality::kVoice
: InputModality::kKeyboard);
// We don't explicitly start a new voice interaction if the entry point // We don't explicitly start a new voice interaction if the entry point
// is hotword since in such cases a voice interaction will already be in // is hotword since in such cases a voice interaction will already be in
// progress. // progress.
if (assistant::util::IsVoiceEntryPoint(entry_point, IsPreferVoice()) && if (is_voice_entry && entry_point != AssistantEntryPoint::kHotword) {
entry_point != AssistantEntryPoint::kHotword) {
StartVoiceInteraction(); StartVoiceInteraction();
return; return;
} }
......
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