Bug 1769255 - record the battery percentrage for each active tick, r=chutten,smaug.

Differential Revision: https://phabricator.services.mozilla.com/D146319
This commit is contained in:
Florian Quèze 2022-05-15 21:52:03 +00:00
parent 6c116fd30b
commit 5a63863b53
2 changed files with 31 additions and 0 deletions

View File

@ -12,6 +12,7 @@
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventForwards.h"
#include "mozilla/EventStates.h"
#include "mozilla/Hal.h"
#include "mozilla/HTMLEditor.h"
#include "mozilla/IMEStateManager.h"
#include "mozilla/MiscEvents.h"
@ -42,6 +43,7 @@
#include "mozilla/dom/UIEventBinding.h"
#include "mozilla/dom/UserActivation.h"
#include "mozilla/dom/WheelEventBinding.h"
#include "mozilla/glean/GleanMetrics.h"
#include "mozilla/StaticPrefs_accessibility.h"
#include "mozilla/StaticPrefs_browser.h"
#include "mozilla/StaticPrefs_dom.h"
@ -185,6 +187,13 @@ UITimerCallback::Notify(nsITimer* aTimer) {
} else {
obs->NotifyObservers(nullptr, "user-interaction-active", nullptr);
EventStateManager::UpdateUserActivityTimer();
if (XRE_IsParentProcess()) {
hal::BatteryInformation batteryInfo;
hal::GetCurrentBatteryInformation(&batteryInfo);
glean::power_battery::percentage_when_user_active.AccumulateSamples(
{uint64_t(batteryInfo.level() * 100)});
}
}
mPreviousCount = gMouseOrKeyboardEventCounter;
return NS_OK;

View File

@ -291,3 +291,25 @@ power.cpu_ms_per_thread:
content_foreground: *per_thread_cpu_ms
content_background: *per_thread_cpu_ms
gpu_process: *per_thread_cpu_ms
power.battery:
percentage_when_user_active:
type: custom_distribution
description: >
Records how many percent of battery was available for each period of
user activity.
range_min: 0
range_max: 100
bucket_count: 100
histogram_type: linear
unit: percent
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1769255
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1769255
data_sensitivity:
- interaction
- technical
notification_emails:
- florian@mozilla.com
expires: never