/*
 * Copyright (C) 2025 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.
 */

// Clone of packages/services/Car/service/proto/android/car/watchdog/atoms.proto.

syntax = "proto2";

package com.android.internal;
option java_multiple_files = true;
option java_package = "com.android.internal.util";
option java_outer_classname = "AtomsProto";

/**
 * Logs the current state of an application/process before it is killed.
 *
 * Keep in sync with proto file at frameworks/proto_logging/stats/atoms.proto
 */
message CarWatchdogKillStatsReported {
  // Linux process uid for the package.
  optional int32 uid = 1;

  // State of the uid when it was killed.
  enum UidState {
    UNKNOWN_UID_STATE = 0;
    BACKGROUND_MODE = 1;
    FOREGROUND_MODE = 2;
  }
  optional UidState uid_state = 2;

  // System state indicating whether the system was in normal mode or garage mode.
  enum SystemState {
    UNKNOWN_SYSTEM_STATE = 0;
    USER_INTERACTION_MODE = 1;
    USER_NO_INTERACTION_MODE = 2;
    GARAGE_MODE = 3;
  }
  optional SystemState system_state = 3;

  // Reason for killing the application.
  // Keep in sync with proto file at packages/services/Car/cpp/watchdog/proto
  enum KillReason {
    UNKNOWN_KILL_REASON = 0;
    KILLED_ON_ANR = 1;
    KILLED_ON_IO_OVERUSE = 2;
    KILLED_ON_MEMORY_OVERUSE = 3;
  }
  optional KillReason kill_reason = 4;

  // Stats of the processes owned by the application when the application was killed.
  // The process stack traces are not collected when the application was killed due to IO_OVERUSE.
  optional CarWatchdogProcessStats process_stats = 5;

  reserved 6; //CarWatchdogIoOveruseStats
}

/**
 * Logs each CarWatchdogProcessStat in CarWatchdogProcessStats.
 *
 * Keep in sync with proto file at frameworks/proto_logging/stats/atoms.proto
 */
message CarWatchdogProcessStats {
  // Records the stats of the processes owned by an application.
  repeated CarWatchdogProcessStat process_stat = 1;
}

/**
 * Logs a process's stats.
 *
 * Keep in sync with proto file at frameworks/proto_logging/stats/atoms.proto
 */
message CarWatchdogProcessStat {
  // Command name of the process.
  optional string process_name = 1;

  // Process uptime.
  optional uint64 uptime_millis = 2;

  reserved 3; //major_page_faults

  reserved 4; //vm_peak_kb

  reserved 5; //vm_size_kb

  reserved 6; //vm_hwm_kb

  reserved 7; //vm_rss_kb
}
