// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

syntax = "proto2";

option optimize_for = LITE_RUNTIME;

package power_manager;
option go_package = "chromiumos/system_api/power_manager_proto";

// 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;
      CLAMSHELL = 1;
      CONVERTIBLE = 2;
      DETACHABLE = 3;
      TABLET = 4;
      OTHER = 5;

      // Next value to use: 6
    }

    enum DeviceMode {
      UNKNOWN_MODE = 0;
      CLOSED_LID_MODE = 1;
      LAPTOP_MODE = 2;
      TABLET_MODE = 3;

      // Next value to use: 4
    }

    // 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_minutes = 2;
    // Duration of the last time the device was charged in minutes.
    optional int32 duration_of_last_charge_minutes = 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_minutes = 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_hours = 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_minutes = 17;
    optional int32 duration_recent_audio_playing_minutes = 18;
    // Brightness of the screen in percent.
    optional int32 screen_brightness_percent = 19;
    // Charge voltage in mV.
    optional int32 voltage_mv = 20;
    // Whether there's any shutdown/suspend action between the last charge
    // and current event.
    optional bool halt_from_last_charge = 21;
    // Whether the device is being charged or not.
    optional bool is_charging = 22;

    // Next ID to use: 23
  }

  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;

      // Next value to use: 6
    }

    // Unique number that represent the event.
    optional int32 event_id = 1;
    // Reason for the event.
    optional Reason reason = 2;

    // Next ID to use: 3
  }

  optional Features features = 1;
  optional Event event = 2;

  // Next ID to use: 3
}

// PastChargingEvents contain a list of events that have information about "past
// charging events". It will only store the plug/unplug pair of the last charge
// and a recent plug/halt event if any.
message PastChargingEvents {
  message Event {
    // Time of the event in minutes since Windows epoch.
    optional int32 time = 1;
    // Battery percentage of the device.
    optional int32 battery_percent = 2;
    // Timezone of the device.
    optional int32 timezone = 3;
    // Reason for the event.
    optional UserChargingEvent.Event.Reason reason = 4;

    // Next ID to use: 5
  }
  // A list containing past charging events.
  repeated Event events = 1;
}
