huangcm
2025-04-22 c8cf547b11f2c03565d8fb8b8bcdc69860d0ed08
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/*
 * Copyright (C) 2016 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.
 */
 
package android.hardware.health@1.0;
 
/**
 * Possible return values for optional HAL method(s) like
 * IHealth::energyCounter()
 */
enum Result : int32_t {
    SUCCESS,
    NOT_SUPPORTED,
    UNKNOWN,
};
 
/**
 * Possible values for Battery Status.
 * Note: These are currently in sync with BatteryManager and must not
 * be extended / altered.
 */
@export(name="", value_prefix="BATTERY_STATUS_")
enum BatteryStatus : int32_t {
    UNKNOWN = 1,
    CHARGING = 2,
    DISCHARGING = 3,
    /**
     * Battery is *not* charging - special case when charger is present
     * but battery isn't charging
     */
    NOT_CHARGING = 4,
    FULL = 5,
};
 
/**
 * Possible values for Battery Health.
 * Note: These are currently in sync with BatteryManager and must not
 * be extended / altered.
 */
@export(name="", value_prefix="BATTERY_HEALTH_")
enum BatteryHealth : int32_t {
    UNKNOWN = 1,
    GOOD = 2,
    OVERHEAT = 3,
    DEAD = 4,
    OVER_VOLTAGE = 5,
    /**
     * Battery experienced an unknown/unspecifid failure.
     */
    UNSPECIFIED_FAILURE = 6,
    COLD = 7,
};
 
struct HealthConfig {
 
    /**
     * periodicChoresIntervalFast is used while the device is not in
     * suspend, or in suspend and connected to a charger (to watch for battery
     * overheat due to charging)
     */
    int32_t periodicChoresIntervalFast;
 
    /**
     * periodicChoresIntervalSlow is used when the device is in suspend and
     * not connected to a charger (to watch for a battery drained to zero
     * remaining capacity).
     */
    int32_t periodicChoresIntervalSlow;
 
    /**
     * power_supply sysfs attribute file paths. Set these to specific paths
     * to use for the associated battery parameters. Clients must search
     * for appropriate power_supply attribute files to use, for any paths
     * left empty after the HAL is initialized.
     */
 
    /**
     * batteryStatusPath - file path to read battery charging status.
     * (POWER_SUPPLY_PROP_STATUS)
     */
    string batteryStatusPath;
 
 
    /**
     * batteryHealthPath - file path to read battery health.
     * (POWER_SUPPLY_PROP_HEALTH)
     */
    string batteryHealthPath;
 
    /**
     * batteryPresentPath - file path to read battery present status.
     * (POWER_SUPPLY_PROP_PRESENT)
     */
    string batteryPresentPath;
 
 
    /**
     * batteryCapacityPath - file path to read remaining battery capacity.
     * (POWER_SUPPLY_PROP_CAPACITY)
     */
    string batteryCapacityPath;
 
    /**
     * batteryVoltagePath - file path to read battery voltage.
     * (POWER_SUPPLY_PROP_VOLTAGE_NOW)
     */
    string batteryVoltagePath;
 
    /**
     * batteryTemperaturePath - file path to read battery temperature in tenths
     * of degree celcius. (POWER_SUPPLY_PROP_TEMP)
     */
    string batteryTemperaturePath;
 
    /**
     * batteryTechnologyPath - file path to read battery technology.
     * (POWER_SUPPLY_PROP_TECHNOLOGY)
     */
    string batteryTechnologyPath;
 
    /**
     * batteryCurrentNowPath - file path to read battery instantaneous current.
     * (POWER_SUPPLY_PROP_CURRENT_NOW)
     */
    string batteryCurrentNowPath;
 
    /**
     * batteryCurrentAvgPath - file path to read battery average current.
     * (POWER_SUPPLY_PROP_CURRENT_AVG)
     */
    string batteryCurrentAvgPath;
 
    /**
     * batteryChargeCounterPath - file path to read battery accumulated charge.
     * (POWER_SUPPLY_PROP_CHARGE_COUNTER)
     */
    string batteryChargeCounterPath;
 
    /**
     * batteryFullChargerPath - file path to read battery charge value when it
     * is considered to be full. (POWER_SUPPLY_PROP_CHARGE_FULL)
     */
    string batteryFullChargePath;
 
    /**
     * batteryCycleCountPath - file path to read battery charge cycle count.
     * (POWER_SUPPLY_PROP_CYCLE_COUNT)
     */
    string batteryCycleCountPath;
};
 
/**
 * The parameter to healthd mainloop update calls
 */
struct HealthInfo {
    /** AC charger state - 'true' if online */
    bool chargerAcOnline;
 
    /** USB charger state - 'true' if online */
    bool chargerUsbOnline;
 
    /** Wireless charger state - 'true' if online */
    bool chargerWirelessOnline;
 
    /** Maximum charging current supported by charger in uA */
    int32_t maxChargingCurrent;
 
    /** Maximum charging voltage supported by charger in uV */
    int32_t maxChargingVoltage;
 
    BatteryStatus batteryStatus;
 
    BatteryHealth batteryHealth;
 
    /** 'true' if battery is present */
    bool batteryPresent;
 
    /** Remaining battery capacity in percent */
    int32_t batteryLevel;
 
    /**
     * Instantaneous battery voltage in millivolts (mV).
     *
     * Historically, the unit of this field is microvolts (uV), but all
     * clients and implementations uses millivolts in practice, making it
     * the de-facto standard.
     */
    int32_t batteryVoltage;
 
    /** Instantaneous battery temperature in tenths of degree celcius */
    int32_t batteryTemperature;
 
    /** Instantaneous battery current in uA */
    int32_t batteryCurrent;
 
    /** Battery charge cycle count */
    int32_t batteryCycleCount;
 
    /** Battery charge value when it is considered to be "full" in uA-h */
    int32_t batteryFullCharge;
 
    /** Instantaneous battery capacity in uA-h */
    int32_t batteryChargeCounter;
 
    /** Battery technology, e.g. "Li-ion, Li-Poly" etc. */
    string batteryTechnology;
};