• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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 * Obtains battery information of a device.
18 *
19 * <p>Battery information includes the remaining battery power,
20 * voltage, temperature, model, and charger type.
21 *
22 * @syscap SystemCapability.PowerManager.BatteryManager.Core
23 * @since 6
24 */
25declare namespace batteryInfo {
26    /**
27     * Battery state of charge (SoC) of the current device, in percent.
28     * @since 6
29     */
30    const batterySOC: number;
31
32    /**
33     * Battery charging status of the current device.
34     * @since 6
35     */
36    const chargingStatus: BatteryChargeState;
37
38    /**
39     * Battery health state of the current device.
40     * @since 6
41     */
42    const healthStatus: BatteryHealthState;
43
44    /**
45     * Charger type of the current device.
46     * @since 6
47     */
48    const pluggedType: BatteryPluggedType;
49
50    /**
51     * Battery voltage of the current device, in µV.
52     * @since 6
53     */
54    const voltage: number;
55
56    /**
57     * Battery technology of the current device.
58     * @since 6
59     */
60    const technology: string;
61
62    /**
63     * Battery temperature of the current device, in 0.1℃.
64     * @since 6
65     */
66    const batteryTemperature: number;
67
68    /**
69     * Battery present state of the current device.
70     * @since 7
71     */
72    const isBatteryPresent: boolean;
73
74    /**
75     * Indicates the charger type of a device.
76     *
77     * @syscap SystemCapability.PowerManager.BatteryManager.Core
78     * @since 6
79     */
80    export enum BatteryPluggedType {
81        /**
82         * Unknown type
83         * @since 6
84         */
85        NONE,
86        /**
87         * AC charger
88         * @since 6
89         */
90        AC,
91        /**
92         * USB charger
93         * @since 6
94         */
95        USB,
96        /**
97         * Wireless charger
98         * @since 6
99         */
100        WIRELESS
101    }
102
103    /**
104     * Indicates the battery charging status of a device.
105     *
106     * @syscap SystemCapability.PowerManager.BatteryManager.Core
107     * @since 6
108     */
109    export enum BatteryChargeState {
110        /**
111         * Unknown state.
112         * @since 6
113         */
114        NONE,
115        /**
116         * The battery is being charged.
117         * @since 6
118         */
119        ENABLE,
120        /**
121         * The battery is not being charged.
122         * @since 6
123         */
124        DISABLE,
125        /**
126         * The battery is fully charged.
127         * @since 6
128         */
129        FULL
130    }
131
132    /**
133     * Indicates the battery health status of a device.
134     *
135     * @syscap SystemCapability.PowerManager.BatteryManager.Core
136     * @since 6
137     */
138    export enum BatteryHealthState {
139        /**
140         * Unknown state.
141         * @since 6
142         */
143        UNKNOWN,
144        /**
145         * The battery is in healthy state.
146         * @since 6
147         */
148        GOOD,
149        /**
150         * The battery is overheated.
151         * @since 6
152         */
153        OVERHEAT,
154        /**
155         * The battery voltage is over high.
156         * @since 6
157         */
158        OVERVOLTAGE,
159        /**
160         * The battery temperature is low.
161         * @since 6
162         */
163        COLD,
164        /**
165         * The battery is dead.
166         * @since 6
167         */
168        DEAD
169    }
170}
171export default batteryInfo;
172
173