Commit 9142572d authored by Mathias Carlen's avatar Mathias Carlen Committed by Commit Bot

[AA Direct Actions] Remove perform_assistant_action

Before this patch perform_assistant_action was used to trigger Autofill
Assistant layer scripts. For an external DirectAction caller it is
expected to get a flattened list of direct actions instead of this
indirection. The indirection got removed in a previous patch and the
perform_assistant_action can now be removed too.

Bug: b/138833619
Change-Id: Ib41fe034dc1cdeaae38582c7f5389ed8d1b3946a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879453
Commit-Queue: Mathias Carlen <mcarlen@chromium.org>
Reviewed-by: default avatarStephane Zermatten <szermatt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710269}
parent e449c9bb
...@@ -112,20 +112,9 @@ public class AutofillAssistantDirectActionHandlerTest { ...@@ -112,20 +112,9 @@ public class AutofillAssistantDirectActionHandlerTest {
FakeDirectActionReporter reporter = new FakeDirectActionReporter(); FakeDirectActionReporter reporter = new FakeDirectActionReporter();
reportAvailableDirectActions(mHandler, reporter); reportAvailableDirectActions(mHandler, reporter);
assertEquals(2, reporter.mActions.size()); assertEquals(1, reporter.mActions.size());
FakeDirectActionDefinition perform = reporter.mActions.get(0); FakeDirectActionDefinition fetch = reporter.mActions.get(0);
assertEquals("perform_assistant_action", perform.mId);
assertEquals(2, perform.mParameters.size());
assertEquals("name", perform.mParameters.get(0).mName);
assertEquals(Type.STRING, perform.mParameters.get(0).mType);
assertEquals("experiment_ids", perform.mParameters.get(1).mName);
assertEquals(Type.STRING, perform.mParameters.get(1).mType);
assertEquals(1, perform.mResults.size());
assertEquals("success", perform.mResults.get(0).mName);
assertEquals(Type.BOOLEAN, perform.mResults.get(0).mType);
FakeDirectActionDefinition fetch = reporter.mActions.get(1);
assertEquals("fetch_website_actions", fetch.mId); assertEquals("fetch_website_actions", fetch.mId);
assertEquals(2, fetch.mParameters.size()); assertEquals(2, fetch.mParameters.size());
assertEquals("user_name", fetch.mParameters.get(0).mName); assertEquals("user_name", fetch.mParameters.get(0).mName);
...@@ -145,12 +134,10 @@ public class AutofillAssistantDirectActionHandlerTest { ...@@ -145,12 +134,10 @@ public class AutofillAssistantDirectActionHandlerTest {
reportAvailableDirectActions(mHandler, reporter); reportAvailableDirectActions(mHandler, reporter);
// Now that the AA stack is up, the fetdch_website_actions should no longer show up. // Now that the AA stack is up, the fetdch_website_actions should no longer show up.
assertEquals(3, reporter.mActions.size()); assertEquals(2, reporter.mActions.size());
assertEquals("perform_assistant_action", reporter.mActions.get(0).mId);
// Now we expect 2 dyamic actions "search" and "action2". // Now we expect 2 dyamic actions "search" and "action2".
FakeDirectActionDefinition search = reporter.mActions.get(1); FakeDirectActionDefinition search = reporter.mActions.get(0);
assertEquals("search", search.mId); assertEquals("search", search.mId);
assertEquals(2, search.mParameters.size()); assertEquals(2, search.mParameters.size());
assertEquals("experiment_ids", search.mParameters.get(0).mName); assertEquals("experiment_ids", search.mParameters.get(0).mName);
...@@ -161,7 +148,7 @@ public class AutofillAssistantDirectActionHandlerTest { ...@@ -161,7 +148,7 @@ public class AutofillAssistantDirectActionHandlerTest {
assertEquals("success", search.mResults.get(0).mName); assertEquals("success", search.mResults.get(0).mName);
assertEquals(Type.BOOLEAN, search.mResults.get(0).mType); assertEquals(Type.BOOLEAN, search.mResults.get(0).mType);
FakeDirectActionDefinition action2 = reporter.mActions.get(2); FakeDirectActionDefinition action2 = reporter.mActions.get(1);
assertEquals("action2", action2.mId); assertEquals("action2", action2.mId);
assertEquals(1, action2.mParameters.size()); assertEquals(1, action2.mParameters.size());
assertEquals("experiment_ids", action2.mParameters.get(0).mName); assertEquals("experiment_ids", action2.mParameters.get(0).mName);
...@@ -180,20 +167,9 @@ public class AutofillAssistantDirectActionHandlerTest { ...@@ -180,20 +167,9 @@ public class AutofillAssistantDirectActionHandlerTest {
FakeDirectActionReporter reporter = new FakeDirectActionReporter(); FakeDirectActionReporter reporter = new FakeDirectActionReporter();
reportAvailableDirectActions(mHandler, reporter); reportAvailableDirectActions(mHandler, reporter);
assertEquals(2, reporter.mActions.size()); assertEquals(1, reporter.mActions.size());
FakeDirectActionDefinition perform = reporter.mActions.get(0); FakeDirectActionDefinition fetch = reporter.mActions.get(0);
assertEquals("perform_assistant_action", perform.mId);
assertEquals(2, perform.mParameters.size());
assertEquals("name", perform.mParameters.get(0).mName);
assertEquals(Type.STRING, perform.mParameters.get(0).mType);
assertEquals("experiment_ids", perform.mParameters.get(1).mName);
assertEquals(Type.STRING, perform.mParameters.get(1).mType);
assertEquals(1, perform.mResults.size());
assertEquals("success", perform.mResults.get(0).mName);
assertEquals(Type.BOOLEAN, perform.mResults.get(0).mType);
FakeDirectActionDefinition fetch = reporter.mActions.get(1);
assertEquals("fetch_website_actions", fetch.mId); assertEquals("fetch_website_actions", fetch.mId);
assertEquals(2, fetch.mParameters.size()); assertEquals(2, fetch.mParameters.size());
assertEquals("user_name", fetch.mParameters.get(0).mName); assertEquals("user_name", fetch.mParameters.get(0).mName);
...@@ -296,23 +272,22 @@ public class AutofillAssistantDirectActionHandlerTest { ...@@ -296,23 +272,22 @@ public class AutofillAssistantDirectActionHandlerTest {
})); }));
} }
/** Calls perform_assistant_action and returns the result. */ /** Performs direct action |name| and returns the result. */
private Boolean performAction(String name, Bundle arguments) throws Exception { private Boolean performAction(String name, Bundle arguments) throws Exception {
return performActionAsync(name, arguments).waitForResult("perform_assistant_action"); return performActionAsync(name, arguments).waitForResult("success");
} }
/** /**
* Calls perform_assistant_action and returns a {@link WaitingCallback} that'll eventually * Performs direct action |name| and returns a {@link WaitingCallback} that'll eventually
* contain the result. * contain the result.
*/ */
private WaitingCallback<Boolean> performActionAsync(String name, Bundle arguments) private WaitingCallback<Boolean> performActionAsync(String name, Bundle arguments)
throws Exception { throws Exception {
WaitingCallback<Boolean> callback = new WaitingCallback<Boolean>(); WaitingCallback<Boolean> callback = new WaitingCallback<Boolean>();
Bundle allArguments = new Bundle(arguments); Bundle allArguments = new Bundle(arguments);
if (!name.isEmpty()) allArguments.putString("name", name);
TestThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() ()
-> mHandler.performDirectAction("perform_assistant_action", allArguments, -> mHandler.performDirectAction(name, allArguments,
(bundle) -> callback.onResult(bundle.getBoolean("success")))); (bundle) -> callback.onResult(bundle.getBoolean("success"))));
return callback; return callback;
} }
......
...@@ -28,8 +28,6 @@ import java.util.Arrays; ...@@ -28,8 +28,6 @@ import java.util.Arrays;
public class AutofillAssistantDirectActionHandler implements DirectActionHandler { public class AutofillAssistantDirectActionHandler implements DirectActionHandler {
private static final String FETCH_WEBSITE_ACTIONS = "fetch_website_actions"; private static final String FETCH_WEBSITE_ACTIONS = "fetch_website_actions";
private static final String FETCH_WEBSITE_ACTIONS_RESULT = "success"; private static final String FETCH_WEBSITE_ACTIONS_RESULT = "success";
// TODO(b/138833619): Remove this action entirely.
private static final String PERFORM_AA_ACTION = "perform_assistant_action";
private static final String AA_ACTION_RESULT = "success"; private static final String AA_ACTION_RESULT = "success";
private static final String ACTION_NAME = "name"; private static final String ACTION_NAME = "name";
private static final String EXPERIMENT_IDS = "experiment_ids"; private static final String EXPERIMENT_IDS = "experiment_ids";
...@@ -69,11 +67,6 @@ public class AutofillAssistantDirectActionHandler implements DirectActionHandler ...@@ -69,11 +67,6 @@ public class AutofillAssistantDirectActionHandler implements DirectActionHandler
return; return;
} }
reporter.addDirectAction(PERFORM_AA_ACTION)
.withParameter(ACTION_NAME, Type.STRING, /* required= */ false)
.withParameter(EXPERIMENT_IDS, Type.STRING, /* required= */ false)
.withResult(AA_ACTION_RESULT, Type.BOOLEAN);
ThreadUtils.assertOnUiThread(); ThreadUtils.assertOnUiThread();
if (mDelegate == null || (mDelegate != null && !mDelegate.hasRunFirstCheck())) { if (mDelegate == null || (mDelegate != null && !mDelegate.hasRunFirstCheck())) {
reporter.addDirectAction(FETCH_WEBSITE_ACTIONS) reporter.addDirectAction(FETCH_WEBSITE_ACTIONS)
...@@ -106,10 +99,6 @@ public class AutofillAssistantDirectActionHandler implements DirectActionHandler ...@@ -106,10 +99,6 @@ public class AutofillAssistantDirectActionHandler implements DirectActionHandler
fetchWebsiteActions(arguments, callback); fetchWebsiteActions(arguments, callback);
return true; return true;
} }
if (actionId.equals(PERFORM_AA_ACTION)) {
performAction(arguments, callback);
return true;
}
// Only handle and perform the action if it is known to the controller. // Only handle and perform the action if it is known to the controller.
if (isActionAvailable(actionId) || ONBOARDING_ACTION.equals(actionId)) { if (isActionAvailable(actionId) || ONBOARDING_ACTION.equals(actionId)) {
arguments.putString("name", actionId); arguments.putString("name", actionId);
......
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