syntax = "proto2";

option java_multiple_files = true;
option java_package = "com.android.settings.fuelgauge.batteryusage";
option java_outer_classname = "AppUsageEventProto";

enum AppUsageEventType {
  UNKNOWN = 0;
  ACTIVITY_RESUMED = 1;
  ACTIVITY_STOPPED = 2;
  DEVICE_SHUTDOWN = 3;
}

message AppUsageEvent {
  // Timestamp of the usage event.
  optional int64 timestamp = 1;
  // Type of the usage event.
  optional AppUsageEventType type = 2;
  // Package name of the app.
  optional string package_name = 3;
  // Instance ID for the activity. This is important for matching events of
  // different event types for the same instance because an activity can be
  // instantiated multiple times. Only available on Q builds after Dec 13 2018.
  optional int32 instance_id = 4;
  // Package name of the task root. For example, if a Twitter activity starts a
  // Chrome activity within the same task, then while package_name is Chrome,
  // task_root_package_name will be Twitter.
  // Note: Activities that are task roots themselves (most activities) will have
  // this field is populated as package_name.
  // Note: The task root might be missing due to b/123404490.
  optional string task_root_package_name = 5;
  optional int64 user_id = 6;
  optional int64 uid = 7;
}

// Represents a continuous period of time when an app is used.
message AppUsagePeriod {
  // Start of the usage period.
  optional int64 start_time = 1;
  // End of the usage period.
  optional int64 end_time = 2;
}

enum AppUsageEndPointType {
  START = 1;
  END = 2;
}

// The endpoint (the beginning or the end) of an AppUsagePeriod.
message AppUsageEndPoint {
  // Type of the end point.
  optional AppUsageEndPointType type = 1;
  // Timestamp of the end point.
  optional int64 timestamp = 2;
}
