1/* 2 * Copyright (c) 2023 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 battery 18 * @{ 19 * 20 * @brief Provides APIs for obtaining and subscribing to battery information. 21 * 22 * After obtaining an object or proxy of this module, the battery service can invoke related APIs to obtain and 23 * subscribe to battery information. 24 * 25 * @since 3.2 26 * @version 1.1 27 */ 28 29/** 30 * @file IBatteryInterface.idl 31 * 32 * @brief Provides APIs for obtaining and subscribing to battery information. 33 * 34 * After obtaining an object or proxy of this module, the battery service can invoke related APIs to obtain and 35 * subscribe to battery information. 36 * 37 * @since 3.2 38 * @version 1.1 39 */ 40package ohos.hdi.battery.v1_2; 41 42import ohos.hdi.battery.v1_2.Types; 43import ohos.hdi.battery.v1_2.IBatteryCallback; 44 45/** 46 * @brief Represents APIs for obtaining and subscribing to battery information. 47 * 48 * 49 * 50 * @since 3.1 51 */ 52interface IBatteryInterface { 53 /** 54 * @brief Registers the callback of battery information. 55 * 56 * @param event Callback to register. 57 * 58 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 59 * 60 * @since 3.1 61 */ 62 Register([in] IBatteryCallback event); 63 64 /** 65 * @brief Unregisters the callback of battery information. 66 * 67 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 68 * 69 * @since 3.1 70 */ 71 UnRegister(); 72 73 /** 74 * @brief Sets the path of the battery information node. 75 * 76 * @param path Path of the battery information node. 77 * 78 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 79 * 80 * @since 3.1 81 */ 82 ChangePath([in] String path); 83 84 /** 85 * @brief Obtains the battery percentage. 86 * 87 * @param capacity Battery percentage. 88 * 89 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 90 * 91 * @since 3.1 92 */ 93 GetCapacity([out] int capacity); 94 95 /** 96 * @brief Obtains the battery voltage. 97 * 98 * @param voltage Battery voltage, in microvolts. 99 * 100 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 101 * 102 * @since 3.1 103 */ 104 GetVoltage([out] int voltage); 105 106 /** 107 * @brief Obtains the battery temperature during charging. The unit is 0.1°C. 108 * 109 * @param temperature Battery temperature. 110 * 111 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 112 * 113 * @since 3.1 114 */ 115 GetTemperature([out] int temperature); 116 117 /** 118 * @brief Obtains the battery health status. 119 * 120 * @param healthState Battery health status. 121 * 122 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 123 * @see BatteryHealthState 124 * 125 * @since 3.1 126 */ 127 GetHealthState([out] enum BatteryHealthState healthState); 128 129 /** 130 * @brief Obtains the type of the charging device. 131 * 132 * @param pluggedType Type of the charging device. 133 * 134 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 135 * @see BatteryPluggedType 136 * 137 * @since 3.1 138 */ 139 GetPluggedType([out] enum BatteryPluggedType pluggedType); 140 141 /** 142 * @brief Obtains the charging status. 143 * 144 * @param chargeState Battery charging status. 145 * 146 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 147 * @see BatteryChargeState 148 * 149 * @since 3.1 150 */ 151 GetChargeState([out] enum BatteryChargeState chargeState); 152 153 /** 154 * @brief Checks whether the battery is supported or present. 155 * 156 * @param present Whether battery is supported or present. The value **true** indicates that the battery is 157 * supported or present, and the value **false** indicates the opposite. 158 * 159 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 160 * 161 * @since 3.1 162 */ 163 GetPresent([out] boolean present); 164 165 /** 166 * @brief Obtains the battery technology of the current device. 167 * 168 * @param technology Battery technology of the current device. 169 * 170 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 171 * 172 * @since 3.1 173 */ 174 GetTechnology([out] String technology); 175 176 /** 177 * @brief Obtains the total battery capacity. 178 * 179 * @param totalEnergy Total battery capacity, in mA. 180 * 181 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 182 * 183 * @since 3.1 184 */ 185 GetTotalEnergy([out] int totalEnergy); 186 187 /** 188 * @brief Obtains the average battery current. 189 * 190 * @param totalEnergy Average battery current, in mA. 191 * 192 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 193 * 194 * @since 3.1 195 */ 196 GetCurrentAverage([out] int curAverage); 197 198 /** 199 * @brief Obtains the battery current. 200 * 201 * @param curNow Battery current, in mA. 202 * 203 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 204 * 205 * @since 3.1 206 */ 207 GetCurrentNow([out] int curNow); 208 209 /** 210 * @brief Obtains the remaining battery capacity. 211 * 212 * @param remainEnergy Remaining battery capacity, in mA. 213 * 214 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 215 * 216 * @since 3.1 217 */ 218 GetRemainEnergy([out] int remainEnergy); 219 220 /** 221 * @brief Obtains all battery information. 222 * 223 * @param info Battery information. 224 * 225 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 226 * @see BatteryInfo 227 * 228 * @since 3.1 229 */ 230 GetBatteryInfo([out] struct BatteryInfo info); 231 232 /** 233 * @brief Sets a limit on the battery charging current or voltage. 234 * 235 * @param ChargingLimit Limit on the battery charging current or voltage. 236 * 237 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 238 * 239 * @since 3.2 240 */ 241 SetChargingLimit([in] struct ChargingLimit[] chargingLimit); 242 243 /** 244 * @brief Obtains the type of charger plugged-in. 245 * 246 * @param type Charge type 247 * 248 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 249 * 250 * @since 4.0 251 */ 252 GetChargeType([out] enum ChargeType type); 253 254 /** 255 * @brief set battery config by scene name 256 * 257 * @param sceneName battery charge scene name 258 * 259 * @param value battery config value 260 * 261 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 262 * 263 * @since 4.1 264 */ 265 SetBatteryConfig([in] String sceneName, [in] String value); 266 267 /** 268 * @brief get the battery config by scene name 269 * 270 * @param sceneName battery charge scene name 271 * 272 * @param value battery config value 273 * 274 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 275 * 276 * @since 4.1 277 */ 278 GetBatteryConfig([in] String sceneName, [out] String value); 279 280 /** 281 * @brief checks the battery config is enable by scene name 282 * 283 * @param sceneName battery charge scene name 284 * 285 * @param value the battery config is enable or not 286 * 287 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 288 * 289 * @since 4.1 290 */ 291 IsBatteryConfigSupported([in] String sceneName, [out] boolean value); 292} 293/** @} */ 294