Commit f06ccfc9 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

arc: gamepad: Record gamepad interaction

This CL adds a new histogram enum GAMEPAD_INTERACTION to
Arc.UserInteraction, which will be recorded on the first time a user
sends a gamepad event to an ARC++ app window. It resets every time the
window is deactivated.

This will be used as success metrics of ARC Improved Gamepad project
go/arc-improved-gamepad.

TEST=manual(Press gamepad buttons when an ARC++ app is active and check
chrome://histograms)
BUG=b:130597086

Change-Id: I90c4d00399a7227a102ebd9e81861b735bef6001
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1605667
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarKevin Schoedel <kpschoedel@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Reviewed-by: default avatarMaajid <maajid@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659665}
parent 77b4785e
......@@ -123,6 +123,7 @@ static_library("arc") {
"//ui/display/manager",
"//ui/events",
"//ui/events:dom_keycode_converter",
"//ui/events/ozone:events_ozone_evdev",
"//url:url",
]
}
......
include_rules = [
"+ui/aura",
"+ui/events/ozone/gamepad",
"+ui/wm/public",
]
......@@ -89,7 +89,10 @@ enum class UserInteractionType {
// User started an app from the Kiosk Next Home app.
APP_STARTED_FROM_KIOSK_NEXT_HOME = 18,
kMaxValue = APP_STARTED_FROM_KIOSK_NEXT_HOME,
// User interacted with an app using a gamepad.
GAMEPAD_INTERACTION = 19,
kMaxValue = GAMEPAD_INTERACTION,
};
} // namespace arc
......
......@@ -29,6 +29,7 @@
#include "components/session_manager/core/session_manager.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_context.h"
#include "ui/events/ozone/gamepad/gamepad_provider_ozone.h"
namespace arc {
......@@ -151,6 +152,7 @@ ArcMetricsService::ArcMetricsService(content::BrowserContext* context,
arc_window_delegate_->RegisterActivationChangeObserver();
session_manager::SessionManager::Get()->AddObserver(this);
chromeos::PowerManagerClient::Get()->AddObserver(this);
ui::GamepadProviderOzone::GetInstance()->AddGamepadObserver(this);
DCHECK(pref_service_);
RestoreEngagementTimeFromPrefs();
......@@ -172,6 +174,7 @@ ArcMetricsService::~ArcMetricsService() {
UpdateEngagementTime();
SaveEngagementTimeToPrefs();
ui::GamepadProviderOzone::GetInstance()->RemoveGamepadObserver(this);
chromeos::PowerManagerClient::Get()->RemoveObserver(this);
session_manager::SessionManager::Get()->RemoveObserver(this);
arc_window_delegate_->UnregisterActivationChangeObserver();
......@@ -325,8 +328,10 @@ void ArcMetricsService::OnWindowActivated(
aura::Window* lost_active) {
UpdateEngagementTime();
was_arc_window_active_ = arc_window_delegate_->IsArcAppWindow(gained_active);
if (!was_arc_window_active_)
if (!was_arc_window_active_) {
gamepad_interaction_recorded_ = false;
return;
}
UMA_HISTOGRAM_ENUMERATION(
"Arc.UserInteraction",
UserInteractionType::APP_CONTENT_WINDOW_INTERACTION);
......@@ -345,6 +350,16 @@ void ArcMetricsService::ScreenIdleStateChanged(
was_screen_dimmed_ = proto.dimmed();
}
void ArcMetricsService::OnGamepadEvent(const ui::GamepadEvent& event) {
if (!was_arc_window_active_)
return;
if (gamepad_interaction_recorded_)
return;
gamepad_interaction_recorded_ = true;
UMA_HISTOGRAM_ENUMERATION("Arc.UserInteraction",
UserInteractionType::GAMEPAD_INTERACTION);
}
void ArcMetricsService::OnTaskCreated(int32_t task_id,
const std::string& package_name,
const std::string& activity,
......
......@@ -21,6 +21,7 @@
#include "components/arc/session/connection_observer.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/session_manager/core/session_manager_observer.h"
#include "ui/events/ozone/gamepad/gamepad_observer.h"
#include "ui/wm/public/activation_change_observer.h"
class BrowserContextKeyedServiceFactory;
......@@ -48,7 +49,8 @@ class ArcMetricsService : public KeyedService,
public wm::ActivationChangeObserver,
public session_manager::SessionManagerObserver,
public chromeos::PowerManagerClient::Observer,
public mojom::MetricsHost {
public mojom::MetricsHost,
public ui::GamepadObserver {
public:
// Delegate for handling window focus observation that is used to track ARC
// app usage metrics.
......@@ -107,6 +109,9 @@ class ArcMetricsService : public KeyedService,
void ScreenIdleStateChanged(
const power_manager::ScreenIdleState& proto) override;
// ui::GamepadObserver overrides.
void OnGamepadEvent(const ui::GamepadEvent& event) override;
// ArcAppListPrefs::Observer callbacks which are called through
// ArcMetricsServiceProxy.
void OnTaskCreated(int32_t task_id,
......@@ -192,6 +197,8 @@ class ArcMetricsService : public KeyedService,
base::TimeDelta engagement_time_foreground_;
base::TimeDelta engagement_time_background_;
bool gamepad_interaction_recorded_ = false;
// Always keep this the last member of this class to make sure it's the
// first thing to be destructed.
base::WeakPtrFactory<ArcMetricsService> weak_ptr_factory_;
......
......@@ -2511,6 +2511,7 @@ Unknown properties are collapsed to zero. -->
<int value="16" label="App started from link context menu"/>
<int value="17" label="App started from Smart Text Selection context menu"/>
<int value="18" label="App started from Kiosk Next Home"/>
<int value="19" label="Interaction with gamepad"/>
</enum>
<enum name="ArcVideoDecodeAcceleratorResult">
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