audio: Add audio selection performance metrics under one histogram name
This metric will be fired whenever an audio selection event happens. Created an enum AudioSelectionEvents including 24 different audio selection events. Bug: b/328425880 Test: AudioDeviceSelectionTest, CrasAudioHandlerTest Change-Id: I71cc15a21578f11839d199b9d2e9c2e0b87b9d85 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5425930 Commit-Queue: Wenyu Zhang <zhangwenyu@google.com> Reviewed-by: Camden Bickel <cambickel@google.com> Cr-Commit-Position: refs/heads/main@{#1284135}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
6e23de78b4
commit
79e17af468
chromeos/ash/components/audio
tools/metrics/histograms/metadata/cros_audio
@ -10,6 +10,14 @@
|
||||
|
||||
namespace ash {
|
||||
|
||||
namespace {
|
||||
|
||||
// The time threshold whether user override system decision metrics would be
|
||||
// fired or not. This is the time delta since the system decision was triggered.
|
||||
constexpr int kUserOverrideSystemDecisionTimeThresholdInMinutes = 60;
|
||||
|
||||
} // namespace
|
||||
|
||||
AudioDeviceMetricsHandler::AudioDeviceMetricsHandler() = default;
|
||||
AudioDeviceMetricsHandler::~AudioDeviceMetricsHandler() = default;
|
||||
|
||||
@ -32,6 +40,10 @@ void AudioDeviceMetricsHandler::MaybeRecordSystemSwitchDecisionAndContext(
|
||||
}
|
||||
|
||||
base::UmaHistogramBoolean(kSystemSwitchInputAudio, is_switched);
|
||||
base::UmaHistogramEnumeration(
|
||||
kAudioSelectionPerformance,
|
||||
is_switched ? AudioSelectionEvents::kSystemSwitchInput
|
||||
: AudioSelectionEvents::kSystemNotSwitchInput);
|
||||
|
||||
AudioDeviceList input_devices =
|
||||
CrasAudioHandler::GetSimpleUsageAudioDevices(audio_devices_,
|
||||
@ -79,6 +91,10 @@ void AudioDeviceMetricsHandler::MaybeRecordSystemSwitchDecisionAndContext(
|
||||
}
|
||||
|
||||
base::UmaHistogramBoolean(kSystemSwitchOutputAudio, is_switched);
|
||||
base::UmaHistogramEnumeration(
|
||||
kAudioSelectionPerformance,
|
||||
is_switched ? AudioSelectionEvents::kSystemSwitchOutput
|
||||
: AudioSelectionEvents::kSystemNotSwitchOutput);
|
||||
|
||||
AudioDeviceList output_devices =
|
||||
CrasAudioHandler::GetSimpleUsageAudioDevices(audio_devices_,
|
||||
@ -167,16 +183,20 @@ void AudioDeviceMetricsHandler::MaybeRecordUserOverrideSystemDecision(
|
||||
const std::string& histogram_name_switched =
|
||||
is_input ? kUserOverrideSystemSwitchInputAudio
|
||||
: kUserOverrideSystemSwitchOutputAudio;
|
||||
int time_delta =
|
||||
int time_delta_since_system_decision =
|
||||
(base::TimeTicks::Now() - switched_by_system_at.value()).InMinutes();
|
||||
RecordUserOverrideMetrics(histogram_name_switched, time_delta);
|
||||
AudioSelectionEvents audio_selection_event =
|
||||
is_input ? AudioSelectionEvents::kUserOverrideSystemSwitchInput
|
||||
: AudioSelectionEvents::kUserOverrideSystemSwitchOutput;
|
||||
RecordUserOverrideMetrics(histogram_name_switched, audio_selection_event,
|
||||
time_delta_since_system_decision);
|
||||
|
||||
// Record user override metrics separated by chrome restarts.
|
||||
|
||||
RecordUserOverrideMetricsSeparatedByChromeRestarts(
|
||||
is_input, /*is_switched=*/true,
|
||||
/*is_chrome_restarts=*/is_system_decision_at_chrome_restarts,
|
||||
time_delta);
|
||||
time_delta_since_system_decision);
|
||||
|
||||
// Reset the system_switch timestamp since user has activated an audio
|
||||
// device now. User activating again is not considered overriding system
|
||||
@ -189,17 +209,22 @@ void AudioDeviceMetricsHandler::MaybeRecordUserOverrideSystemDecision(
|
||||
const std::string& histogram_name_not_switched =
|
||||
is_input ? kUserOverrideSystemNotSwitchInputAudio
|
||||
: kUserOverrideSystemNotSwitchOutputAudio;
|
||||
int time_delta =
|
||||
int time_delta_since_system_decision =
|
||||
(base::TimeTicks::Now() - not_switched_by_system_at.value())
|
||||
.InMinutes();
|
||||
RecordUserOverrideMetrics(histogram_name_not_switched, time_delta);
|
||||
AudioSelectionEvents audio_selection_event =
|
||||
is_input ? AudioSelectionEvents::kUserOverrideSystemNotSwitchInput
|
||||
: AudioSelectionEvents::kUserOverrideSystemNotSwitchOutput;
|
||||
RecordUserOverrideMetrics(histogram_name_not_switched,
|
||||
audio_selection_event,
|
||||
time_delta_since_system_decision);
|
||||
|
||||
// Record user override metrics separated by chrome restarts.
|
||||
|
||||
RecordUserOverrideMetricsSeparatedByChromeRestarts(
|
||||
is_input, /*is_switched=*/false,
|
||||
/*is_chrome_restarts=*/is_system_decision_at_chrome_restarts,
|
||||
time_delta);
|
||||
time_delta_since_system_decision);
|
||||
|
||||
// Reset the system_not_switch timestamp since user has activated an audio
|
||||
// device now.
|
||||
@ -218,6 +243,7 @@ void AudioDeviceMetricsHandler::
|
||||
std::string device_count_histogram_name;
|
||||
std::string device_set_histogram_name;
|
||||
std::string before_and_after_device_set_histogram_name;
|
||||
AudioSelectionEvents audio_selection_event;
|
||||
|
||||
if (is_chrome_restarts) {
|
||||
system_switch_histogram_name = is_input
|
||||
@ -225,6 +251,10 @@ void AudioDeviceMetricsHandler::
|
||||
: kSystemSwitchOutputAudioChromeRestarts;
|
||||
|
||||
if (is_switched) {
|
||||
audio_selection_event =
|
||||
is_input ? AudioSelectionEvents::kSystemSwitchInputChromeRestart
|
||||
: AudioSelectionEvents::kSystemSwitchOutputChromeRestart;
|
||||
|
||||
device_count_histogram_name =
|
||||
is_input ? kSystemSwitchInputAudioDeviceCountChromeRestarts
|
||||
: kSystemSwitchOutputAudioDeviceCountChromeRestarts;
|
||||
@ -236,6 +266,9 @@ void AudioDeviceMetricsHandler::
|
||||
? kSystemSwitchInputBeforeAndAfterAudioDeviceSetChromeRestarts
|
||||
: kSystemSwitchOutputBeforeAndAfterAudioDeviceSetChromeRestarts;
|
||||
} else {
|
||||
audio_selection_event =
|
||||
is_input ? AudioSelectionEvents::kSystemNotSwitchInputChromeRestart
|
||||
: AudioSelectionEvents::kSystemNotSwitchOutputChromeRestart;
|
||||
device_count_histogram_name =
|
||||
is_input ? kSystemNotSwitchInputAudioDeviceCountChromeRestarts
|
||||
: kSystemNotSwitchOutputAudioDeviceCountChromeRestarts;
|
||||
@ -253,6 +286,9 @@ void AudioDeviceMetricsHandler::
|
||||
: kSystemSwitchOutputAudioNonChromeRestarts;
|
||||
|
||||
if (is_switched) {
|
||||
audio_selection_event =
|
||||
is_input ? AudioSelectionEvents::kSystemSwitchInputNonChromeRestart
|
||||
: AudioSelectionEvents::kSystemSwitchOutputNonChromeRestart;
|
||||
device_count_histogram_name =
|
||||
is_input ? kSystemSwitchInputAudioDeviceCountNonChromeRestarts
|
||||
: kSystemSwitchOutputAudioDeviceCountNonChromeRestarts;
|
||||
@ -264,6 +300,10 @@ void AudioDeviceMetricsHandler::
|
||||
? kSystemSwitchInputBeforeAndAfterAudioDeviceSetNonChromeRestarts
|
||||
: kSystemSwitchOutputBeforeAndAfterAudioDeviceSetNonChromeRestarts;
|
||||
} else {
|
||||
audio_selection_event =
|
||||
is_input
|
||||
? AudioSelectionEvents::kSystemNotSwitchInputNonChromeRestart
|
||||
: AudioSelectionEvents::kSystemNotSwitchOutputNonChromeRestart;
|
||||
device_count_histogram_name =
|
||||
is_input ? kSystemNotSwitchInputAudioDeviceCountNonChromeRestarts
|
||||
: kSystemNotSwitchOutputAudioDeviceCountNonChromeRestarts;
|
||||
@ -280,6 +320,9 @@ void AudioDeviceMetricsHandler::
|
||||
// Record the system switch decision.
|
||||
base::UmaHistogramBoolean(system_switch_histogram_name, is_switched);
|
||||
|
||||
base::UmaHistogramEnumeration(kAudioSelectionPerformance,
|
||||
audio_selection_event);
|
||||
|
||||
// Record the number of audio devices.
|
||||
base::UmaHistogramExactLinear(device_count_histogram_name,
|
||||
current_device_list.size(),
|
||||
@ -297,43 +340,80 @@ void AudioDeviceMetricsHandler::
|
||||
|
||||
void AudioDeviceMetricsHandler::RecordUserOverrideMetrics(
|
||||
const std::string_view histogram_name,
|
||||
int time_delta) const {
|
||||
AudioSelectionEvents audio_selection_event,
|
||||
int time_delta_since_system_decision) const {
|
||||
base::UmaHistogramCustomCounts(
|
||||
histogram_name.data(), time_delta,
|
||||
histogram_name.data(), time_delta_since_system_decision,
|
||||
kMinTimeInMinuteOfUserOverrideSystemDecision,
|
||||
base::Hours(kMaxTimeInHourOfUserOverrideSystemDecision).InMinutes(),
|
||||
kUserOverrideSystemDecisionTimeDeltaBucketCount);
|
||||
|
||||
// The user override system decision metrics are only recorded within a time
|
||||
// threshold of system making the decision. This is because the metrics aim to
|
||||
// measure how well the system makes the decision. The shorter the user
|
||||
// overrides the system decision, the more likely that the system didn't make
|
||||
// a good decision. Current threshold is a reasonable value picked based on
|
||||
// the existing metrics (UserOverrideSystemSwitchTimeElapsed).
|
||||
if (time_delta_since_system_decision <=
|
||||
kUserOverrideSystemDecisionTimeThresholdInMinutes) {
|
||||
base::UmaHistogramEnumeration(kAudioSelectionPerformance,
|
||||
audio_selection_event);
|
||||
}
|
||||
}
|
||||
|
||||
void AudioDeviceMetricsHandler::
|
||||
RecordUserOverrideMetricsSeparatedByChromeRestarts(bool is_input,
|
||||
bool is_switched,
|
||||
bool is_chrome_restarts,
|
||||
int time_delta) const {
|
||||
RecordUserOverrideMetricsSeparatedByChromeRestarts(
|
||||
bool is_input,
|
||||
bool is_switched,
|
||||
bool is_chrome_restarts,
|
||||
int time_delta_since_system_decision) const {
|
||||
std::string user_override_histogram_name;
|
||||
AudioSelectionEvents audio_selection_event;
|
||||
if (is_chrome_restarts) {
|
||||
if (is_switched) {
|
||||
user_override_histogram_name =
|
||||
is_input ? kUserOverrideSystemSwitchInputAudioChromeRestarts
|
||||
: kUserOverrideSystemSwitchOutputAudioChromeRestarts;
|
||||
audio_selection_event =
|
||||
is_input ? AudioSelectionEvents::
|
||||
kUserOverrideSystemSwitchInputChromeRestart
|
||||
: AudioSelectionEvents::
|
||||
kUserOverrideSystemSwitchOutputChromeRestart;
|
||||
} else {
|
||||
user_override_histogram_name =
|
||||
is_input ? kUserOverrideSystemNotSwitchInputAudioChromeRestarts
|
||||
: kUserOverrideSystemNotSwitchOutputAudioChromeRestarts;
|
||||
|
||||
audio_selection_event =
|
||||
is_input ? AudioSelectionEvents::
|
||||
kUserOverrideSystemNotSwitchInputChromeRestart
|
||||
: AudioSelectionEvents::
|
||||
kUserOverrideSystemNotSwitchOutputChromeRestart;
|
||||
}
|
||||
} else {
|
||||
if (is_switched) {
|
||||
user_override_histogram_name =
|
||||
is_input ? kUserOverrideSystemSwitchInputAudioNonChromeRestarts
|
||||
: kUserOverrideSystemSwitchOutputAudioNonChromeRestarts;
|
||||
audio_selection_event =
|
||||
is_input ? AudioSelectionEvents::
|
||||
kUserOverrideSystemSwitchInputNonChromeRestart
|
||||
: AudioSelectionEvents::
|
||||
kUserOverrideSystemSwitchOutputNonChromeRestart;
|
||||
} else {
|
||||
user_override_histogram_name =
|
||||
is_input ? kUserOverrideSystemNotSwitchInputAudioNonChromeRestarts
|
||||
: kUserOverrideSystemNotSwitchOutputAudioNonChromeRestarts;
|
||||
audio_selection_event =
|
||||
is_input ? AudioSelectionEvents::
|
||||
kUserOverrideSystemNotSwitchInputNonChromeRestart
|
||||
: AudioSelectionEvents::
|
||||
kUserOverrideSystemNotSwitchOutputNonChromeRestart;
|
||||
}
|
||||
}
|
||||
|
||||
RecordUserOverrideMetrics(user_override_histogram_name, time_delta);
|
||||
RecordUserOverrideMetrics(user_override_histogram_name, audio_selection_event,
|
||||
time_delta_since_system_decision);
|
||||
}
|
||||
|
||||
void AudioDeviceMetricsHandler::RecordConsecutiveAudioDevicsChangeTimeElapsed(
|
||||
@ -343,10 +423,11 @@ void AudioDeviceMetricsHandler::RecordConsecutiveAudioDevicsChangeTimeElapsed(
|
||||
std::optional<base::TimeTicks>& devices_changed_at =
|
||||
is_input ? input_devices_changed_at_ : output_devices_changed_at_;
|
||||
if (devices_changed_at.has_value()) {
|
||||
int time_delta = (now - devices_changed_at.value()).InSeconds();
|
||||
int time_delta_since_system_decision =
|
||||
(now - devices_changed_at.value()).InSeconds();
|
||||
base::UmaHistogramSparse(is_input ? kConsecutiveInputDevicsChanged
|
||||
: kConsecutiveOutputDevicsChanged,
|
||||
time_delta);
|
||||
time_delta_since_system_decision);
|
||||
}
|
||||
devices_changed_at = now;
|
||||
|
||||
@ -354,10 +435,11 @@ void AudioDeviceMetricsHandler::RecordConsecutiveAudioDevicsChangeTimeElapsed(
|
||||
std::optional<base::TimeTicks>& devices_added_at =
|
||||
is_input ? input_devices_added_at_ : output_devices_added_at_;
|
||||
if (devices_added_at.has_value()) {
|
||||
int time_delta = (now - devices_added_at.value()).InSeconds();
|
||||
int time_delta_since_system_decision =
|
||||
(now - devices_added_at.value()).InSeconds();
|
||||
base::UmaHistogramSparse(is_input ? kConsecutiveInputDevicsAdded
|
||||
: kConsecutiveOutputDevicsAdded,
|
||||
time_delta);
|
||||
time_delta_since_system_decision);
|
||||
}
|
||||
devices_added_at = now;
|
||||
}
|
||||
|
@ -36,6 +36,11 @@ class COMPONENT_EXPORT(CHROMEOS_ASH_COMPONENTS_AUDIO)
|
||||
// histogram metrics.
|
||||
static constexpr uint32_t kMaxAudioDevicesCount = 10;
|
||||
|
||||
// An enum histogram metric to measure the performance of audio selection
|
||||
// mechanism.
|
||||
static constexpr char kAudioSelectionPerformance[] =
|
||||
"ChromeOS.AudioSelection";
|
||||
|
||||
// A series of user action metrics to record when user switches the
|
||||
// input/output audio device and if this switch overrides the system decision.
|
||||
static constexpr char kUserActionSwitchInput[] =
|
||||
@ -250,6 +255,73 @@ class COMPONENT_EXPORT(CHROMEOS_ASH_COMPONENTS_AUDIO)
|
||||
static constexpr char kConsecutiveOutputDevicsAdded[] =
|
||||
"ChromeOS.AudioSelection.Output.ConsecutiveDevicesChangeTimeElapsed.Add";
|
||||
|
||||
// A series of audio selection events used to record the audio selection
|
||||
// performance. Note that these values are persisted to histograms so existing
|
||||
// values should remain unchanged and new values should be added to the end.
|
||||
enum class AudioSelectionEvents {
|
||||
// The system switched the input device.
|
||||
kSystemSwitchInput = 0,
|
||||
// The system switched the output device.
|
||||
kSystemSwitchOutput = 1,
|
||||
// The system did not switch the input device.
|
||||
kSystemNotSwitchInput = 2,
|
||||
// The system did not switch the output device.
|
||||
kSystemNotSwitchOutput = 3,
|
||||
// User overrode the system decision to switch input device.
|
||||
kUserOverrideSystemSwitchInput = 4,
|
||||
// User overrode the system decision to switch output device.
|
||||
kUserOverrideSystemSwitchOutput = 5,
|
||||
// User overrode the system decision to not switch input device.
|
||||
kUserOverrideSystemNotSwitchInput = 6,
|
||||
// User overrode the system decision to not switch output device.
|
||||
kUserOverrideSystemNotSwitchOutput = 7,
|
||||
// The system switched the input device (for the first time after the system
|
||||
// booted or chrome restarted).
|
||||
kSystemSwitchInputChromeRestart = 8,
|
||||
// The system switched the output device (for the first time after the
|
||||
// system booted or chrome restarted).
|
||||
kSystemSwitchOutputChromeRestart = 9,
|
||||
// The system did not switch the input device (for the first time after the
|
||||
// system booted or chrome restarted).
|
||||
kSystemNotSwitchInputChromeRestart = 10,
|
||||
// The system did not switch the output device (for the first time after the
|
||||
// system booted or chrome restarted).
|
||||
kSystemNotSwitchOutputChromeRestart = 11,
|
||||
// User overrode the system decision to switch input device (for the first
|
||||
// time after the system booted or chrome restarted).
|
||||
kUserOverrideSystemSwitchInputChromeRestart = 12,
|
||||
// User overrode the system decision to switch output device (for the first
|
||||
// time after the system booted or chrome restarted).
|
||||
kUserOverrideSystemSwitchOutputChromeRestart = 13,
|
||||
// User overrode the system decision to not switch input device (for the
|
||||
// first time after the system booted or chrome restarted).
|
||||
kUserOverrideSystemNotSwitchInputChromeRestart = 14,
|
||||
// User overrode the system decision to not switch output device (for the
|
||||
// first time after the system booted or chrome restarted).
|
||||
kUserOverrideSystemNotSwitchOutputChromeRestart = 15,
|
||||
// The system switched the input device (for hot plug/unplug cases).
|
||||
kSystemSwitchInputNonChromeRestart = 16,
|
||||
// The system switched the output device (for hot plug/unplug cases).
|
||||
kSystemSwitchOutputNonChromeRestart = 17,
|
||||
// The system did not switch the input device (for hot plug/unplug cases).
|
||||
kSystemNotSwitchInputNonChromeRestart = 18,
|
||||
// The system did not switch the output device (for hot plug/unplug cases).
|
||||
kSystemNotSwitchOutputNonChromeRestart = 19,
|
||||
// User overrode the system decision to switch input device (for hot
|
||||
// plug/unplug cases).
|
||||
kUserOverrideSystemSwitchInputNonChromeRestart = 20,
|
||||
// User overrode the system decision to switch output device (for hot
|
||||
// plug/unplug cases).
|
||||
kUserOverrideSystemSwitchOutputNonChromeRestart = 21,
|
||||
// User overrode the system decision to not switch input device (for hot
|
||||
// plug/unplug cases).
|
||||
kUserOverrideSystemNotSwitchInputNonChromeRestart = 22,
|
||||
// User overrode the system decision to not switch output device (for hot
|
||||
// plug/unplug cases).
|
||||
kUserOverrideSystemNotSwitchOutputNonChromeRestart = 23,
|
||||
kMaxValue = kUserOverrideSystemNotSwitchOutputNonChromeRestart,
|
||||
};
|
||||
|
||||
// Record the histogram of system decision of switching or not switching after
|
||||
// audio device is added or removed. Only record if there are more than one
|
||||
// available devices.
|
||||
@ -275,7 +347,8 @@ class COMPONENT_EXPORT(CHROMEOS_ASH_COMPONENTS_AUDIO)
|
||||
|
||||
// Record user overrides system decision metrics.
|
||||
void RecordUserOverrideMetrics(const std::string_view histogram_name,
|
||||
int time_delta) const;
|
||||
AudioSelectionEvents audio_selection_event,
|
||||
int time_delta_since_system_decision) const;
|
||||
|
||||
// Record user overrides system decision metrics in the case of chrome
|
||||
// restarts, including system boots and users sign out, as well as the case of
|
||||
@ -284,7 +357,7 @@ class COMPONENT_EXPORT(CHROMEOS_ASH_COMPONENTS_AUDIO)
|
||||
bool is_input,
|
||||
bool is_switched,
|
||||
bool is_chrome_restarts,
|
||||
int time_delta) const;
|
||||
int time_delta_since_system_decision) const;
|
||||
|
||||
// Record the time elaspsed between two consecutive devices change event,
|
||||
// including devices added/removed and devices changed.
|
||||
|
@ -44,6 +44,23 @@ void ExpectSystemDecisionHistogramCount(
|
||||
AudioDeviceMetricsHandler::kSystemSwitchOutputAudio,
|
||||
kSystemNotSwitchSample, expected_system_not_switch_output_count);
|
||||
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::kSystemSwitchInput,
|
||||
expected_system_switch_input_count);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::kSystemNotSwitchInput,
|
||||
expected_system_not_switch_input_count);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::kSystemSwitchOutput,
|
||||
expected_system_switch_output_count);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::kSystemNotSwitchOutput,
|
||||
expected_system_not_switch_output_count);
|
||||
|
||||
if (is_chrome_restarts) {
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kSystemSwitchInputAudioChromeRestarts,
|
||||
@ -57,6 +74,27 @@ void ExpectSystemDecisionHistogramCount(
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kSystemSwitchOutputAudioChromeRestarts,
|
||||
kSystemNotSwitchSample, expected_system_not_switch_output_count);
|
||||
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kSystemSwitchInputChromeRestart,
|
||||
expected_system_switch_input_count);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kSystemNotSwitchInputChromeRestart,
|
||||
expected_system_not_switch_input_count);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kSystemSwitchOutputChromeRestart,
|
||||
expected_system_switch_output_count);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kSystemNotSwitchOutputChromeRestart,
|
||||
expected_system_not_switch_output_count);
|
||||
} else {
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kSystemSwitchInputAudioNonChromeRestarts,
|
||||
@ -70,6 +108,27 @@ void ExpectSystemDecisionHistogramCount(
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kSystemSwitchOutputAudioNonChromeRestarts,
|
||||
kSystemNotSwitchSample, expected_system_not_switch_output_count);
|
||||
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kSystemSwitchInputNonChromeRestart,
|
||||
expected_system_switch_input_count);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kSystemNotSwitchInputNonChromeRestart,
|
||||
expected_system_not_switch_input_count);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kSystemSwitchOutputNonChromeRestart,
|
||||
expected_system_switch_output_count);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kSystemNotSwitchOutputNonChromeRestart,
|
||||
expected_system_not_switch_output_count);
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,6 +190,83 @@ void ExpectUserOverrideSystemDecisionHistogramCount(
|
||||
}
|
||||
}
|
||||
|
||||
// Test the histogram of user override after system switch or not switch, these
|
||||
// metrics are only fired within limited time frame.
|
||||
void ExpectUserOverrideSystemDecisionHistogramCountInLimitedTime(
|
||||
const base::HistogramTester& histogram_tester,
|
||||
uint16_t expected_user_override_system_switch_input_count_in_limited_time,
|
||||
uint16_t
|
||||
expected_user_override_system_not_switch_input_count_in_limited_time,
|
||||
uint16_t expected_user_override_system_switch_output_count_in_limited_time,
|
||||
uint16_t
|
||||
expected_user_override_system_not_switch_output_count_in_limited_time,
|
||||
bool is_chrome_restarts) {
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kUserOverrideSystemSwitchInput,
|
||||
expected_user_override_system_switch_input_count_in_limited_time);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kUserOverrideSystemNotSwitchInput,
|
||||
expected_user_override_system_not_switch_input_count_in_limited_time);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kUserOverrideSystemSwitchOutput,
|
||||
expected_user_override_system_switch_output_count_in_limited_time);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kUserOverrideSystemNotSwitchOutput,
|
||||
expected_user_override_system_not_switch_output_count_in_limited_time);
|
||||
|
||||
if (is_chrome_restarts) {
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kUserOverrideSystemSwitchInputChromeRestart,
|
||||
expected_user_override_system_switch_input_count_in_limited_time);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kUserOverrideSystemNotSwitchInputChromeRestart,
|
||||
expected_user_override_system_not_switch_input_count_in_limited_time);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kUserOverrideSystemSwitchOutputChromeRestart,
|
||||
expected_user_override_system_switch_output_count_in_limited_time);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kUserOverrideSystemNotSwitchOutputChromeRestart,
|
||||
expected_user_override_system_not_switch_output_count_in_limited_time);
|
||||
} else {
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kUserOverrideSystemSwitchInputNonChromeRestart,
|
||||
expected_user_override_system_switch_input_count_in_limited_time);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kUserOverrideSystemNotSwitchInputNonChromeRestart,
|
||||
expected_user_override_system_not_switch_input_count_in_limited_time);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kUserOverrideSystemSwitchOutputNonChromeRestart,
|
||||
expected_user_override_system_switch_output_count_in_limited_time);
|
||||
histogram_tester.ExpectBucketCount(
|
||||
AudioDeviceMetricsHandler::kAudioSelectionPerformance,
|
||||
AudioDeviceMetricsHandler::AudioSelectionEvents::
|
||||
kUserOverrideSystemNotSwitchOutputNonChromeRestart,
|
||||
expected_user_override_system_not_switch_output_count_in_limited_time);
|
||||
}
|
||||
}
|
||||
|
||||
// Test the time delta histogram of user override after system switch or not
|
||||
// switch.
|
||||
void ExpectUserOverrideSystemDecisionTimeDelta(
|
||||
@ -366,6 +502,14 @@ TEST_F(AudioDeviceSelectionTest, PlugUnplugHistogramMetrics) {
|
||||
uint16_t expected_user_override_system_switch_output_count = 0;
|
||||
uint16_t expected_user_override_system_not_switch_output_count = 0;
|
||||
|
||||
uint16_t expected_user_override_system_switch_input_count_in_limited_time = 0;
|
||||
uint16_t
|
||||
expected_user_override_system_not_switch_input_count_in_limited_time = 0;
|
||||
uint16_t expected_user_override_system_switch_output_count_in_limited_time =
|
||||
0;
|
||||
uint16_t
|
||||
expected_user_override_system_not_switch_output_count_in_limited_time = 0;
|
||||
|
||||
uint16_t num_of_input_devices = 0;
|
||||
uint16_t num_of_output_devices = 0;
|
||||
|
||||
@ -496,6 +640,13 @@ TEST_F(AudioDeviceSelectionTest, PlugUnplugHistogramMetrics) {
|
||||
expected_user_override_system_switch_output_count,
|
||||
expected_user_override_system_not_switch_output_count,
|
||||
/*is_chrome_restarts=*/false);
|
||||
ExpectUserOverrideSystemDecisionHistogramCountInLimitedTime(
|
||||
histogram_tester(),
|
||||
++expected_user_override_system_switch_input_count_in_limited_time,
|
||||
expected_user_override_system_not_switch_input_count_in_limited_time,
|
||||
expected_user_override_system_switch_output_count_in_limited_time,
|
||||
expected_user_override_system_not_switch_output_count_in_limited_time,
|
||||
/*is_chrome_restarts=*/false);
|
||||
ExpectUserOverrideSystemDecisionTimeDelta(
|
||||
histogram_tester(), /*is_input=*/true, /*system_has_switched=*/true,
|
||||
/*delta_in_minute=*/0, /*is_chrome_restarts=*/false);
|
||||
@ -512,6 +663,13 @@ TEST_F(AudioDeviceSelectionTest, PlugUnplugHistogramMetrics) {
|
||||
++expected_user_override_system_switch_output_count,
|
||||
expected_user_override_system_not_switch_output_count,
|
||||
/*is_chrome_restarts=*/false);
|
||||
ExpectUserOverrideSystemDecisionHistogramCountInLimitedTime(
|
||||
histogram_tester(),
|
||||
expected_user_override_system_switch_input_count_in_limited_time,
|
||||
expected_user_override_system_not_switch_input_count_in_limited_time,
|
||||
++expected_user_override_system_switch_output_count_in_limited_time,
|
||||
expected_user_override_system_not_switch_output_count_in_limited_time,
|
||||
/*is_chrome_restarts=*/false);
|
||||
ExpectUserOverrideSystemDecisionTimeDelta(
|
||||
histogram_tester(), /*is_input=*/false, /*system_has_switched=*/true,
|
||||
/*delta_in_minute=*/kTimeDeltaInMinuteA, /*is_chrome_restarts=*/false);
|
||||
@ -527,6 +685,13 @@ TEST_F(AudioDeviceSelectionTest, PlugUnplugHistogramMetrics) {
|
||||
expected_user_override_system_switch_output_count,
|
||||
expected_user_override_system_not_switch_output_count,
|
||||
/*is_chrome_restarts=*/false);
|
||||
ExpectUserOverrideSystemDecisionHistogramCountInLimitedTime(
|
||||
histogram_tester(),
|
||||
expected_user_override_system_switch_input_count_in_limited_time,
|
||||
expected_user_override_system_not_switch_input_count_in_limited_time,
|
||||
expected_user_override_system_switch_output_count_in_limited_time,
|
||||
expected_user_override_system_not_switch_output_count_in_limited_time,
|
||||
/*is_chrome_restarts=*/false);
|
||||
|
||||
// Plug in a bluetooth nb mic with lower priority than current active one.
|
||||
// Expect to record system does not switch input.
|
||||
@ -601,6 +766,13 @@ TEST_F(AudioDeviceSelectionTest, PlugUnplugHistogramMetrics) {
|
||||
expected_user_override_system_switch_output_count,
|
||||
expected_user_override_system_not_switch_output_count,
|
||||
/*is_chrome_restarts=*/false);
|
||||
ExpectUserOverrideSystemDecisionHistogramCountInLimitedTime(
|
||||
histogram_tester(),
|
||||
expected_user_override_system_switch_input_count_in_limited_time,
|
||||
++expected_user_override_system_not_switch_input_count_in_limited_time,
|
||||
expected_user_override_system_switch_output_count_in_limited_time,
|
||||
expected_user_override_system_not_switch_output_count_in_limited_time,
|
||||
/*is_chrome_restarts=*/false);
|
||||
ExpectUserOverrideSystemDecisionTimeDelta(
|
||||
histogram_tester(), /*is_input=*/true, /*system_has_switched=*/false,
|
||||
/*delta_in_minute=*/kTimeDeltaInMinuteB, /*is_chrome_restarts=*/false);
|
||||
@ -676,6 +848,13 @@ TEST_F(AudioDeviceSelectionTest, PlugUnplugHistogramMetrics) {
|
||||
expected_user_override_system_switch_output_count,
|
||||
expected_user_override_system_not_switch_output_count,
|
||||
/*is_chrome_restarts=*/false);
|
||||
ExpectUserOverrideSystemDecisionHistogramCountInLimitedTime(
|
||||
histogram_tester(),
|
||||
expected_user_override_system_switch_input_count_in_limited_time,
|
||||
expected_user_override_system_not_switch_input_count_in_limited_time,
|
||||
expected_user_override_system_switch_output_count_in_limited_time,
|
||||
expected_user_override_system_not_switch_output_count_in_limited_time,
|
||||
/*is_chrome_restarts=*/false);
|
||||
ExpectUserOverrideSystemDecisionTimeDelta(
|
||||
histogram_tester(), /*is_input=*/true, /*system_has_switched=*/true,
|
||||
/*delta_in_minute=*/kTimeDeltaInMinuteC, /*is_chrome_restarts=*/false);
|
||||
@ -716,6 +895,14 @@ TEST_F(AudioDeviceSelectionTest, SystemBootsHistogramMetrics) {
|
||||
uint16_t expected_user_override_system_switch_output_count = 0;
|
||||
uint16_t expected_user_override_system_not_switch_output_count = 0;
|
||||
|
||||
uint16_t expected_user_override_system_switch_input_count_in_limited_time = 0;
|
||||
uint16_t
|
||||
expected_user_override_system_not_switch_input_count_in_limited_time = 0;
|
||||
uint16_t expected_user_override_system_switch_output_count_in_limited_time =
|
||||
0;
|
||||
uint16_t
|
||||
expected_user_override_system_not_switch_output_count_in_limited_time = 0;
|
||||
|
||||
// System boots with multiple audio devices.
|
||||
// Expect to record system has switched both input and output.
|
||||
SystemBootsWith({input_internal, input_USB, output_internal, output_USB});
|
||||
@ -809,6 +996,13 @@ TEST_F(AudioDeviceSelectionTest, SystemBootsHistogramMetrics) {
|
||||
expected_user_override_system_switch_output_count,
|
||||
expected_user_override_system_not_switch_output_count,
|
||||
/*is_chrome_restarts=*/true);
|
||||
ExpectUserOverrideSystemDecisionHistogramCountInLimitedTime(
|
||||
histogram_tester(),
|
||||
++expected_user_override_system_switch_input_count_in_limited_time,
|
||||
expected_user_override_system_not_switch_input_count_in_limited_time,
|
||||
expected_user_override_system_switch_output_count_in_limited_time,
|
||||
expected_user_override_system_not_switch_output_count_in_limited_time,
|
||||
/*is_chrome_restarts=*/true);
|
||||
|
||||
ExpectUserOverrideSystemDecisionTimeDelta(
|
||||
histogram_tester(), /*is_input=*/true, /*system_has_switched=*/true,
|
||||
|
@ -56,6 +56,39 @@ chromium-metrics-reviews@google.com.
|
||||
<int value="1" label="Unmuted"/>
|
||||
</enum>
|
||||
|
||||
<enum name="AudioSelectionEvents">
|
||||
<int value="0" label="Input|System switched"/>
|
||||
<int value="1" label="Output|System switched"/>
|
||||
<int value="2" label="Input|System didn't switch"/>
|
||||
<int value="3" label="Output|System didn't switch"/>
|
||||
<int value="4" label="Input|User overrode|System switched"/>
|
||||
<int value="5" label="Output|User overrode|System switched"/>
|
||||
<int value="6" label="Input|User overrode|System didn't switch"/>
|
||||
<int value="7" label="Output|User overrode|System didn't switch"/>
|
||||
<int value="8" label="Input|System switched|Chrome restarts"/>
|
||||
<int value="9" label="Output|System switched|Chrome restarts"/>
|
||||
<int value="10" label="Input|System didn't switch|Chrome restarts"/>
|
||||
<int value="11" label="Output|System didn't switch|Chrome restarts"/>
|
||||
<int value="12" label="Input|User overrode|System switched|Chrome restarts"/>
|
||||
<int value="13" label="Output|User overrode|System switched|Chrome restarts"/>
|
||||
<int value="14"
|
||||
label="Input|User overrode|System didn't switch|Chrome restarts"/>
|
||||
<int value="15"
|
||||
label="Output|User overrode|System didn't switch|Chrome restarts"/>
|
||||
<int value="16" label="Input|System switched|Non Chrome restarts"/>
|
||||
<int value="17" label="Output|System switched|Non Chrome restarts"/>
|
||||
<int value="18" label="Input|System didn't switch|Non Chrome restarts"/>
|
||||
<int value="19" label="Output|System didn't switch|Non Chrome restarts"/>
|
||||
<int value="20"
|
||||
label="Input|User overrode|System switched|Non Chrome restarts"/>
|
||||
<int value="21"
|
||||
label="Output|User overrode|System switched|Non Chrome restarts"/>
|
||||
<int value="22"
|
||||
label="Input|User overrode|System didn't switch|Non Chrome restarts"/>
|
||||
<int value="23"
|
||||
label="Output|User overrode|System didn't switch|Non Chrome restarts"/>
|
||||
</enum>
|
||||
|
||||
</enums>
|
||||
|
||||
</histogram-configuration>
|
||||
|
@ -22,6 +22,20 @@ incoming reviews. Googlers can read more about this at go/gwsq-gerrit.
|
||||
|
||||
<histograms>
|
||||
|
||||
<histogram name="ChromeOS.AudioSelection" enum="AudioSelectionEvents"
|
||||
expires_after="2025-03-31">
|
||||
<owner>zhangwenyu@google.com</owner>
|
||||
<owner>cros-peripherals@google.com</owner>
|
||||
<summary>
|
||||
Recorded when audio selection events described in AudioSelectionEvents
|
||||
happen. For example, the system switches or does not switch active audio
|
||||
device after the device is added or removed, the user overrides the system
|
||||
switching or not switching decision, etc. The user-override metrics are only
|
||||
recorded if they occur within the first hour after the system decision was
|
||||
made. Do not record if there is no alternative available audio device.
|
||||
</summary>
|
||||
</histogram>
|
||||
|
||||
<histogram
|
||||
name="ChromeOS.AudioSelection.{AudioType}.ConsecutiveDevicesChangeTimeElapsed.{ChangeType}"
|
||||
units="seconds" expires_after="2025-02-25">
|
||||
|
Reference in New Issue
Block a user