healthd.h revision bc102111845a48f79a4cf6ea058a0ca334cd613c
1/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _HEALTHD_H_
18#define _HEALTHD_H_
19
20#include <batteryservice/BatteryService.h>
21#include <utils/String8.h>
22
23// periodic_chores_interval_fast, periodic_chores_interval_slow: intervals at
24// which healthd wakes up to poll health state and perform periodic chores,
25// in units of seconds:
26//
27//    periodic_chores_interval_fast is used while the device is not in
28//    suspend, or in suspend and connected to a charger (to watch for battery
29//    overheat due to charging).  The default value is 60 (1 minute).  Value
30//    -1 turns off periodic chores (and wakeups) in these conditions.
31//
32//    periodic_chores_interval_slow is used when the device is in suspend and
33//    not connected to a charger (to watch for a battery drained to zero
34//    remaining capacity).  The default value is 600 (10 minutes).  Value -1
35//    tuns off periodic chores (and wakeups) in these conditions.
36//
37// power_supply sysfs attribute file paths.  Set these to specific paths
38// to use for the associated battery parameters.  healthd will search for
39// appropriate power_supply attribute files to use for any paths left empty:
40//
41//    batteryStatusPath: charging status (POWER_SUPPLY_PROP_STATUS)
42//    batteryHealthPath: battery health (POWER_SUPPLY_PROP_HEALTH)
43//    batteryPresentPath: battery present (POWER_SUPPLY_PROP_PRESENT)
44//    batteryCapacityPath: remaining capacity (POWER_SUPPLY_PROP_CAPACITY)
45//    batteryVoltagePath: battery voltage (POWER_SUPPLY_PROP_VOLTAGE_NOW)
46//    batteryTemperaturePath: battery temperature (POWER_SUPPLY_PROP_TEMP)
47//    batteryTechnologyPath: battery technology (POWER_SUPPLY_PROP_TECHNOLOGY)
48//    batteryCurrentNowPath: battery current (POWER_SUPPLY_PROP_CURRENT_NOW)
49//    batteryChargeCounterPath: battery accumulated charge
50//                                         (POWER_SUPPLY_PROP_CHARGE_COUNTER)
51
52struct healthd_config {
53    int periodic_chores_interval_fast;
54    int periodic_chores_interval_slow;
55
56    android::String8 batteryStatusPath;
57    android::String8 batteryHealthPath;
58    android::String8 batteryPresentPath;
59    android::String8 batteryCapacityPath;
60    android::String8 batteryVoltagePath;
61    android::String8 batteryTemperaturePath;
62    android::String8 batteryTechnologyPath;
63    android::String8 batteryCurrentNowPath;
64    android::String8 batteryCurrentAvgPath;
65    android::String8 batteryChargeCounterPath;
66};
67
68// The following are implemented in libhealthd_board to handle board-specific
69// behavior.
70//
71// healthd_board_init() is called at startup time to modify healthd's
72// configuration according to board-specific requirements.  config
73// points to the healthd configuration values described above.  To use default
74// values, this function can simply return without modifying the fields of the
75// config parameter.
76
77void healthd_board_init(struct healthd_config *config);
78
79// Process updated battery property values.  This function is called when
80// the kernel sends updated battery status via a uevent from the power_supply
81// subsystem, or when updated values are polled by healthd, as for periodic
82// poll of battery state.
83//
84// props are the battery properties read from the kernel.  These values may
85// be modified in this call, prior to sending the modified values to the
86// Android runtime.
87//
88// Return 0 to indicate the usual kernel log battery status heartbeat message
89// is to be logged, or non-zero to prevent logging this information.
90
91int healthd_board_battery_update(struct android::BatteryProperties *props);
92
93#endif /* _HEALTHD_H_ */
94