• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   * @syscap SystemCapability.PowerManager.BatteryManager.Lite
32   * @since 3
33   * @deprecated since 6
34   */
35  charging: boolean;
36
37  /**
38   * Current battery level, which ranges from 0.00 to 1.00.
39   *
40   * @syscap SystemCapability.PowerManager.BatteryManager.Lite
41   * @since 3
42   * @deprecated since 6
43   */
44  level: number;
45}
46
47/**
48 * @interface GetStatusOptions
49 * @syscap SystemCapability.PowerManager.BatteryManager.Lite
50 * @since 3
51 * @deprecated since 6
52 */
53export interface GetStatusOptions {
54  /**
55   * Called when the current charging state and battery level are obtained.
56   *
57   * @syscap SystemCapability.PowerManager.BatteryManager.Lite
58   * @since 3
59   * @deprecated since 6
60   */
61  success?: (data: BatteryResponse) => void;
62
63  /**
64   * Called when the current charging state and battery level fail to be obtained.
65   *
66   * @syscap SystemCapability.PowerManager.BatteryManager.Lite
67   * @since 3
68   * @deprecated since 6
69   */
70  fail?: (data: string, code: number) => void;
71
72  /**
73   * Called when the execution is completed.
74   *
75   * @syscap SystemCapability.PowerManager.BatteryManager.Lite
76   * @since 3
77   * @deprecated since 6
78   */
79  complete?: () => void;
80}
81
82/**
83 * @syscap SystemCapability.PowerManager.BatteryManager.Lite
84 * @since 3
85 * @deprecated since 6
86 */
87export default class Battery {
88  /**
89   * Obtains the current charging state and battery level.
90   *
91   * @param { GetStatusOptions } options Options.
92   * @syscap SystemCapability.PowerManager.BatteryManager.Lite
93   * @since 3
94   * @deprecated since 6
95   */
96  static getStatus(options?: GetStatusOptions): void;
97}
98