1/* 2 * Copyright (c) 2022-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 * @file 18 * @kit BasicServicesKit 19 */ 20 21/** 22 * @interface BatteryResponse 23 * @syscap SystemCapability.PowerManager.BatteryManager.Lite 24 * @since 3 25 * @deprecated since 6 26 */ 27export interface BatteryResponse { 28 /** 29 * Whether the battery is being charged. 30 * 31 * @type { boolean } 32 * @syscap SystemCapability.PowerManager.BatteryManager.Lite 33 * @since 3 34 * @deprecated since 6 35 */ 36 charging: boolean; 37 38 /** 39 * Current battery level, which ranges from 0.00 to 1.00. 40 * 41 * @type { number } 42 * @syscap SystemCapability.PowerManager.BatteryManager.Lite 43 * @since 3 44 * @deprecated since 6 45 */ 46 level: number; 47} 48 49/** 50 * @interface GetStatusOptions 51 * @syscap SystemCapability.PowerManager.BatteryManager.Lite 52 * @since 3 53 * @deprecated since 6 54 */ 55export interface GetStatusOptions { 56 /** 57 * Called when the current charging state and battery level are obtained. 58 * 59 * @type { ?function } 60 * @syscap SystemCapability.PowerManager.BatteryManager.Lite 61 * @since 3 62 * @deprecated since 6 63 */ 64 success?: (data: BatteryResponse) => void; 65 66 /** 67 * Called when the current charging state and battery level fail to be obtained. 68 * 69 * @type { ?function } 70 * @syscap SystemCapability.PowerManager.BatteryManager.Lite 71 * @since 3 72 * @deprecated since 6 73 */ 74 fail?: (data: string, code: number) => void; 75 76 /** 77 * Called when the execution is completed. 78 * 79 * @type { ?function } 80 * @syscap SystemCapability.PowerManager.BatteryManager.Lite 81 * @since 3 82 * @deprecated since 6 83 */ 84 complete?: () => void; 85} 86 87/** 88 * @syscap SystemCapability.PowerManager.BatteryManager.Lite 89 * @since 3 90 * @deprecated since 6 91 */ 92export default class Battery { 93 /** 94 * Obtains the current charging state and battery level. 95 * 96 * @param { GetStatusOptions } options Options. 97 * @syscap SystemCapability.PowerManager.BatteryManager.Lite 98 * @since 3 99 * @deprecated since 6 100 */ 101 static getStatus(options?: GetStatusOptions): void; 102} 103