Todd Poynor | 87bf0d9 | 2013-05-16 14:51:15 -0700 | [diff] [blame] | 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 ANDROID_BATTERYSERVICE_H |
| 18 | #define ANDROID_BATTERYSERVICE_H |
| 19 | |
| 20 | #include <binder/Parcel.h> |
Todd Poynor | a186e65 | 2014-05-08 16:04:22 -0700 | [diff] [blame] | 21 | #include <sys/types.h> |
Todd Poynor | 87bf0d9 | 2013-05-16 14:51:15 -0700 | [diff] [blame] | 22 | #include <utils/Errors.h> |
| 23 | #include <utils/String8.h> |
| 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | // must be kept in sync with definitions in BatteryManager.java |
| 28 | enum { |
| 29 | BATTERY_STATUS_UNKNOWN = 1, // equals BatteryManager.BATTERY_STATUS_UNKNOWN constant |
| 30 | BATTERY_STATUS_CHARGING = 2, // equals BatteryManager.BATTERY_STATUS_CHARGING constant |
| 31 | BATTERY_STATUS_DISCHARGING = 3, // equals BatteryManager.BATTERY_STATUS_DISCHARGING constant |
| 32 | BATTERY_STATUS_NOT_CHARGING = 4, // equals BatteryManager.BATTERY_STATUS_NOT_CHARGING constant |
| 33 | BATTERY_STATUS_FULL = 5, // equals BatteryManager.BATTERY_STATUS_FULL constant |
| 34 | }; |
| 35 | |
| 36 | // must be kept in sync with definitions in BatteryManager.java |
| 37 | enum { |
| 38 | BATTERY_HEALTH_UNKNOWN = 1, // equals BatteryManager.BATTERY_HEALTH_UNKNOWN constant |
| 39 | BATTERY_HEALTH_GOOD = 2, // equals BatteryManager.BATTERY_HEALTH_GOOD constant |
| 40 | BATTERY_HEALTH_OVERHEAT = 3, // equals BatteryManager.BATTERY_HEALTH_OVERHEAT constant |
| 41 | BATTERY_HEALTH_DEAD = 4, // equals BatteryManager.BATTERY_HEALTH_DEAD constant |
| 42 | BATTERY_HEALTH_OVER_VOLTAGE = 5, // equals BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE constant |
| 43 | BATTERY_HEALTH_UNSPECIFIED_FAILURE = 6, // equals BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE constant |
| 44 | BATTERY_HEALTH_COLD = 7, // equals BatteryManager.BATTERY_HEALTH_COLD constant |
| 45 | }; |
| 46 | |
Todd Poynor | cf80873 | 2013-08-14 17:23:37 -0700 | [diff] [blame] | 47 | // must be kept in sync with definitions in BatteryProperty.java |
| 48 | enum { |
Todd Poynor | a186e65 | 2014-05-08 16:04:22 -0700 | [diff] [blame] | 49 | BATTERY_PROP_CHARGE_COUNTER = 1, // equals BatteryProperty.CHARGE_COUNTER constant |
| 50 | BATTERY_PROP_CURRENT_NOW = 2, // equals BatteryProperty.CURRENT_NOW constant |
| 51 | BATTERY_PROP_CURRENT_AVG = 3, // equals BatteryProperty.CURRENT_AVG constant |
| 52 | BATTERY_PROP_CAPACITY = 4, // equals BatteryProperty.CAPACITY constant |
| 53 | BATTERY_PROP_ENERGY_COUNTER = 5, // equals BatteryProperty.ENERGY_COUNTER constant |
Todd Poynor | cf80873 | 2013-08-14 17:23:37 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
Todd Poynor | 87bf0d9 | 2013-05-16 14:51:15 -0700 | [diff] [blame] | 56 | struct BatteryProperties { |
| 57 | bool chargerAcOnline; |
| 58 | bool chargerUsbOnline; |
| 59 | bool chargerWirelessOnline; |
Adrian Roos | 687aa22 | 2015-07-10 13:08:28 -0700 | [diff] [blame] | 60 | int maxChargingCurrent; |
Todd Poynor | 87bf0d9 | 2013-05-16 14:51:15 -0700 | [diff] [blame] | 61 | int batteryStatus; |
| 62 | int batteryHealth; |
| 63 | bool batteryPresent; |
| 64 | int batteryLevel; |
| 65 | int batteryVoltage; |
Todd Poynor | 87bf0d9 | 2013-05-16 14:51:15 -0700 | [diff] [blame] | 66 | int batteryTemperature; |
Ruchi Kandoi | ec3198e | 2015-08-12 17:49:42 -0700 | [diff] [blame^] | 67 | int batteryCurrent; |
| 68 | int batteryCycleCount; |
| 69 | int batteryFullCharge; |
Todd Poynor | 87bf0d9 | 2013-05-16 14:51:15 -0700 | [diff] [blame] | 70 | String8 batteryTechnology; |
| 71 | |
| 72 | status_t writeToParcel(Parcel* parcel) const; |
| 73 | status_t readFromParcel(Parcel* parcel); |
| 74 | }; |
| 75 | |
Todd Poynor | cf80873 | 2013-08-14 17:23:37 -0700 | [diff] [blame] | 76 | struct BatteryProperty { |
Todd Poynor | a186e65 | 2014-05-08 16:04:22 -0700 | [diff] [blame] | 77 | int64_t valueInt64; |
Todd Poynor | cf80873 | 2013-08-14 17:23:37 -0700 | [diff] [blame] | 78 | |
| 79 | status_t writeToParcel(Parcel* parcel) const; |
| 80 | status_t readFromParcel(Parcel* parcel); |
| 81 | }; |
| 82 | |
Todd Poynor | 87bf0d9 | 2013-05-16 14:51:15 -0700 | [diff] [blame] | 83 | }; // namespace android |
| 84 | |
| 85 | #endif // ANDROID_BATTERYSERVICE_H |