[suggestion_engine] Deprecate QueryAction
TESTED=device
MI4-1372 #comment Deprecate QueryAction in SuggestionEngine
Change-Id: I736824d3fd840b7b8467fa80d5c0a19c02fa6472
diff --git a/bin/suggestion_engine/BUILD.gn b/bin/suggestion_engine/BUILD.gn
index 66f51cb..ed1106b 100644
--- a/bin/suggestion_engine/BUILD.gn
+++ b/bin/suggestion_engine/BUILD.gn
@@ -36,8 +36,6 @@
source_set("suggestion_engine_impl") {
sources = [
- "auto_select_first_query_listener.cc",
- "auto_select_first_query_listener.h",
"media_player.cc",
"media_player.h",
"navigation_processor.cc",
diff --git a/bin/suggestion_engine/auto_select_first_query_listener.cc b/bin/suggestion_engine/auto_select_first_query_listener.cc
deleted file mode 100644
index a131c63..0000000
--- a/bin/suggestion_engine/auto_select_first_query_listener.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "peridot/bin/suggestion_engine/auto_select_first_query_listener.h"
-
-#include <fuchsia/modular/cpp/fidl.h>
-
-#include "peridot/bin/suggestion_engine/suggestion_engine_impl.h"
-
-namespace modular {
-
-AutoSelectFirstQueryListener::AutoSelectFirstQueryListener(
- SuggestionEngineImpl* suggestion_engine)
- : engine_(suggestion_engine) {}
-
-void AutoSelectFirstQueryListener::OnQueryResults(
- fidl::VectorPtr<fuchsia::modular::Suggestion> suggestions) {
- suggestions_.reset();
- suggestions_ = std::move(suggestions);
-}
-
-void AutoSelectFirstQueryListener::OnQueryComplete() {
- if (suggestions_->empty()) {
- return;
- }
- fuchsia::modular::Interaction interaction;
- interaction.type = fuchsia::modular::InteractionType::SELECTED;
- engine_->NotifyInteraction(suggestions_->at(0).uuid, std::move(interaction));
-}
-
-} // namespace modular
diff --git a/bin/suggestion_engine/auto_select_first_query_listener.h b/bin/suggestion_engine/auto_select_first_query_listener.h
deleted file mode 100644
index 61e0bb6..0000000
--- a/bin/suggestion_engine/auto_select_first_query_listener.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef PERIDOT_BIN_SUGGESTION_ENGINE_AUTO_SELECT_FIRST_QUERY_LISTENER_H_
-#define PERIDOT_BIN_SUGGESTION_ENGINE_AUTO_SELECT_FIRST_QUERY_LISTENER_H_
-
-#include <fuchsia/modular/cpp/fidl.h>
-
-namespace modular {
-
-class SuggestionEngineImpl;
-
-// This listener is created when performing a fuchsia::modular::QueryAction.
-// It saves the last query results received and on query complete it picks the
-// first one and selects it.
-class AutoSelectFirstQueryListener : public fuchsia::modular::QueryListener {
- public:
- AutoSelectFirstQueryListener(SuggestionEngineImpl* suggestion_engine);
-
- private:
- // |fuchsia::modular::QueryListener|
- void OnQueryResults(
- fidl::VectorPtr<fuchsia::modular::Suggestion> suggestions) override;
-
- // |fuchsia::modular::QueryListener|
- void OnQueryComplete() override;
-
- fidl::VectorPtr<fuchsia::modular::Suggestion> suggestions_;
- SuggestionEngineImpl* const engine_;
-};
-
-} // namespace modular
-
-#endif // PERIDOT_BIN_SUGGESTION_ENGINE_AUTO_SELECT_FIRST_QUERY_LISTENER_H_
diff --git a/bin/suggestion_engine/ranking_features/mod_pair_ranking_feature.cc b/bin/suggestion_engine/ranking_features/mod_pair_ranking_feature.cc
index 75cb41d..17c0545 100644
--- a/bin/suggestion_engine/ranking_features/mod_pair_ranking_feature.cc
+++ b/bin/suggestion_engine/ranking_features/mod_pair_ranking_feature.cc
@@ -61,7 +61,6 @@
case fuchsia::modular::Action::Tag::kFocusModule:
case fuchsia::modular::Action::Tag::kSetLinkValueAction:
case fuchsia::modular::Action::Tag::kUpdateModule:
- case fuchsia::modular::Action::Tag::kQueryAction:
case fuchsia::modular::Action::Tag::Invalid:
continue;
}
diff --git a/bin/suggestion_engine/suggestion_engine_impl.cc b/bin/suggestion_engine/suggestion_engine_impl.cc
index 4c4d080..643c880 100644
--- a/bin/suggestion_engine/suggestion_engine_impl.cc
+++ b/bin/suggestion_engine/suggestion_engine_impl.cc
@@ -16,7 +16,6 @@
#include "lib/fidl/cpp/clone.h"
#include "lib/fxl/random/uuid.h"
-#include "peridot/bin/suggestion_engine/auto_select_first_query_listener.h"
#include "peridot/bin/suggestion_engine/decision_policies/rank_over_threshold_decision_policy.h"
#include "peridot/bin/suggestion_engine/filters/conjugate_ranked_passive_filter.h"
#include "peridot/bin/suggestion_engine/filters/ranked_active_filter.h"
@@ -35,20 +34,11 @@
namespace modular {
-namespace {
-
-constexpr int kQueryActionMaxResults = 1;
-
-} // namespace
-
SuggestionEngineImpl::SuggestionEngineImpl(fuchsia::media::AudioPtr audio)
: debug_(std::make_shared<SuggestionDebugImpl>()),
next_processor_(debug_),
query_processor_(std::move(audio), debug_),
- context_listener_binding_(this),
- auto_select_first_query_listener_(this),
- auto_select_first_query_listener_binding_(
- &auto_select_first_query_listener_) {}
+ context_listener_binding_(this) {}
SuggestionEngineImpl::~SuggestionEngineImpl() = default;
@@ -362,7 +352,6 @@
for (auto& action : *actions) {
auto command = ActionToStoryCommand(action);
// Some actions aren't supported as story commands (yet). In particular:
- // - QueryAction: should be transformed into a SessionCommand
// - CustomAction: we would like to fully remove it and all its uses.
if (command.has_invalid_tag()) {
pending_actions.push_back(std::move(action));
@@ -429,7 +418,6 @@
command.set_update_mod(std::move(update_mod));
break;
}
- case fuchsia::modular::Action::Tag::kQueryAction:
case fuchsia::modular::Action::Tag::kCustomAction:
case fuchsia::modular::Action::Tag::Invalid:
break;
@@ -441,11 +429,6 @@
std::vector<fuchsia::modular::Action> actions) {
for (auto& action : actions) {
switch (action.Which()) {
- case fuchsia::modular::Action::Tag::kQueryAction: {
- FXL_LOG(INFO) << "Performing query action but it's deprecated.";
- PerformQueryAction(action);
- break;
- }
case fuchsia::modular::Action::Tag::kCustomAction: {
FXL_LOG(INFO) << "Performing custom action but it's deprecated.";
PerformCustomAction(&action);
@@ -470,15 +453,6 @@
action->custom_action().Bind()->Execute();
}
-void SuggestionEngineImpl::PerformQueryAction(
- const fuchsia::modular::Action& action) {
- // TODO(miguelfrde): instead of keeping a AutoSelectFirstQueryListener as an
- // attribute. Create and move here through an internal structure.
- const auto& query_action = action.query_action();
- Query(auto_select_first_query_listener_binding_.NewBinding(),
- query_action.input, kQueryActionMaxResults);
-}
-
void SuggestionEngineImpl::OnContextUpdate(
fuchsia::modular::ContextUpdate update) {
for (auto& entry : update.values.take()) {
diff --git a/bin/suggestion_engine/suggestion_engine_impl.h b/bin/suggestion_engine/suggestion_engine_impl.h
index 90d5f1b..a3db3da 100644
--- a/bin/suggestion_engine/suggestion_engine_impl.h
+++ b/bin/suggestion_engine/suggestion_engine_impl.h
@@ -14,7 +14,6 @@
#include <lib/fidl/cpp/interface_ptr_set.h>
#include <lib/fxl/memory/weak_ptr.h>
-#include "peridot/bin/suggestion_engine/auto_select_first_query_listener.h"
#include "peridot/bin/suggestion_engine/debug.h"
#include "peridot/bin/suggestion_engine/interruptions_processor.h"
#include "peridot/bin/suggestion_engine/navigation_processor.h"
@@ -181,8 +180,6 @@
void PerformDeprecatedActions(std::vector<fuchsia::modular::Action> actions);
- void PerformQueryAction(const fuchsia::modular::Action& action);
-
void PerformCustomAction(fuchsia::modular::Action* action);
void RegisterRankingFeatures();
@@ -242,12 +239,6 @@
// The puppet master connection that is used to execute actions.
fuchsia::modular::PuppetMasterPtr puppet_master_;
- // Used to jackpot a suggestion when a fuchsia::modular::QueryAction is
- // executed.
- AutoSelectFirstQueryListener auto_select_first_query_listener_;
- fidl::Binding<fuchsia::modular::QueryListener>
- auto_select_first_query_listener_binding_;
-
FXL_DISALLOW_COPY_AND_ASSIGN(SuggestionEngineImpl);
};
diff --git a/public/fidl/fuchsia.modular/suggestion/proposal.fidl b/public/fidl/fuchsia.modular/suggestion/proposal.fidl
index f42c321..61296ef 100644
--- a/public/fidl/fuchsia.modular/suggestion/proposal.fidl
+++ b/public/fidl/fuchsia.modular/suggestion/proposal.fidl
@@ -66,7 +66,6 @@
UpdateModule update_module;
SetLinkValueAction set_link_value_action;
CustomAction custom_action;
- QueryAction query_action;
};
// Brings an existing story into focus.
@@ -122,10 +121,3 @@
interface CustomAction {
1: Execute();
};
-
-// Performs a query with the given text. Once the proposals from the query are
-// received, the first top-ranked proposal (not necessarily first proposal
-// received) is automatically executed.
-struct QueryAction {
- UserInput input;
-};