-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CrOS Bluetooth] Add HidConnected metric to legacy HID screen.
Create hid_detection_utils.h that will contain HID detection screen metrics-related logic. Emit HidConnected metric for each HID connected while the HID detection screen is shown in the pre-revamp HID detection screen. Bug: b/229012996 Test: HIDDetectionScreen*Test Change-Id: Ifbed7530d2a23f404d685347e35845bf0cff601b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3632655 Reviewed-by: Chad Duffin <chadduffin@chromium.org> Reviewed-by: Roman Sorokin <rsorokin@chromium.org> Reviewed-by: Reilly Grant <reillyg@chromium.org> Commit-Queue: Gordon Seto <gordonseto@google.com> Cr-Commit-Position: refs/heads/main@{#1002262}
- Loading branch information
Gordon Seto
authored and
Chromium LUCI CQ
committed
May 11, 2022
1 parent
3fca29e
commit 4371d75
Showing
10 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
include_rules = [ | ||
"+chromeos/services/bluetooth_config", | ||
"+components/device_event_log", | ||
"+services/device/public", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2022 The Chromium 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 "ash/components/hid_detection/hid_detection_utils.h" | ||
|
||
#include "base/metrics/histogram_functions.h" | ||
#include "components/device_event_log/device_event_log.h" | ||
#include "third_party/abseil-cpp/absl/types/optional.h" | ||
|
||
namespace ash::hid_detection { | ||
namespace { | ||
|
||
using InputDeviceType = device::mojom::InputDeviceType; | ||
|
||
absl::optional<HidType> GetHidType( | ||
const device::mojom::InputDeviceInfo& device) { | ||
if (device.is_touchscreen || device.is_tablet) | ||
return HidType::kTouchscreen; | ||
|
||
if (device.is_mouse || device.is_touchpad) { | ||
switch (device.type) { | ||
case InputDeviceType::TYPE_BLUETOOTH: | ||
return HidType::kBluetoothPointer; | ||
case InputDeviceType::TYPE_USB: | ||
return HidType::kUsbPointer; | ||
case InputDeviceType::TYPE_SERIO: | ||
return HidType::kSerialPointer; | ||
case InputDeviceType::TYPE_UNKNOWN: | ||
return HidType::kUnknownPointer; | ||
} | ||
} | ||
|
||
if (device.is_keyboard) { | ||
switch (device.type) { | ||
case InputDeviceType::TYPE_BLUETOOTH: | ||
return HidType::kBluetoothKeyboard; | ||
case InputDeviceType::TYPE_USB: | ||
return HidType::kUsbKeyboard; | ||
case InputDeviceType::TYPE_SERIO: | ||
return HidType::kSerialKeyboard; | ||
case InputDeviceType::TYPE_UNKNOWN: | ||
return HidType::kUnknownKeyboard; | ||
} | ||
} | ||
|
||
return absl::nullopt; | ||
} | ||
|
||
} // namespace | ||
|
||
void RecordHidConnected(const device::mojom::InputDeviceInfo& device) { | ||
absl::optional<HidType> hid_type = GetHidType(device); | ||
|
||
// If |device| is not relevant (i.e. an accelerometer, joystick, etc), don't | ||
// emit metric. | ||
if (!hid_type.has_value()) { | ||
HID_LOG(DEBUG) << "HidConnected not logged for device " << device.id | ||
<< " because it doesn't have a relevant device type."; | ||
return; | ||
} | ||
|
||
base::UmaHistogramEnumeration("OOBE.HidDetectionScreen.HidConnected", | ||
hid_type.value()); | ||
} | ||
|
||
} // namespace ash::hid_detection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2022 The Chromium 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 ASH_COMPONENTS_HID_DETECTION_HID_DETECTION_UTILS_H_ | ||
#define ASH_COMPONENTS_HID_DETECTION_HID_DETECTION_UTILS_H_ | ||
|
||
#include "services/device/public/mojom/input_service.mojom.h" | ||
|
||
namespace ash::hid_detection { | ||
|
||
// This enum is tied directly to the HidType UMA enum defined in | ||
// //tools/metrics/histograms/enums.xml, and should always reflect it (do not | ||
// change one without changing the other). | ||
enum class HidType { | ||
kTouchscreen = 0, | ||
kUsbKeyboard = 1, | ||
kUsbPointer = 2, | ||
kSerialKeyboard = 3, | ||
kSerialPointer = 4, | ||
kBluetoothKeyboard = 5, | ||
kBluetoothPointer = 6, | ||
kUnknownKeyboard = 7, | ||
kUnknownPointer = 8, | ||
kMaxValue = kUnknownPointer | ||
}; | ||
|
||
// Record each HID that is connected while the HID detection screen is shown. | ||
void RecordHidConnected(const device::mojom::InputDeviceInfo& device); | ||
|
||
} // namespace ash::hid_detection | ||
|
||
#endif // ASH_COMPONENTS_HID_DETECTION_HID_DETECTION_UTILS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters