1 /*
2 * Copyright (C) 2019 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 "healthd_mode_charger_nops.h"
18
19 #include <health2/Health.h>
20 #include <healthd/healthd.h>
21
22 #include <stdlib.h>
23 #include <string.h>
24
25 using namespace android;
26
27 // main healthd loop
28 extern int healthd_main(void);
29
30 // NOPs for modes that need no special action
31
32 static void healthd_mode_nop_init(struct healthd_config* config);
33 static int healthd_mode_nop_preparetowait(void);
34 static void healthd_mode_nop_heartbeat(void);
35 static void healthd_mode_nop_battery_update(struct android::BatteryProperties* props);
36
37 static struct healthd_mode_ops healthd_nops = {
38 .init = healthd_mode_nop_init,
39 .preparetowait = healthd_mode_nop_preparetowait,
40 .heartbeat = healthd_mode_nop_heartbeat,
41 .battery_update = healthd_mode_nop_battery_update,
42 };
43
healthd_mode_nop_init(struct healthd_config * config)44 static void healthd_mode_nop_init(struct healthd_config* config) {
45 using android::hardware::health::V2_0::implementation::Health;
46 Health::initInstance(config);
47 }
48
healthd_mode_nop_preparetowait(void)49 static int healthd_mode_nop_preparetowait(void) {
50 return -1;
51 }
52
healthd_mode_nop_heartbeat(void)53 static void healthd_mode_nop_heartbeat(void) {}
54
healthd_mode_nop_battery_update(struct android::BatteryProperties *)55 static void healthd_mode_nop_battery_update(struct android::BatteryProperties* /*props*/) {}
56
healthd_charger_nops(int,char **)57 int healthd_charger_nops(int /* argc */, char** /* argv */) {
58 healthd_mode_ops = &healthd_nops;
59 return healthd_main();
60 }
61