Commit acce16fc authored by Rachel Wong's avatar Rachel Wong Committed by Commit Bot

Implement logging of features for bluetooth connections.

The code that calls the bluetooth logging function is in
https://chromium-review.googlesource.com/c/chromium/src/+/1999973.

Bug: 1014839
Change-Id: Ica03b6509df95b389559cb01a8f9dea4dcf15e82
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2011469Reviewed-by: default avatarTony Yeoman <tby@chromium.org>
Commit-Queue: Rachel Wong <wrong@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733885}
parent bbbb72b3
...@@ -102,9 +102,9 @@ message UserSettingsEvent { ...@@ -102,9 +102,9 @@ message UserSettingsEvent {
// Whether the user has connected to a cellular network in the current // Whether the user has connected to a cellular network in the current
// session. // session.
optional bool used_cellular_in_session = 17; optional bool used_cellular_in_session = 17;
// Whether there are previously paired bluetooth devices available for // Whether or not the current bluetooth device was already paired. Only
// connection. // populated upon connection to a bluetooth device.
optional bool has_available_bluetooth_devices = 18; optional bool is_paired_bluetooth_device = 18;
// Whether the user has set up a night light schedule. // Whether the user has set up a night light schedule.
optional bool has_night_light_schedule = 19; optional bool has_night_light_schedule = 19;
// True if it is after sunset and before sunrise in the local time. // True if it is after sunset and before sunrise in the local time.
......
...@@ -62,11 +62,29 @@ void UserSettingsEventLogger::LogNetworkUkmEvent( ...@@ -62,11 +62,29 @@ void UserSettingsEventLogger::LogNetworkUkmEvent(
// We are not interested in other types of networks. // We are not interested in other types of networks.
return; return;
} }
event->set_setting_type(UserSettingsEvent::Event::QUICK_SETTINGS);
PopulateSharedFeatures(&settings_event);
SendToUkm(settings_event);
}
void UserSettingsEventLogger::LogBluetoothUkmEvent(
const BluetoothAddress& device_address) {
UserSettingsEvent settings_event;
auto* const event = settings_event.mutable_event();
event->set_setting_id(UserSettingsEvent::Event::BLUETOOTH);
event->set_setting_type(UserSettingsEvent::Event::QUICK_SETTINGS); event->set_setting_type(UserSettingsEvent::Event::QUICK_SETTINGS);
// Convert the setting state to an int. Some settings have multiple states, so
// all setting states are stored as ints. const auto& devices =
event->set_current_value(1); Shell::Get()->tray_bluetooth_helper()->GetAvailableBluetoothDevices();
for (const auto& device : devices) {
if (device->address == device_address) {
settings_event.mutable_features()->set_is_paired_bluetooth_device(
device->is_paired);
break;
}
}
PopulateSharedFeatures(&settings_event); PopulateSharedFeatures(&settings_event);
SendToUkm(settings_event); SendToUkm(settings_event);
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef ASH_SYSTEM_MACHINE_LEARNING_USER_SETTINGS_EVENT_LOGGER_H_ #ifndef ASH_SYSTEM_MACHINE_LEARNING_USER_SETTINGS_EVENT_LOGGER_H_
#define ASH_SYSTEM_MACHINE_LEARNING_USER_SETTINGS_EVENT_LOGGER_H_ #define ASH_SYSTEM_MACHINE_LEARNING_USER_SETTINGS_EVENT_LOGGER_H_
#include "ash/system/bluetooth/tray_bluetooth_helper.h"
#include "ash/system/machine_learning/user_settings_event.pb.h" #include "ash/system/machine_learning/user_settings_event.pb.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom-forward.h" #include "chromeos/services/network_config/public/mojom/cros_network_config.mojom-forward.h"
...@@ -27,6 +28,9 @@ class UserSettingsEventLogger { ...@@ -27,6 +28,9 @@ class UserSettingsEventLogger {
// Logs an event to UKM that the user has connected to the given network. // Logs an event to UKM that the user has connected to the given network.
void LogNetworkUkmEvent( void LogNetworkUkmEvent(
const chromeos::network_config::mojom::NetworkStateProperties& network); const chromeos::network_config::mojom::NetworkStateProperties& network);
// Logs an event to UKM that the user has connected to the given bluetooth
// device.
void LogBluetoothUkmEvent(const BluetoothAddress& device_address);
private: private:
UserSettingsEventLogger(); UserSettingsEventLogger();
......
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