Commit 9b4367a9 authored by Hiroki Sato's avatar Hiroki Sato Committed by Commit Bot

Add autotest private API to set ARC touch mode

This change adds an extension API to set touch mode in ARC, which will
be used in tast test.

Bug: b:147116837
Test: tast run DUT arc.Accessibility* (crrev/c/1999865)
Change-Id: I4bfdc11c5fec41e45207ceeffa0be0c985b172c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1997436
Commit-Queue: Hiroki Sato <hirokisato@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732244}
parent f7e9505f
...@@ -3921,6 +3921,28 @@ void AutotestPrivateStopTracingFunction::OnTracingComplete( ...@@ -3921,6 +3921,28 @@ void AutotestPrivateStopTracingFunction::OnTracingComplete(
base::Value value(*trace.get()); base::Value value(*trace.get());
Respond(OneArgument(base::Value::ToUniquePtrValue(std::move(value)))); Respond(OneArgument(base::Value::ToUniquePtrValue(std::move(value))));
} }
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateSetArcTouchModeFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateSetArcTouchModeFunction::
AutotestPrivateSetArcTouchModeFunction() = default;
AutotestPrivateSetArcTouchModeFunction::
~AutotestPrivateSetArcTouchModeFunction() = default;
ExtensionFunction::ResponseAction
AutotestPrivateSetArcTouchModeFunction::Run() {
std::unique_ptr<api::autotest_private::SetArcTouchMode::Params> params(
api::autotest_private::SetArcTouchMode::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
DVLOG(1) << "AutotestPrivateSetArcTouchModeFunction " << params->enabled;
if (!arc::SetTouchMode(params->enabled))
return RespondNow(Error("Could not send intent to ARC."));
return RespondNow(NoArguments());
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateAPI // AutotestPrivateAPI
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
......
...@@ -1137,6 +1137,17 @@ class AutotestPrivateStopTracingFunction : public ExtensionFunction { ...@@ -1137,6 +1137,17 @@ class AutotestPrivateStopTracingFunction : public ExtensionFunction {
void OnTracingComplete(std::unique_ptr<std::string> trace); void OnTracingComplete(std::unique_ptr<std::string> trace);
}; };
class AutotestPrivateSetArcTouchModeFunction : public ExtensionFunction {
public:
AutotestPrivateSetArcTouchModeFunction();
DECLARE_EXTENSION_FUNCTION("autotestPrivate.setArcTouchMode",
AUTOTESTPRIVATE_SETARCTOUCHMODE)
private:
~AutotestPrivateSetArcTouchModeFunction() override;
ResponseAction Run() override;
};
template <> template <>
KeyedService* KeyedService*
BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor(
......
...@@ -152,18 +152,8 @@ bool Launch(content::BrowserContext* context, ...@@ -152,18 +152,8 @@ bool Launch(content::BrowserContext* context,
return false; return false;
} }
arc::mojom::IntentHelperInstance* intent_helper_instance = if (IsMouseOrTouchEventFromFlags(event_flags))
GET_INTENT_HELPER_INSTANCE(SendBroadcast); SetTouchMode(IsMouseOrTouchEventFromFlags(event_flags));
if (intent_helper_instance && IsMouseOrTouchEventFromFlags(event_flags)) {
base::DictionaryValue extras;
extras.SetBoolean("inTouchMode", IsMouseOrTouchEventFromFlags(event_flags));
std::string extras_string;
base::JSONWriter::Write(extras, &extras_string);
intent_helper_instance->SendBroadcast(
kSetInTouchModeIntent,
ArcIntentHelperBridge::kArcIntentHelperPackageName,
kIntentHelperClassName, extras_string);
}
// Unthrottle the ARC instance before launching an ARC app. This is done // Unthrottle the ARC instance before launching an ARC app. This is done
// to minimize lag on an app launch. // to minimize lag on an app launch.
...@@ -438,6 +428,23 @@ void CloseTask(int task_id) { ...@@ -438,6 +428,23 @@ void CloseTask(int task_id) {
app_instance->CloseTask(task_id); app_instance->CloseTask(task_id);
} }
bool SetTouchMode(bool enable) {
arc::mojom::IntentHelperInstance* intent_helper_instance =
GET_INTENT_HELPER_INSTANCE(SendBroadcast);
if (!intent_helper_instance)
return false;
base::DictionaryValue extras;
extras.SetBoolean("inTouchMode", enable);
std::string extras_string;
base::JSONWriter::Write(extras, &extras_string);
intent_helper_instance->SendBroadcast(
kSetInTouchModeIntent, ArcIntentHelperBridge::kArcIntentHelperPackageName,
kIntentHelperClassName, extras_string);
return true;
}
std::vector<std::string> GetSelectedPackagesFromPrefs( std::vector<std::string> GetSelectedPackagesFromPrefs(
content::BrowserContext* context) { content::BrowserContext* context) {
std::vector<std::string> packages; std::vector<std::string> packages;
......
...@@ -148,6 +148,9 @@ void SetTaskActive(int task_id); ...@@ -148,6 +148,9 @@ void SetTaskActive(int task_id);
// Closes the task. // Closes the task.
void CloseTask(int task_id); void CloseTask(int task_id);
// Sets TouchMode in Android. Returns true if the intent was sent.
bool SetTouchMode(bool enable);
// Gets user selected package names. // Gets user selected package names.
std::vector<std::string> GetSelectedPackagesFromPrefs( std::vector<std::string> GetSelectedPackagesFromPrefs(
content::BrowserContext* context); content::BrowserContext* context);
......
...@@ -897,6 +897,10 @@ namespace autotestPrivate { ...@@ -897,6 +897,10 @@ namespace autotestPrivate {
// parameter. // parameter.
static void stopTracing(TraceCompleteCallback completeCallback); static void stopTracing(TraceCompleteCallback completeCallback);
// Sends ARC touch mode enabled or disabled.
// |enable|: whether enabled touch mode.
// |callback|: called when action performed.
static void setArcTouchMode(boolean enabled, VoidCallback callback);
}; };
interface Events { interface Events {
......
...@@ -1494,6 +1494,7 @@ enum HistogramValue { ...@@ -1494,6 +1494,7 @@ enum HistogramValue {
AUTOTESTPRIVATE_STOPTRACING = 1431, AUTOTESTPRIVATE_STOPTRACING = 1431,
LOGIN_LOCKMANAGEDGUESTSESSION = 1432, LOGIN_LOCKMANAGEDGUESTSESSION = 1432,
LOGIN_UNLOCKMANAGEDGUESTSESSION = 1433, LOGIN_UNLOCKMANAGEDGUESTSESSION = 1433,
AUTOTESTPRIVATE_SETARCTOUCHMODE = 1434,
// Last entry: Add new entries above, then run: // Last entry: Add new entries above, then run:
// python tools/metrics/histograms/update_extension_histograms.py // python tools/metrics/histograms/update_extension_histograms.py
ENUM_BOUNDARY ENUM_BOUNDARY
......
...@@ -21755,6 +21755,7 @@ to ensure that the crash string is shown properly on the user-facing crash UI. ...@@ -21755,6 +21755,7 @@ to ensure that the crash string is shown properly on the user-facing crash UI.
<int value="1431" label="AUTOTESTPRIVATE_STOPTRACING"/> <int value="1431" label="AUTOTESTPRIVATE_STOPTRACING"/>
<int value="1432" label="LOGIN_LOCKMANAGEDGUESTSESSION"/> <int value="1432" label="LOGIN_LOCKMANAGEDGUESTSESSION"/>
<int value="1433" label="LOGIN_UNLOCKMANAGEDGUESTSESSION"/> <int value="1433" label="LOGIN_UNLOCKMANAGEDGUESTSESSION"/>
<int value="1434" label="AUTOTESTPRIVATE_SETARCTOUCHMODE"/>
</enum> </enum>
<enum name="ExtensionIconState"> <enum name="ExtensionIconState">
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