/*
 * Copyright (C) 2023 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 = "proto2";
package perfetto.protos;

message EntityStateResidency {
  message PowerEntityState {
    // Index corresponding to the entity
    optional int32 entity_index = 1;

    // Index corresponding to the state
    optional int32 state_index = 2;

    // Name of the entity. This is device-specific, determined by the PowerStats
    // HAL, and cannot be configured by the user. An example would be
    // "Bluetooth".
    optional string entity_name = 3;

    // Name of the state. This is device-specific, determined by the PowerStats
    // HAL, and cannot be configured by the user. An example would be
    // "Active".
    optional string state_name = 4;
  }

  // This is only emitted at the beginning of the trace.
  repeated PowerEntityState power_entity_state = 1;

  message StateResidency {
    // Index corresponding to PowerEntityState.entity_index
    optional int32 entity_index = 1;

    // Index corresponding to PowerEntityState.state_index
    optional int32 state_index = 2;

    // Time since boot that this entity has been in this state
    optional uint64 total_time_in_state_ms = 3;

    // Total number of times since boot that the entity has entered this state
    optional uint64 total_state_entry_count = 4;

    // Timestamp of the last time the entity entered this state
    optional uint64 last_entry_timestamp_ms = 5;
  }

  repeated StateResidency residency = 2;
}
