blob: abc90c3aa994d7edea592c0167cddd88b7c4a6d4 [file] [log] [blame]
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto3";
package profiler.proto;
option java_package = "com.android.tools.profiler.proto";
option java_outer_classname = "EnergyProfiler";
import "common.proto";
service EnergyService {
// Starts collecting execution metrics of a running app, such as energy
// samples and events. Does nothing if the app is already being monitored.
rpc StartMonitoringApp(EnergyStartRequest) returns (EnergyStartResponse) {
}
// Stops monitoring a running app. Does nothing if the app is not being
// monitored, or is not running.
rpc StopMonitoringApp(EnergyStopRequest) returns (EnergyStopResponse) {
}
// Requests energy samples from app with given |process_id|, in the time range
// from |start_timestamp| (exclusive) to |end_timestamp| (inclusive), or
// mathematically written as in interval (start_timestamp, end_timestamp].
rpc GetSamples(EnergyRequest) returns (EnergySamplesResponse) {
}
// Requests energy event data such as WakeLock, Alarm with given time range.
// Request data range is same as |GetSamples(start_timestamp, end_timestamp]|.
// Response data includes repeated data in time order.
rpc GetEvents(EnergyRequest) returns (EnergyEventsResponse) {
}
// Requests an event group (where all events in a series share the same ID)
rpc GetEventGroup(EnergyEventGroupRequest) returns (EnergyEventsResponse) {
}
}
message EnergyStartRequest {
Session session = 1;
}
message EnergyStartResponse {
}
message EnergyStopRequest {
Session session = 1;
}
message EnergyStopResponse {
}
message EnergyRequest {
Session session = 1;
int64 start_timestamp = 2;
int64 end_timestamp = 3;
}
message EnergyEventGroupRequest {
Session session = 1;
int32 event_id = 2;
}
message EnergySample {
// Time when the energy sample usages occurred.
int64 timestamp = 1;
// Sample usage data by cpu in mA.
int32 cpu_usage = 2;
// Sample usage data by network in mA.
int32 network_usage = 3;
// Sample usage data by location in mA.
int32 location_usage = 4;
}
message EnergySamplesResponse {
// List of Energy usage sample data.
repeated EnergySample samples = 1;
}
message EnergyEventsResponse {
// Energy event details information in time order.
repeated EnergyEvent events = 1;
}
// Energy event data or state change for WakeLock, Alarm, etc.
message EnergyEvent {
// Timestamp of the event in nanoseconds. For related events (e.g. those with
// the same ID), each event is expected to have a unique timestamp, as it will
// be used to order them.
int64 timestamp = 1;
// Application Id this event is associated with.
int32 pid = 2;
// ID used to correlate two (or more) related events together. Note: Event
// group IDs may be re-used across |pid|s, but will be unique within an app.
int32 event_id = 3;
// ID to fetch a code stack trace for where this event was generated
// Use with |ProfilerService.GetBytes|
string trace_id = 4;
// If true, this will be the last event that will be received with this
// |event_id| - in other words, this event ends a series of events.
bool is_terminal = 5;
// Metadata for this specific event. Additionally, use
// |EnergyEvent.metadata_case()| as a way to see what this event's type is.
oneof metadata {
// Note: metadata IDs start at 101, so EnergyEvent fields can be added later
// without any concern for numbers overlapping.
// A wake lock was acquired, forcing the device to stay awake.
WakeLockAcquired wake_lock_acquired = 101;
// A wake lock was released, indicating it's not needed anymore.
WakeLockReleased wake_lock_released = 102;
// An alarm was set.
AlarmSet alarm_set = 103;
// An alarm was cancelled.
AlarmCancelled alarm_cancelled = 104;
// An alarm goes off.
AlarmFired alarm_fired = 105;
// A job is scheduled by JobScheduler.
JobScheduled job_scheduled = 106;
// JobService.onStartJob is called.
JobStarted job_started = 107;
// JobService.onStopJob is called. This is called if the system has
// determined that the application must stop execution of this job even
// before it has had a chance to call jobFinished(JobParameters, boolean).
// For example, JobScheduler.cancel() will trigger this event. This will
// also happen if the constraints specified at schedule time (e.g. requires
// charging) are no longer met.
JobStopped job_stopped = 108;
// JobService.jobFinished is called. Application must call this to inform
// the JobScheduler the application has finished executing. When the system
// receives this message it will release the wakelock being held.
JobFinished job_finished = 109;
// Location update is requested. With user-granted location permission,
// application can start receiving location updates in the form of a
// callback or PendingIntent.
LocationUpdateRequested location_update_requested = 110;
// Location update request is removed. The application stops receiving
// location updates for the given callback or PendingIntent.
LocationUpdateRemoved location_update_removed = 111;
// Location is changed. Application receives the new location in the form of
// a callback or extended data contained in a PendingIntent.
LocationChanged location_changed = 112;
}
}
message WakeLockAcquired {
enum Level {
UNDEFINED_WAKE_LOCK_LEVEL = 0;
PARTIAL_WAKE_LOCK = 1;
SCREEN_DIM_WAKE_LOCK = 2;
SCREEN_BRIGHT_WAKE_LOCK = 3;
FULL_WAKE_LOCK = 4;
PROXIMITY_SCREEN_OFF_WAKE_LOCK = 5;
}
enum CreationFlag {
UNDEFINED_WAKE_LOCK_CREATION_FLAG = 0;
ACQUIRE_CAUSES_WAKEUP = 1;
ON_AFTER_RELEASE = 2;
}
// Level for the wake lock instance initialization.
// https://developer.android.com/reference/android/os/PowerManager.html#newWakeLock(int, java.lang.String)
Level level = 1;
// Optional flags for the wake lock instance initialization, empty if no flag
// is set.
repeated CreationFlag flags = 2;
// Tag of the wake lock (which users may have set for debugging purposes).
string tag = 3;
// An optional timeout in milliseconds given to the acquire call. The lock
// will be released after the given timeout expires.
int64 timeout = 4;
}
message WakeLockReleased {
enum ReleaseFlag {
UNDEFINED_WAKE_LOCK_RELEASE_FLAG = 0;
RELEASE_FLAG_WAIT_FOR_NO_PROXIMITY = 1;
}
// Optional flags that modify the release behavior, empty if no flag is set.
// https://developer.android.com/reference/android/os/PowerManager.WakeLock.html#release(int)
repeated ReleaseFlag flags = 1;
// True if the wake lock is still held after the release. This may happen if
// the wake lock is reference counted and has been acquired multiple times.
bool is_held = 2;
}
message AlarmSet {
enum Type {
UNDEFINED_ALARM_TYPE = 0;
RTC = 1;
RTC_WAKEUP = 2;
ELAPSED_REALTIME = 3;
ELAPSED_REALTIME_WAKEUP = 4;
}
// Type of alarm.
Type type = 1;
// Time in milliseconds that the alarm should go off, using the appropriate
// clock (depending on the alarm type). Used by all AlarmManager.set*()
// methods.
int64 trigger_ms = 2;
// The length of the requested delivery window, in milliseconds. The alarm
// will be delivered no later than this many milliseconds after trigger_ms.
// Used by AlarmManager.setWindow().
int64 window_ms = 3;
// Interval in milliseconds between subsequent repeats of the alarm. Used by
// AlarmManager.setRepeating() and AlarmManager.setInexactRepeating().
int64 interval_ms = 4;
// The alarm action can either be a PendingIntent or an AlarmListener.
oneof set_action {
// Metadata of the action to perform when the alarm goes off.
PendingIntent operation = 5;
// Metadata of the alarm listener whose onAlarm() method will be called when
// the alarm goes off.
AlarmListener listener = 6;
}
}
message AlarmCancelled {
// The alarm action can either be a PendingIntent or an AlarmListener.
oneof cancel_action {
// A previously set operation.
PendingIntent operation = 1;
// A previously set listener.
AlarmListener listener = 2;
}
}
message AlarmFired {
// True if the alarm repeats, i.e. interval is greater than zero.
// Android doesn't allow repeating listener alarms.
bool is_repeating = 1;
// The alarm action can either be a PendingIntent or an AlarmListener.
oneof fire_action {
// A previously set operation.
PendingIntent operation = 2;
// A previously set listener.
AlarmListener listener = 3;
}
}
message PendingIntent {
// The package name of the PendingIntent, or empty if there is none
// associated with it.
string creator_package = 1;
// The uid of the PendingIntent, or -1 if there is none associated with it.
int32 creator_uid = 2;
}
message AlarmListener {
// String describing the alarm listener, used for logging and battery-use
// attribution.
string tag = 1;
}
message JobScheduled {
enum Result {
UNDEFINED_JOB_SCHEDULE_RESULT = 0;
RESULT_FAILURE = 1;
RESULT_SUCCESS = 2;
}
// Contains the parameters required to schedule a job, e.g. constraint.
JobInfo job = 1;
// The result of the schedule request.
Result result = 2;
}
message JobStarted {
// Contains the parameters used to configure the job.
JobParameters params = 1;
// True if the service needs to process the work (on a separate thread). False
// if there's no more work to be done for this job.
bool work_ongoing = 2;
}
message JobStopped {
// Contains the parameters used to configure the job.
JobParameters params = 1;
// True to indicate to the JobScheduler whether the job needs to be
// rescheduled based on the retry criteria provided at job creation-time.
// False to drop the job.
bool reschedule = 2;
}
message JobFinished {
// Contains the parameters used to configure the job.
JobParameters params = 1;
// True if this job should be rescheduled according to the back-off criteria
// specified at schedule-time.
bool needs_reschedule = 2;
}
// The data passed to the JobScheduler encapsulating the parameters required to
// schedule work against the calling application.
message JobInfo {
enum BackoffPolicy {
UNDEFINED_BACKOFF_POLICY = 0;
BACKOFF_POLICY_LINEAR = 1;
BACKOFF_POLICY_EXPONENTIAL = 2;
}
enum NetworkType {
UNDEFINED_NETWORK_TYPE = 0;
NETWORK_TYPE_NONE =1;
NETWORK_TYPE_ANY = 2;
NETWORK_TYPE_UNMETERED = 3;
NETWORK_TYPE_NOT_ROAMING = 4;
NETWORK_TYPE_METERED = 5;
}
// Application-provided id for this job.
int32 job_id = 1;
// Name of the service endpoint that will be called back into by the
// JobScheduler.
string service_name = 2;
// The backoff policy of this job.
BackoffPolicy backoff_policy = 3;
// The amount of time the JobScheduler will wait before rescheduling a failed
// job.
int64 initial_backoff_ms = 4;
// True if this job will repeat with a given period.
bool is_periodic = 5;
// Flex time in milliseconds for a periodic job. The job can execute at any
// time in a window of flex length at the end of the period.
int64 flex_ms = 6;
// Millisecond interval for which this job will repeat. For periodic jobs
// only.
int64 interval_ms = 7;
// Delay in miliseconds after which this job will be eligible for execution.
// For non-periodic jobs only.
int64 min_latency_ms = 8;
// Deadline in miliseconds which is the maximum scheduling latency. The job
// will be run by this deadline even if other requirements are not met. For
// non-periodic jobs only.
int64 max_execution_delay_ms = 9;
// The kind of connectivity requirements that the job has.
NetworkType network_type = 10;
// Which content URIs must change for the job to be scheduled.
repeated string trigger_content_uris = 11;
// When triggering on content URI changes, this is the maximum delay before
// the job is scheduled. It is in milliseconds.
int64 trigger_content_max_delay = 12;
// When triggering on content URI changes, this is the delay from when a
// change is detected until the job is scheduled. It is in milliseconds.
int64 trigger_content_update_delay = 13;
// Whether or not this job should be persisted across device reboots.
bool is_persisted = 14;
// Whether this job needs the device's battery level to not be at below the
// critical threshold.
bool is_require_battery_not_low = 15;
// Whether this job needs the device to be plugged in.
bool is_require_charging = 16;
// Whether this job needs the device to be in an Idle maintenance window.
bool is_require_device_idle = 17;
// Whether this job needs the device's storage to not be low.
bool is_require_storage_not_low = 18;
// String representation of the extras which are returned to the application
// at execution time.
string extras = 19;
// String representation of the transient extras which are returned to the
// application at execution time, but not persisted by the system.
string transient_extras = 20;
}
// The parameters used to configure/identify the job. This is not created by the
// application, instead it is handed in to the application by the System.
message JobParameters {
// The unique id of this job, specified at creation time.
int32 job_id = 1;
// For jobs with JobInfo.trigger_content_uris set, this reports which content
// authorities have triggered the job.
repeated string triggered_content_authorities = 2;
// For jobs with JobInfo.trigger_content_uris set, this reports which URIs
// have triggered the job.
repeated string triggered_content_uris = 3;
// For jobs with setOverrideDeadline(long) set, this provides an easy way to
// tell whether the job is being executed due to the deadline expiring.
bool is_override_deadline_expired = 4;
// String representation of the extras which are returned to the application
// at execution time.
string extras = 5;
// String representation of the transient extras which are returned to the
// application at execution time, but not persisted by the system.
string transient_extras = 6;
}
message LocationUpdateRequested {
oneof action {
// Metadata of the callback whose onLocationChanged() method will be called
// for each location update.
LocationListener listener = 1;
// Metadata of the PendingIntent to be sent for each location update.
PendingIntent intent = 2;
}
// The location request for the updates, e.g. accuracy, interval.
LocationRequest request = 3;
}
message LocationUpdateRemoved {
oneof action {
// A previously requested listener to remove.
LocationListener listener = 1;
// A previously requested PendingIntent to remove.
PendingIntent intent = 2;
}
}
message LocationChanged {
oneof action {
// A previously requested listener.
LocationListener listener = 1;
// A previously requested PendingIntent.
PendingIntent intent = 2;
}
// The location data from the callback or intent extras.
Location location = 3;
}
// Contains no metadata but we need the message to indicate a listener is passed
// to the location request.
message LocationListener {
}
message LocationRequest {
// Priority of the location request. This is an abstraction of the accuracy and
// power useage defined by two location APIs (criteria in LocationManager and
// priority in FusedLocationProviderClient).
enum Priority {
UNDEFINED_PRIORITY = 0;
// Requests the best accuracy possible with zero additional power
// consumption, a.k.a. passive mode. Location update is only sent when
// another application also request it.
NO_POWER = 1;
// Requests "city" level accuracy. Has low power impact.
LOW_POWER = 2;
// Requests "block" level accuracy, a.k.a. coarse location. A balance
// between power consumption and accuracy.
BALANCED = 3;
// Requests the most accurate locations available, a.k.a fine location.
// Has high power impact.
HIGH_ACCURACY = 4;
}
// Name of the location provider.
// If set through LocationManager, it can be "gps", "network", "passive" or
// empty.
// If set through FusedLocationProviderClient, it will be "fused".
string provider = 1;
// The desired interval of this request, in milliseconds.
int64 interval_ms = 2;
// The fastest interval of this request, in milliseconds. In LocationManager
// this uses the same value as interval_ms.
int64 fastest_interval_ms = 3;
// The minimum displacement between location updates in meters.
float smallest_displacement_meters = 4;
// Prority of the location request.
Priority priority = 5;
}
message Location {
// Name of the provider that generated this location.
string provider = 1;
// The estimated horizontal accuracy of this location, radial, in meters.
float accuracy = 2;
// The latitude of this location, in degrees.
double latitude = 3;
// The longitude of this location, in degrees.
double longitude = 4;
}