1/* 2 * Copyright (c) 2020 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 16export interface BatteryResponse { 17 /** 18 * Whether the battery is being charged. 19 * @since 3 20 */ 21 charging: boolean; 22 23 /** 24 * Current battery level, which ranges from 0.00 to 1.00. 25 * @since 3 26 */ 27 level: number; 28} 29 30/** 31 * @Syscap SysCap.ACE.UIEngine 32 */ 33export default class Battery { 34 /** 35 * Obtains the battery level of the current device. 36 * @param options 37 */ 38 static getStatus(options?: { 39 /** 40 * Called when the current charging state and battery level are obtained. 41 * @since 3 42 */ 43 success?: (data: BatteryResponse) => void; 44 45 /** 46 * Called when the current charging state and battery level fail to be obtained. 47 * @since 3 48 */ 49 fail?: (data: any, code: number) => void; 50 51 /** 52 * Called when the execution is completed. 53 * @since 3 54 */ 55 complete?: () => void; 56 }): void; 57} 58