Commit 199cc2b8 authored by Meilin Wang's avatar Meilin Wang Committed by Commit Bot

Add a feature flag.

Bug: b/158630837
Test: manually.
Change-Id: I1a5158d54c8c4bd941c37d036c5be535175e9aa9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2261370Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: Meilin Wang <meilinw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781948}
parent 95c32800
......@@ -196,7 +196,8 @@ void AmbientController::OnAmbientUiVisibilityChanged(
// We close the Assistant UI after ambient screen not being shown to sync
// states to |AssistantUiController|. This will be a no-op if the
// Assistant UI has already been closed.
// |kAmbientAssistant| feature is disabled, or the Assistant UI has
// already been closed.
CloseAssistantUi();
break;
}
......
......@@ -17,6 +17,7 @@
#include "ash/public/cpp/ambient/ambient_ui_model.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/shell.h"
#include "chromeos/services/assistant/public/cpp/features.h"
#include "ui/aura/window.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/background.h"
......@@ -27,6 +28,8 @@ namespace ash {
namespace {
using chromeos::assistant::features::IsAmbientAssistantEnabled;
// Appearance.
constexpr int kHorizontalMarginDip = 16;
constexpr int kVerticalMarginDip = 64;
......@@ -53,8 +56,11 @@ gfx::Size AmbientContainerView::CalculatePreferredSize() const {
void AmbientContainerView::Layout() {
// Layout child views first to have proper bounds set for children.
LayoutPhotoView();
LayoutAssistantView();
LayoutGlanceableInfoView();
// The assistant view may not exist if |kAmbientAssistant| feature is
// disabled.
if (ambient_assistant_container_view_)
LayoutAssistantView();
View::Layout();
}
......@@ -65,12 +71,14 @@ void AmbientContainerView::Init() {
photo_view_ = AddChildView(std::make_unique<PhotoView>(delegate_));
ambient_assistant_container_view_ =
AddChildView(std::make_unique<AmbientAssistantContainerView>());
ambient_assistant_container_view_->SetVisible(false);
glanceable_info_view_ =
AddChildView(std::make_unique<GlanceableInfoView>(delegate_));
if (IsAmbientAssistantEnabled()) {
ambient_assistant_container_view_ =
AddChildView(std::make_unique<AmbientAssistantContainerView>());
ambient_assistant_container_view_->SetVisible(false);
}
}
void AmbientContainerView::LayoutPhotoView() {
......
......@@ -28,6 +28,8 @@ namespace ash {
namespace {
using chromeos::assistant::features::IsAmbientAssistantEnabled;
// Toast -----------------------------------------------------------------------
constexpr int kToastDurationMs = 2500;
......@@ -91,7 +93,7 @@ void AssistantUiControllerImpl::ShowUi(AssistantEntryPoint entry_point) {
return;
}
if (chromeos::features::IsAmbientModeEnabled() &&
if (IsAmbientAssistantEnabled() &&
Shell::Get()->ambient_controller()->IsShown()) {
model_.SetUiMode(AssistantUiMode::kAmbientUi);
model_.SetVisible(entry_point);
......
......@@ -27,6 +27,7 @@ component("cpp") {
]
deps = [
"//chromeos/constants:constants",
"//chromeos/services/assistant/public/mojom",
"//components/prefs",
"//mojo/public/cpp/bindings",
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "chromeos/services/assistant/public/cpp/features.h"
#include "chromeos/constants/chromeos_features.h"
#include "base/feature_list.h"
......@@ -37,6 +38,9 @@ const base::Feature kAssistantTimersV2{"AssistantTimersV2",
const base::Feature kAssistantWaitScheduling{"AssistantWaitScheduling",
base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kEnableAmbientAssistant{"EnableAmbientAssistant",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kEnableDspHotword{"EnableDspHotword",
base::FEATURE_DISABLED_BY_DEFAULT};
......@@ -59,6 +63,12 @@ const base::Feature kEnableMediaSessionIntegration{
const base::Feature kDisableVoiceMatch{"DisableVoiceMatch",
base::FEATURE_DISABLED_BY_DEFAULT};
bool IsAmbientAssistantEnabled() {
return chromeos::features::IsAmbientModeEnabled() &&
base::FeatureList::IsEnabled(
assistant::features::kEnableAmbientAssistant);
}
bool IsAppSupportEnabled() {
return base::FeatureList::IsEnabled(
assistant::features::kAssistantAppSupport);
......
......@@ -54,6 +54,10 @@ extern const base::Feature kAssistantTimersV2;
COMPONENT_EXPORT(ASSISTANT_SERVICE_PUBLIC)
extern const base::Feature kAssistantWaitScheduling;
// Enables Assistant in Ambient Mode.
COMPONENT_EXPORT(ASSISTANT_SERVICE_PUBLIC)
extern const base::Feature kEnableAmbientAssistant;
// Enables DSP for hotword detection.
COMPONENT_EXPORT(ASSISTANT_SERVICE_PUBLIC)
extern const base::Feature kEnableDspHotword;
......@@ -79,6 +83,8 @@ extern const base::Feature kEnableOnDeviceAssistant;
COMPONENT_EXPORT(ASSISTANT_SERVICE_PUBLIC)
extern const base::Feature kEnableLibAssistantBetaBackend;
COMPONENT_EXPORT(ASSISTANT_SERVICE_PUBLIC) bool IsAmbientAssistantEnabled();
COMPONENT_EXPORT(ASSISTANT_SERVICE_PUBLIC) bool IsAppSupportEnabled();
COMPONENT_EXPORT(ASSISTANT_SERVICE_PUBLIC) bool IsAudioEraserEnabled();
......
......@@ -60,6 +60,7 @@ namespace assistant {
namespace {
using chromeos::assistant::features::IsAmbientAssistantEnabled;
using CommunicationErrorType = AssistantManagerService::CommunicationErrorType;
constexpr char kScopeAuthGcm[] = "https://www.googleapis.com/auth/gcm";
......@@ -110,7 +111,7 @@ bool IsSignedOutMode() {
// We will switch the Libassitsant mode to signed-out/signed-in when user
// enters/exits the ambient mode.
const bool entered_ambient_mode =
chromeos::features::IsAmbientModeEnabled() && InAmbientMode();
IsAmbientAssistantEnabled() && InAmbientMode();
// Note that we shouldn't toggle the flag to true when exiting ambient
// mode if we have been using fake gaia login, e.g. in the Tast test.
......@@ -238,7 +239,7 @@ void Service::Init() {
ash::AssistantState::Get()->AddObserver(this);
if (chromeos::features::IsAmbientModeEnabled())
if (IsAmbientAssistantEnabled())
ambient_ui_model_observer_.Add(ash::AmbientUiModel::Get());
DCHECK(!assistant_manager_service_);
......@@ -360,6 +361,8 @@ void Service::OnStateChanged(AssistantManagerService::State new_state) {
void Service::OnAmbientUiVisibilityChanged(
ash::AmbientUiVisibility visibility) {
DCHECK(IsAmbientAssistantEnabled());
if (IsSignedOutMode()) {
UpdateAssistantManagerState();
} else {
......@@ -421,7 +424,7 @@ void Service::UpdateAssistantManagerState() {
case AssistantManagerService::State::RUNNING:
if (assistant_state->settings_enabled().value()) {
assistant_manager_service_->SetUser(GetUserInfo());
if (chromeos::features::IsAmbientModeEnabled())
if (IsAmbientAssistantEnabled())
assistant_manager_service_->EnableAmbientMode(InAmbientMode());
assistant_manager_service_->EnableHotword(ShouldEnableHotword());
assistant_manager_service_->SetArcPlayStoreEnabled(
......
......@@ -25,6 +25,7 @@
#include "chromeos/dbus/power/fake_power_manager_client.h"
#include "chromeos/services/assistant/fake_assistant_manager_service_impl.h"
#include "chromeos/services/assistant/public/cpp/assistant_prefs.h"
#include "chromeos/services/assistant/public/cpp/features.h"
#include "chromeos/services/assistant/test_support/fully_initialized_assistant_state.h"
#include "chromeos/services/assistant/test_support/scoped_assistant_client.h"
#include "chromeos/services/assistant/test_support/scoped_device_actions.h"
......@@ -76,8 +77,11 @@ class AssistantServiceTest : public testing::Test {
~AssistantServiceTest() override = default;
void SetUp() override {
scoped_feature_list_.InitAndEnableFeature(
chromeos::features::kAmbientModeFeature);
scoped_feature_list_.InitWithFeatures(
/*enabled_features=*/{chromeos::features::kAmbientModeFeature,
chromeos::assistant::features::
kEnableAmbientAssistant},
/*disabled_features=*/{});
chromeos::CrasAudioHandler::InitializeForTesting();
......
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