1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup OH_BatteryInfo 18 * @{ 19 * 20 * @brief Provides the definition of the C interface for the BatteryInfo module. 21 * 22 * @syscap SystemCapability.PowerManager.BatteryManager.Core 23 * @since 13 24 * @version 1.0 25 */ 26 /** 27 * @file ohbattery_info.h 28 * 29 * @brief Declares the APIs to get informations about the current battery capacity and the power source type, 30 * defines strings that identify corresponding common events. 31 * 32 * @library libohbattery_info.so 33 * @kit BasicServicesKit 34 * @syscap SystemCapability.PowerManager.BatteryManager.Core 35 * @since 13 36 * @version 1.0 37 */ 38 #ifndef OHBATTERY_INFO_HEADER 39 #define OHBATTERY_INFO_HEADER 40 41 #include <stdint.h> 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif /* __cplusplus */ 46 47 /** 48 * @brief A string that identifies the common event sent after battery capacity changes. 49 * @since 13 50 * @version 1.0 51 */ 52 static const char* COMMON_EVENT_KEY_CAPACITY = "soc"; 53 /** 54 * @brief A string that identifies the common event sent after charge state changes. 55 * @since 13 56 * @version 1.0 57 */ 58 static const char* COMMON_EVENT_KEY_CHARGE_STATE = "chargeState"; 59 /** 60 * @brief A string that identifies the common event sent after plugged type changes. 61 * @since 13 62 * @version 1.0 63 */ 64 static const char* COMMON_EVENT_KEY_PLUGGED_TYPE = "pluggedType"; 65 66 /** 67 * @brief Defines plugged types. 68 * 69 * @since 13 70 * @version 1.0 71 */ 72 typedef enum { 73 /** 74 * Power source is unplugged. 75 */ 76 PLUGGED_TYPE_NONE, 77 78 /** 79 * Power source is an AC charger. 80 */ 81 PLUGGED_TYPE_AC, 82 83 /** 84 * Power source is a USB DC charger. 85 */ 86 PLUGGED_TYPE_USB, 87 88 /** 89 * Power source is wireless charger. 90 */ 91 PLUGGED_TYPE_WIRELESS, 92 93 /** 94 * The bottom of the enum. 95 */ 96 PLUGGED_TYPE_BUTT 97 } BatteryInfo_BatteryPluggedType; 98 99 /** 100 * @brief This API returns the current battery capacity. 101 * 102 * @return Returns number betweem 0 and 100. 103 * @syscap SystemCapability.PowerManager.BatteryManager.Core 104 * @since 13 105 */ 106 int32_t OH_BatteryInfo_GetCapacity(); 107 108 /** 109 * @brief This API returns the current plugged type. 110 * 111 * @return {@link BatteryInfo_BatteryPluggedType#PLUGGED_TYPE_NONE} if the power source is unplugged. 112 * {@link PLUGGED_TYPE_AC} if the power source is an AC charger. 113 * {@link PLUGGED_TYPE_USB} if the power source is an USB DC charger. 114 * {@link PLUGGED_TYPE_WIRELESS} if the power source is wireless charger. 115 * {@link PLUGGED_TYPE_BUTT} if the type is unknown. 116 * @syscap SystemCapability.PowerManager.BatteryManager.Core 117 * @since 13 118 */ 119 BatteryInfo_BatteryPluggedType OH_BatteryInfo_GetPluggedType(); 120 #ifdef __cplusplus 121 } 122 #endif /* __cplusplus */ 123 #endif /* OHBATTERY_INFO_HEADER */ 124 /** @} */ 125