• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 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
16import {AsyncCallback, BusinessError, Callback} from './basic';
17
18/**
19 * Provides thermal level-related callback and query APIs to obtain the information required for
20 * temperature control. The APIs are as follows:
21 * {@link registerThermalLevelCallback}: subscribes to callbacks of thermal level changes.
22 * {@link getLevel}: obtains the thermal level of the system in real time.
23 *
24 * @syscap SystemCapability.PowerManager.ThermalManager
25 * @since 8
26 */
27declare namespace thermal {
28    /**
29     * Enumerates the {@link ThermalLevel} types.
30     *
31     * @since 8
32     */
33    export enum ThermalLevel {
34        /**
35         * The device is cool, and services are not restricted.
36         */
37        COOL = 0,
38        /**
39         * The device is operational but is not cool. You need to pay attention to its heating.
40         */
41        NORMAL = 1,
42        /**
43         * The device is warm. You need to stop or delay some imperceptible services.
44         */
45        WARM = 2,
46        /**
47         * The device is heating up. You need to stop all imperceptible services and downgrade
48         * or reduce the load of other services.
49         */
50        HOT = 3,
51        /**
52         * The device is overheated. You need to stop all imperceptible services and downgrade
53         * or reduce the load of major services.
54         */
55        OVERHEATED = 4,
56        /**
57         * The device is overheated and is about to enter the emergency state. You need to stop
58         * all imperceptible services and downgrade major services to the maximum extent.
59         */
60        WARNING = 5,
61        /**
62         * The device has entered the emergency state. You need to stop all services except those
63         * for the emergency help purposes.
64         */
65        EMERGENCY = 6,
66    }
67
68    /**
69     * Subscribes to callbacks of thermal level changes.
70     *
71     * @param callback Callback of thermal level changes.
72     * @returns Returns the thermal level.
73     * @since 8
74     * @deprecated since 9
75     * @useinstead {@link thermal#registerThermalLevelCallback}
76     */
77    function subscribeThermalLevel(callback: AsyncCallback<ThermalLevel>): void;
78
79    /**
80     * Registers to callbacks of thermal level changes.
81     *
82     * @param {Callback<ThermalLevel>} callback Callback of thermal level changes.
83     * @throws {BusinessError} 401 - If callback is not valid.
84     * @throws {BusinessError} 4800101 If connecting to the service failed.
85     * @since 9
86     */
87    function registerThermalLevelCallback(callback: Callback<ThermalLevel>): void;
88
89    /**
90     * Unsubscribes from the callbacks of thermal level changes.
91     *
92     * @param callback Callback of thermal level changes.
93     * @since 8
94     * @deprecated since 9
95     * @useinstead {@link thermal#unregisterThermalLevelCallback}
96     */
97    function unsubscribeThermalLevel(callback?: AsyncCallback<void>): void;
98
99    /**
100     * Unregisters from the callbacks of thermal level changes.
101     *
102     * @param {Callback<void>} callback Callback of thermal level changes.
103     * @throws {BusinessError} 401 - If callback is not valid.
104     * @throws {BusinessError} 4800101 If connecting to the service failed.
105     * @since 9
106     */
107    function unregisterThermalLevelCallback(callback?: Callback<void>): void;
108
109    /**
110     * Obtains the current thermal level.
111     *
112     * @returns Returns the thermal level.
113     * @since 8
114     * @deprecated since 9
115     * @useinstead {@link thermal#getLevel}
116     */
117    function getThermalLevel(): ThermalLevel;
118
119    /**
120     * Obtains the current thermal level.
121     *
122     * @returns {ThermalLevel} The thermal level.
123     * @throws {BusinessError} 4800101 If connecting to the service failed.
124     * @since 9
125     */
126    function getLevel(): ThermalLevel;
127}
128export default thermal;
129