/*
 * Copyright (C) 2024 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 android.os.statsd.hardware.health;

import "frameworks/proto_logging/stats/atom_field_options.proto";
import "frameworks/proto_logging/stats/atoms.proto";
import "frameworks/proto_logging/stats/enums/hardware/health/enums.proto";

option java_package = "com.android.os.hardware.health";
option java_multiple_files = true;

extend Atom {
  optional BatteryHealth battery_health = 10220 [(module) = "framework"];
  optional BatteryLife battery_life = 10245 [(module) = "framework"];
  optional FullBatteryDesignCapacity full_battery_design_capacity = 10246 [(module) = "framework"];
}

/*
 * Data reported by the android.hardware.health HAL.
 */
message BatteryHealth {
  /*
   * Monday of the week the battery was manufactured, in YYYYMMDD format.
   */
  optional int32 battery_manufacturing_date = 1;
  /*
   * Monday of the week the battery was first used, in YYYYMMDD format.
   */
  optional int32 battery_first_usage_date = 2;
  /*
   * Measured battery state of health (remaining estimate full charge capacity
   * relative to the rated capacity in %).
   * This value is in the range 0 to 100, where the special value 0 refers to *
   un UNKNOWN state of the battery.
   */
  optional int32 battery_state_of_health = 3;
  /*
   * Last byte of the hashed battery serial number.
   */
  optional int32 battery_serial_number_hash = 4;
  optional android.hardware.health.BatteryPartStatus battery_part_status = 5;
  optional android.hardware.health.BatteryChargingState battery_charging_state =
      6;
  optional android.hardware.health.BatteryChargingPolicy
      battery_charging_policy = 7;
}

/*
 * Pulls total battery life estimate based on current drain rate, as reported
 * by the android.hardware.health HAL.
 */
message BatteryLife {
  /*
   * The estimated total battery life at the current drain rate, using the
   * actual total battery capacity.
   */
  optional int32 battery_life_minutes = 1;
}

/*
 * Pulls battery design capacity, which is the battery design capacity when full in uAh.
 * This data is retrieved from corresponding registers within the Fuel Gauge (FG) settings.
 *
 * This reported value can vary for the same device model due to factors such as
 * different battery vendors or FG configurations (e.g., using minimum vs. typical capacity).
 */
message FullBatteryDesignCapacity {
    optional int32 design_capacity_micro_ampere_hour = 1;
}
