blob: e3cbefdbebd5746a5395d23236bf2d394ad69f6a [file] [log] [blame]
Yifan Hong4db762a2018-07-10 15:49:21 -07001/*
2 * Copyright (C) 2018 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#include <health2/Health.h>
18#include <healthd/healthd.h>
19
20using android::hardware::health::V2_0::IHealth;
21using android::hardware::health::V2_0::implementation::Health;
22
23static struct healthd_config gHealthdConfig = {
24 .batteryStatusPath = android::String8(android::String8::kEmptyString),
25 .batteryHealthPath = android::String8(android::String8::kEmptyString),
26 .batteryPresentPath = android::String8(android::String8::kEmptyString),
27 .batteryCapacityPath = android::String8(android::String8::kEmptyString),
28 .batteryVoltagePath = android::String8(android::String8::kEmptyString),
29 .batteryTemperaturePath = android::String8(android::String8::kEmptyString),
30 .batteryTechnologyPath = android::String8(android::String8::kEmptyString),
31 .batteryCurrentNowPath = android::String8(android::String8::kEmptyString),
32 .batteryCurrentAvgPath = android::String8(android::String8::kEmptyString),
33 .batteryChargeCounterPath = android::String8(android::String8::kEmptyString),
34 .batteryFullChargePath = android::String8(android::String8::kEmptyString),
35 .batteryCycleCountPath = android::String8(android::String8::kEmptyString),
36 .energyCounter = nullptr,
37 .boot_min_cap = 0,
38 .screen_on = nullptr};
39
40void healthd_board_init(struct healthd_config*) {
41 // use defaults
42}
43
44int healthd_board_battery_update(struct android::BatteryProperties*) {
45 // return 0 to log periodic polled battery status to kernel log
46 return 0;
47}
48
Hridya Valsarajubf0b9fa2018-09-28 10:44:02 -070049void healthd_mode_default_impl_init(struct healthd_config*) {
50 // noop
51}
52
53int healthd_mode_default_impl_preparetowait(void) {
54 return -1;
55}
56
57void healthd_mode_default_impl_heartbeat(void) {
58 // noop
59}
60
61void healthd_mode_default_impl_battery_update(struct android::BatteryProperties*) {
62 // noop
63}
64
65static struct healthd_mode_ops healthd_mode_default_impl_ops = {
66 .init = healthd_mode_default_impl_init,
67 .preparetowait = healthd_mode_default_impl_preparetowait,
68 .heartbeat = healthd_mode_default_impl_heartbeat,
69 .battery_update = healthd_mode_default_impl_battery_update,
70};
71
Yifan Hong4db762a2018-07-10 15:49:21 -070072extern "C" IHealth* HIDL_FETCH_IHealth(const char* name) {
73 const static std::string providedInstance{"backup"};
Hridya Valsarajubf0b9fa2018-09-28 10:44:02 -070074 healthd_mode_ops = &healthd_mode_default_impl_ops;
Yifan Hong4db762a2018-07-10 15:49:21 -070075 if (providedInstance == name) {
76 // use defaults
77 // Health class stores static instance
78 return Health::initInstance(&gHealthdConfig).get();
79 }
80 return nullptr;
81}