Yifan Hong | 4db762a | 2018-07-10 15:49:21 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 20 | using android::hardware::health::V2_0::IHealth; |
| 21 | using android::hardware::health::V2_0::implementation::Health; |
| 22 | |
| 23 | static 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 | |
| 40 | void healthd_board_init(struct healthd_config*) { |
| 41 | // use defaults |
| 42 | } |
| 43 | |
| 44 | int healthd_board_battery_update(struct android::BatteryProperties*) { |
| 45 | // return 0 to log periodic polled battery status to kernel log |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | extern "C" IHealth* HIDL_FETCH_IHealth(const char* name) { |
| 50 | const static std::string providedInstance{"backup"}; |
| 51 | |
| 52 | if (providedInstance == name) { |
| 53 | // use defaults |
| 54 | // Health class stores static instance |
| 55 | return Health::initInstance(&gHealthdConfig).get(); |
| 56 | } |
| 57 | return nullptr; |
| 58 | } |