Commit 12edfb49 authored by Thanh Nguyen's avatar Thanh Nguyen Committed by Commit Bot

[smart-charging] Collect data for Smart Charging

This CL adds a class to collect data for Smart Charging.
The implementation of the class is not completed yet and will be changed
in future CLs.

Here is the design doc: go/cros-smart-charging-logging

Bug: 1028853
Change-Id: I4a2b491be0d6929859a2fce1cb9a9d6bf6db0ec9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1940315
Commit-Queue: Thanh Nguyen <thanhdng@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarJia Meng <jiameng@chromium.org>
Reviewed-by: default avatarTony Yeoman <tby@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721250}
parent 611ecb2e
...@@ -57,6 +57,7 @@ source_set("chromeos") { ...@@ -57,6 +57,7 @@ source_set("chromeos") {
":print_job_info_proto", ":print_job_info_proto",
":screen_brightness_event_proto", ":screen_brightness_event_proto",
":user_activity_event_proto", ":user_activity_event_proto",
":user_charging_event_proto",
"crostini:crostini_installer_types_mojom", "crostini:crostini_installer_types_mojom",
"//apps", "//apps",
"//ash", "//ash",
...@@ -1985,6 +1986,8 @@ source_set("chromeos") { ...@@ -1985,6 +1986,8 @@ source_set("chromeos") {
"power/process_data_collector.h", "power/process_data_collector.h",
"power/renderer_freezer.cc", "power/renderer_freezer.cc",
"power/renderer_freezer.h", "power/renderer_freezer.h",
"power/smart_charging/smart_charging_manager.cc",
"power/smart_charging/smart_charging_manager.h",
"preferences.cc", "preferences.cc",
"preferences.h", "preferences.h",
"printing/automatic_usb_printer_configurer.cc", "printing/automatic_usb_printer_configurer.cc",
...@@ -2887,6 +2890,7 @@ source_set("unit_tests") { ...@@ -2887,6 +2890,7 @@ source_set("unit_tests") {
"power/power_metrics_reporter_unittest.cc", "power/power_metrics_reporter_unittest.cc",
"power/process_data_collector_unittest.cc", "power/process_data_collector_unittest.cc",
"power/renderer_freezer_unittest.cc", "power/renderer_freezer_unittest.cc",
"power/smart_charging/smart_charging_manager_unittest.cc",
"preferences_unittest.cc", "preferences_unittest.cc",
"printing/automatic_usb_printer_configurer_unittest.cc", "printing/automatic_usb_printer_configurer_unittest.cc",
"printing/bulk_printers_calculator_unittest.cc", "printing/bulk_printers_calculator_unittest.cc",
...@@ -3121,6 +3125,12 @@ proto_library("screen_brightness_event_proto") { ...@@ -3121,6 +3125,12 @@ proto_library("screen_brightness_event_proto") {
] ]
} }
proto_library("user_charging_event_proto") {
sources = [
"power/smart_charging/user_charging_event.proto",
]
}
proto_library("user_activity_event_proto") { proto_library("user_activity_event_proto") {
sources = [ sources = [
"power/ml/user_activity_event.proto", "power/ml/user_activity_event.proto",
......
jiameng@chromium.org
thanhdng@chromium.org
// Copyright 2019 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 "chrome/browser/chromeos/power/smart_charging/smart_charging_manager.h"
#include <memory>
#include "chrome/browser/chromeos/power/ml/recent_events_counter.h"
#include "chromeos/constants/devicetype.h"
#include "chromeos/dbus/power_manager/backlight.pb.h"
namespace chromeos {
namespace power {
namespace {
// Interval at which data should be logged.
constexpr base::TimeDelta kLoggingInterval = base::TimeDelta::FromMinutes(30);
// Count number of key, mouse and touch events in the past 30 minutes.
constexpr base::TimeDelta kUserInputEventsDuration =
base::TimeDelta::FromMinutes(30);
// Granularity of input events is per minute.
constexpr int kNumUserInputEventsBuckets =
kUserInputEventsDuration / base::TimeDelta::FromMinutes(1);
} // namespace
SmartChargingManager::SmartChargingManager(
ui::UserActivityDetector* detector,
std::unique_ptr<base::RepeatingTimer> periodic_timer)
: periodic_timer_(std::move(periodic_timer)),
mouse_counter_(std::make_unique<ml::RecentEventsCounter>(
kUserInputEventsDuration,
kNumUserInputEventsBuckets)),
key_counter_(std::make_unique<ml::RecentEventsCounter>(
kUserInputEventsDuration,
kNumUserInputEventsBuckets)),
stylus_counter_(std::make_unique<ml::RecentEventsCounter>(
kUserInputEventsDuration,
kNumUserInputEventsBuckets)),
touch_counter_(std::make_unique<ml::RecentEventsCounter>(
kUserInputEventsDuration,
kNumUserInputEventsBuckets)) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(detector);
user_activity_observer_.Add(detector);
power_manager_client_observer_.Add(chromeos::PowerManagerClient::Get());
}
SmartChargingManager::~SmartChargingManager() = default;
std::unique_ptr<SmartChargingManager> SmartChargingManager::CreateInstance() {
// TODO(crbug.com/1028853): we are collecting data from Chromebook only. Since
// this action is discouraged, we will modify the condition latter using dbus
// calls.
if (chromeos::GetDeviceType() != chromeos::DeviceType::kChromebook)
return nullptr;
ui::UserActivityDetector* const detector = ui::UserActivityDetector::Get();
DCHECK(detector);
std::unique_ptr<SmartChargingManager> screen_brightness_manager =
std::make_unique<SmartChargingManager>(
detector, std::make_unique<base::RepeatingTimer>());
return screen_brightness_manager;
}
void SmartChargingManager::OnUserActivity(const ui::Event* event) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!event)
return;
const base::TimeDelta time_since_boot = boot_clock_.GetTimeSinceBoot();
// Using time_since_boot instead of the event's time stamp so we can use the
// boot clock.
if (event->IsMouseEvent()) {
mouse_counter_->Log(time_since_boot);
return;
}
if (event->IsKeyEvent()) {
key_counter_->Log(time_since_boot);
return;
}
if (event->IsTouchEvent()) {
if (event->AsTouchEvent()->pointer_details().pointer_type ==
ui::EventPointerType::POINTER_TYPE_PEN) {
stylus_counter_->Log(time_since_boot);
return;
}
touch_counter_->Log(time_since_boot);
}
}
void SmartChargingManager::ScreenBrightnessChanged(
const power_manager::BacklightBrightnessChange& change) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
screen_brightness_percent_ = change.percent();
}
void SmartChargingManager::PowerChanged(
const power_manager::PowerSupplyProperties& proto) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (proto.has_battery_percent()) {
battery_percent_ = proto.battery_percent();
}
if (!proto.has_external_power()) {
return;
}
// Logic for the first PowerChanged call.
if (!external_power_.has_value()) {
external_power_ = proto.external_power();
periodic_timer_->Start(FROM_HERE, kLoggingInterval, this,
&SmartChargingManager::OnTimerFired);
if (external_power_.value() == power_manager::PowerSupplyProperties::AC) {
LogEvent(UserChargingEvent::Event::CHARGER_PLUGGED_IN);
}
return;
}
const bool was_on_ac =
external_power_.value() == power_manager::PowerSupplyProperties::AC;
const bool now_on_ac =
proto.external_power() == power_manager::PowerSupplyProperties::AC;
// User plugged the charger in.
if (!was_on_ac && now_on_ac) {
external_power_ = proto.external_power();
LogEvent(UserChargingEvent::Event::CHARGER_PLUGGED_IN);
} else if (was_on_ac && !now_on_ac) {
// User unplugged the charger.
external_power_ = proto.external_power();
LogEvent(UserChargingEvent::Event::CHARGER_UNPLUGGED);
}
}
void SmartChargingManager::PowerManagerBecameAvailable(bool available) {
if (!available) {
return;
}
chromeos::PowerManagerClient::Get()->RequestStatusUpdate();
chromeos::PowerManagerClient::Get()->GetScreenBrightnessPercent(
base::BindOnce(&SmartChargingManager::OnReceiveScreenBrightnessPercent,
weak_ptr_factory_.GetWeakPtr()));
}
void SmartChargingManager::PopulateUserChargingEventProto(
UserChargingEvent* proto) {
auto& features = *proto->mutable_features();
if (battery_percent_)
features.set_battery_percentage(static_cast<int>(battery_percent_.value()));
const base::TimeDelta time_since_boot = boot_clock_.GetTimeSinceBoot();
features.set_num_recent_key_events(key_counter_->GetTotal(time_since_boot));
features.set_num_recent_mouse_events(
mouse_counter_->GetTotal(time_since_boot));
features.set_num_recent_touch_events(
touch_counter_->GetTotal(time_since_boot));
features.set_num_recent_stylus_events(
stylus_counter_->GetTotal(time_since_boot));
if (screen_brightness_percent_)
features.set_screen_brightness_percent(
static_cast<int>(screen_brightness_percent_.value()));
}
void SmartChargingManager::LogEvent(
const UserChargingEvent::Event::Reason& reason) {
UserChargingEvent proto;
proto.mutable_event()->set_event_id(++event_id_);
proto.mutable_event()->set_reason(reason);
PopulateUserChargingEventProto(&proto);
// TODO(crbug.com/1028853): This is for testing only. Need to remove when
// ukm logger is available.
user_charging_event_for_test_ = proto;
// TODO(crbug.com/1028853): Implements logic of this function.
}
void SmartChargingManager::OnTimerFired() {
LogEvent(UserChargingEvent_Event::PERIODIC_LOG);
}
void SmartChargingManager::OnReceiveScreenBrightnessPercent(
base::Optional<double> screen_brightness_percent) {
if (screen_brightness_percent.has_value()) {
screen_brightness_percent_ = *screen_brightness_percent;
}
}
} // namespace power
} // namespace chromeos
// Copyright 2019 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 CHROME_BROWSER_CHROMEOS_POWER_SMART_CHARGING_SMART_CHARGING_MANAGER_H_
#define CHROME_BROWSER_CHROMEOS_POWER_SMART_CHARGING_SMART_CHARGING_MANAGER_H_
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/scoped_observer.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "chrome/browser/chromeos/power/ml/boot_clock.h"
#include "chrome/browser/chromeos/power/smart_charging/user_charging_event.pb.h"
#include "chromeos/dbus/power/power_manager_client.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "ui/base/user_activity/user_activity_detector.h"
#include "ui/base/user_activity/user_activity_observer.h"
namespace chromeos {
namespace power {
namespace ml {
class RecentEventsCounter;
} // namespace ml
// SmartChargingManager logs battery percentage and other features related to
// user charging events. It is currently used to log data and will be
// extended to do inference in the future.
class SmartChargingManager : public ui::UserActivityObserver,
public PowerManagerClient::Observer {
public:
SmartChargingManager(ui::UserActivityDetector* detector,
std::unique_ptr<base::RepeatingTimer> periodic_timer);
~SmartChargingManager() override;
SmartChargingManager(const SmartChargingManager&) = delete;
SmartChargingManager& operator=(const SmartChargingManager&) = delete;
static std::unique_ptr<SmartChargingManager> CreateInstance();
// ui::UserActivityObserver overrides:
void OnUserActivity(const ui::Event* event) override;
// chromeos::PowerManagerClient::Observer overrides:
void ScreenBrightnessChanged(
const power_manager::BacklightBrightnessChange& change) override;
void PowerChanged(const power_manager::PowerSupplyProperties& proto) override;
void PowerManagerBecameAvailable(bool available) override;
private:
friend class SmartChargingManagerTest;
FRIEND_TEST_ALL_PREFIXES(SmartChargingManagerTest,
BrightnessRecoredCorrectly);
FRIEND_TEST_ALL_PREFIXES(SmartChargingManagerTest, PowerChangedTest);
FRIEND_TEST_ALL_PREFIXES(SmartChargingManagerTest, TimerFiredTest);
FRIEND_TEST_ALL_PREFIXES(SmartChargingManagerTest, UserEventCounts);
// Populates the UserChargingEvent proto for logging/inference.
void PopulateUserChargingEventProto(UserChargingEvent* proto);
// Log the event.
void LogEvent(const UserChargingEvent::Event::Reason& reason);
// Called when the periodic timer triggers.
void OnTimerFired();
// Updates screen brightness percent from received value.
void OnReceiveScreenBrightnessPercent(
base::Optional<double> screen_brightness_percent);
ScopedObserver<ui::UserActivityDetector, ui::UserActivityObserver>
user_activity_observer_{this};
ScopedObserver<chromeos::PowerManagerClient,
chromeos::PowerManagerClient::Observer>
power_manager_client_observer_{this};
// Timer to trigger periodically for logging data.
const std::unique_ptr<base::RepeatingTimer> periodic_timer_;
// Helper to return TimeSinceBoot.
ml::BootClock boot_clock_;
int event_id_ = -1;
// Counters for user events.
const std::unique_ptr<ml::RecentEventsCounter> mouse_counter_;
const std::unique_ptr<ml::RecentEventsCounter> key_counter_;
const std::unique_ptr<ml::RecentEventsCounter> stylus_counter_;
const std::unique_ptr<ml::RecentEventsCounter> touch_counter_;
// TODO(crbug.com/1028853): This is for testing only. Need to remove when ukm
// logger is available.
UserChargingEvent user_charging_event_for_test_;
base::Optional<double> battery_percent_;
base::Optional<double> screen_brightness_percent_;
base::Optional<power_manager::PowerSupplyProperties::ExternalPower>
external_power_;
SEQUENCE_CHECKER(sequence_checker_);
base::WeakPtrFactory<SmartChargingManager> weak_ptr_factory_{this};
};
} // namespace power
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_POWER_SMART_CHARGING_SMART_CHARGING_MANAGER_H_
// Copyright 2019 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 "chrome/browser/chromeos/power/smart_charging/smart_charging_manager.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/time/clock.h"
#include "base/timer/timer.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chromeos/dbus/power/fake_power_manager_client.h"
#include "ui/events/keycodes/dom/dom_code.h"
namespace chromeos {
namespace power {
class SmartChargingManagerTest : public ChromeRenderViewHostTestHarness {
public:
SmartChargingManagerTest()
: ChromeRenderViewHostTestHarness(
base::test::TaskEnvironment::MainThreadType::UI,
base::test::TaskEnvironment::TimeSource::MOCK_TIME,
base::test::TaskEnvironment::ThreadPoolExecutionMode::QUEUED) {}
~SmartChargingManagerTest() override = default;
SmartChargingManagerTest(const SmartChargingManagerTest&) = delete;
SmartChargingManagerTest& operator=(const SmartChargingManagerTest&) = delete;
void SetUp() override {
ChromeRenderViewHostTestHarness::SetUp();
PowerManagerClient::InitializeFake();
auto periodic_timer = std::make_unique<base::RepeatingTimer>();
periodic_timer->SetTaskRunner(
task_environment()->GetMainThreadTaskRunner());
smart_charging_manager_ = std::make_unique<SmartChargingManager>(
&user_activity_detector_, std::move(periodic_timer));
}
void TearDown() override {
smart_charging_manager_.reset();
PowerManagerClient::Shutdown();
ChromeRenderViewHostTestHarness::TearDown();
}
SmartChargingManager* smart_charging_manager() {
return smart_charging_manager_.get();
}
protected:
void ReportUserActivity(const ui::Event* const event) {
smart_charging_manager_->OnUserActivity(event);
}
void ReportPowerChangeEvent(
const power_manager::PowerSupplyProperties::ExternalPower power,
const float battery_percent) {
power_manager::PowerSupplyProperties proto;
proto.set_external_power(power);
proto.set_battery_percent(battery_percent);
FakePowerManagerClient::Get()->UpdatePowerProperties(proto);
}
void ReportBrightnessChangeEvent(const double level) {
power_manager::BacklightBrightnessChange change;
change.set_percent(level);
smart_charging_manager_->ScreenBrightnessChanged(change);
}
void FireTimer() { smart_charging_manager_->OnTimerFired(); }
void InitializeBrightness(const double level) {
smart_charging_manager_->OnReceiveScreenBrightnessPercent(level);
}
void FastForwardTimeBySecs(const int seconds) {
task_environment()->FastForwardBy(base::TimeDelta::FromSeconds(seconds));
}
const gfx::Point kEventLocation = gfx::Point(90, 90);
const ui::MouseEvent kMouseEvent = ui::MouseEvent(ui::ET_MOUSE_MOVED,
kEventLocation,
kEventLocation,
base::TimeTicks(),
0,
0);
private:
ui::UserActivityDetector user_activity_detector_;
std::unique_ptr<SmartChargingManager> smart_charging_manager_;
};
TEST_F(SmartChargingManagerTest, BrightnessRecoredCorrectly) {
InitializeBrightness(55.3f);
// LogEvent() hasn't been called yet.
ReportPowerChangeEvent(power_manager::PowerSupplyProperties::DISCONNECTED,
23.0f);
EXPECT_FALSE(
smart_charging_manager()->user_charging_event_for_test_.has_features());
EXPECT_FALSE(
smart_charging_manager()->user_charging_event_for_test_.has_event());
ReportBrightnessChangeEvent(75.7f);
ReportPowerChangeEvent(power_manager::PowerSupplyProperties::AC, 15.0f);
EXPECT_EQ(smart_charging_manager()
->user_charging_event_for_test_.features()
.screen_brightness_percent(),
75);
}
TEST_F(SmartChargingManagerTest, PowerChangedTest) {
// LogEvent() hasn't been called yet.
ReportPowerChangeEvent(power_manager::PowerSupplyProperties::DISCONNECTED,
23.0f);
EXPECT_EQ(smart_charging_manager()->external_power_.value(),
power_manager::PowerSupplyProperties::DISCONNECTED);
EXPECT_FALSE(
smart_charging_manager()->user_charging_event_for_test_.has_features());
EXPECT_FALSE(
smart_charging_manager()->user_charging_event_for_test_.has_event());
// Plugs in the charger.
ReportPowerChangeEvent(power_manager::PowerSupplyProperties::AC, 15.0f);
EXPECT_EQ(smart_charging_manager()->external_power_.value(),
power_manager::PowerSupplyProperties::AC);
EXPECT_EQ(smart_charging_manager()
->user_charging_event_for_test_.features()
.battery_percentage(),
15);
EXPECT_EQ(smart_charging_manager()
->user_charging_event_for_test_.event()
.event_id(),
0);
EXPECT_EQ(
smart_charging_manager()->user_charging_event_for_test_.event().reason(),
UserChargingEvent::Event::CHARGER_PLUGGED_IN);
// Unplugs the charger.
ReportPowerChangeEvent(power_manager::PowerSupplyProperties::USB, 85.0f);
EXPECT_EQ(smart_charging_manager()->external_power_.value(),
power_manager::PowerSupplyProperties::USB);
EXPECT_EQ(smart_charging_manager()
->user_charging_event_for_test_.features()
.battery_percentage(),
85);
EXPECT_EQ(smart_charging_manager()
->user_charging_event_for_test_.event()
.event_id(),
1);
EXPECT_EQ(
smart_charging_manager()->user_charging_event_for_test_.event().reason(),
UserChargingEvent::Event::CHARGER_UNPLUGGED);
}
TEST_F(SmartChargingManagerTest, TimerFiredTest) {
// Timer fired 2 times.
ReportPowerChangeEvent(power_manager::PowerSupplyProperties::USB, 23.0f);
FastForwardTimeBySecs(3600);
EXPECT_EQ(smart_charging_manager()
->user_charging_event_for_test_.features()
.battery_percentage(),
23);
EXPECT_EQ(smart_charging_manager()
->user_charging_event_for_test_.event()
.event_id(),
1);
EXPECT_EQ(
smart_charging_manager()->user_charging_event_for_test_.event().reason(),
UserChargingEvent::Event::PERIODIC_LOG);
// Charger plugged in.
ReportPowerChangeEvent(power_manager::PowerSupplyProperties::AC, 50.0f);
FastForwardTimeBySecs(1900);
EXPECT_EQ(smart_charging_manager()
->user_charging_event_for_test_.features()
.battery_percentage(),
50);
EXPECT_EQ(smart_charging_manager()
->user_charging_event_for_test_.event()
.event_id(),
3);
EXPECT_EQ(
smart_charging_manager()->user_charging_event_for_test_.event().reason(),
UserChargingEvent::Event::PERIODIC_LOG);
}
TEST_F(SmartChargingManagerTest, UserEventCounts) {
FastForwardTimeBySecs(1);
ReportUserActivity(&kMouseEvent);
const ui::TouchEvent kTouchEvent(
ui::ET_TOUCH_PRESSED, kEventLocation, base::TimeTicks(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
ReportUserActivity(&kTouchEvent);
ReportUserActivity(&kTouchEvent);
const ui::KeyEvent kKeyEvent(
ui::ET_KEY_PRESSED, ui::VKEY_A, ui::DomCode::US_A, 0,
ui::DomKey::FromCharacter('a'), base::TimeTicks());
ReportUserActivity(&kKeyEvent);
ReportUserActivity(&kKeyEvent);
ReportUserActivity(&kKeyEvent);
const ui::TouchEvent kStylusEvent(
ui::ET_TOUCH_MOVED, kEventLocation, base::TimeTicks(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_PEN, 0),
ui::EF_NONE);
ReportUserActivity(&kStylusEvent);
ReportUserActivity(&kStylusEvent);
ReportUserActivity(&kStylusEvent);
ReportUserActivity(&kStylusEvent);
FastForwardTimeBySecs(2);
FireTimer();
const auto& proto = smart_charging_manager()->user_charging_event_for_test_;
EXPECT_EQ(proto.features().num_recent_mouse_events(), 1);
EXPECT_EQ(proto.features().num_recent_touch_events(), 2);
EXPECT_EQ(proto.features().num_recent_key_events(), 3);
EXPECT_EQ(proto.features().num_recent_stylus_events(), 4);
}
} // namespace power
} // namespace chromeos
// Copyright 2019 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.
syntax = "proto2";
package chromeos.power;
option optimize_for = LITE_RUNTIME;
// UserChargingEvent contains information about users activities that are
// related to charging.
message UserChargingEvent {
message Features {
enum DayOfWeek {
SUN = 0;
MON = 1;
TUE = 2;
WED = 3;
THU = 4;
FRI = 5;
SAT = 6;
}
enum Month {
JAN = 1;
FEB = 2;
MAR = 3;
APR = 4;
MAY = 5;
JUN = 6;
JUL = 7;
AUG = 8;
SEP = 9;
OCT = 10;
NOV = 11;
DEC = 12;
}
enum DeviceType {
UNKNOWN = 0;
LAPTOP = 1;
CLAMSHELL = 2;
TABLET = 3;
}
enum DeviceMode {
CLOSE_LID_MODE = 1;
LAPTOP_MODE = 2;
TABLET_MODE = 3;
}
// Percentage of the battery.
optional int32 battery_percentage = 1;
// Time since the last time user unplugged the charger in minutes.
optional int32 time_since_last_charge = 2;
// Duration of the last time the device was charged in minutes.
optional int32 duration_of_last_charge = 3;
// The percentage of the battery that the last charge reached.
optional int32 battery_percentage_of_last_charge = 4;
// The percentage of the battery at the beginning of the last charge.
optional int32 battery_percentage_before_last_charge = 5;
// Time of the event in minutes since midnight in the local time zone.
optional int32 time_of_the_day = 6;
// Logging event's day of week.
optional DayOfWeek day_of_week = 7;
// Logging event's day of month.
optional int32 day_of_month = 8;
// Logging event's month.
optional Month month = 9;
// Timezone difference from the last charge. It is equal to
// current_timezone - timezone_from_the_last_charge. The valid range of time
// zone value will be -12 (UTC -12:00) to +14 (UTC +14:00).
optional double timezone_difference_from_last_charge = 10;
// Type of the device.
optional DeviceType device_type = 11;
// Mode of the device.
optional DeviceMode device_mode = 12;
// Number of various events in past 30 minutes.
optional int32 num_recent_key_events = 13;
optional int32 num_recent_mouse_events = 14;
optional int32 num_recent_touch_events = 15;
optional int32 num_recent_stylus_events = 16;
// Duration of video and audio playing in the last 30 minutes.
optional int32 duration_recent_video_playing = 17;
optional int32 duration_recent_audio_playing = 18;
// Brightness of the screen in percent.
optional int32 screen_brightness_percent = 19;
// Charge voltage in mV.
optional int32 voltage = 20;
}
message Event {
enum Reason {
// User plugs in the charger.
CHARGER_PLUGGED_IN = 1;
// User unplugs the charger.
CHARGER_UNPLUGGED = 2;
// Logging at a regular time interval.
PERIODIC_LOG = 3;
// Device goes into shutdown mode.
SHUTDOWN = 4;
// Device goes into suspend mode.
SUSPEND = 5;
}
// Unique number that represent the event.
optional int32 event_id = 1;
// Reason for the event.
optional Reason reason = 2;
}
optional Features features = 1;
optional Event event = 2;
}
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