• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 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
21import { AsyncCallback, BusinessError, Callback } from './@ohos.base';
22
23/**
24 * Provides thermal level-related callback and query APIs to obtain the information required for
25 * temperature control. The APIs are as follows:
26 * {@link registerThermalLevelCallback}: subscribes to callbacks of thermal level changes.
27 * {@link getLevel}: obtains the thermal level of the system in real time.
28 *
29 * @namespace thermal
30 * @syscap SystemCapability.PowerManager.ThermalManager
31 * @since 8
32 */
33declare namespace thermal {
34  /**
35   * Enumerates the {@link ThermalLevel} types.
36   *
37   * @enum {number}
38   * @syscap SystemCapability.PowerManager.ThermalManager
39   * @since 8
40   */
41  export enum ThermalLevel {
42    /**
43     * The device is cool, and services are not restricted.
44     *
45     * @syscap SystemCapability.PowerManager.ThermalManager
46     * @since 8
47     */
48    COOL = 0,
49    /**
50     * The device is operational but is not cool. You need to pay attention to its heating.
51     *
52     * @syscap SystemCapability.PowerManager.ThermalManager
53     * @since 8
54     */
55    NORMAL = 1,
56    /**
57     * The device is warm. You need to stop or delay some imperceptible services.
58     *
59     * @syscap SystemCapability.PowerManager.ThermalManager
60     * @since 8
61     */
62    WARM = 2,
63    /**
64     * The device is heating up. You need to stop all imperceptible services and downgrade
65     * or reduce the load of other services.
66     *
67     * @syscap SystemCapability.PowerManager.ThermalManager
68     * @since 8
69     */
70    HOT = 3,
71    /**
72     * The device is overheated. You need to stop all imperceptible services and downgrade
73     * or reduce the load of major services.
74     *
75     * @syscap SystemCapability.PowerManager.ThermalManager
76     * @since 8
77     */
78    OVERHEATED = 4,
79    /**
80     * The device is overheated and is about to enter the emergency state. You need to stop
81     * all imperceptible services and downgrade major services to the maximum extent.
82     *
83     * @syscap SystemCapability.PowerManager.ThermalManager
84     * @since 8
85     */
86    WARNING = 5,
87    /**
88     * The device has entered the emergency state. The supply of equipment resources has been
89     * minimized, leaving only the basic functions available.
90     *
91     * @syscap SystemCapability.PowerManager.ThermalManager
92     * @since 8
93     */
94    EMERGENCY = 6,
95    /**
96     * The device is about to enter a thermal escape state. All abilities will be forcibly
97     * stopped, you need to implement escape measures.
98     *
99     * @syscap SystemCapability.PowerManager.ThermalManager
100     * @since 11
101     */
102    ESCAPE = 7
103  }
104
105  /**
106   * Subscribes to callbacks of thermal level changes.
107   *
108   * @param { AsyncCallback<ThermalLevel> } callback Callback of thermal level changes. Returns the thermal level.
109   * @syscap SystemCapability.PowerManager.ThermalManager
110   * @since 8
111   * @deprecated since 9
112   * @useinstead thermal#registerThermalLevelCallback
113   */
114  function subscribeThermalLevel(callback: AsyncCallback<ThermalLevel>): void;
115
116  /**
117   * Registers to callbacks of thermal level changes.
118   *
119   * @param { Callback<ThermalLevel> } callback Callback of thermal level changes.
120   * this param is a function type.
121   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types;
122   * @throws { BusinessError } 4800101 - Failed to connect to the service.
123   * @syscap SystemCapability.PowerManager.ThermalManager
124   * @since 9
125   */
126  function registerThermalLevelCallback(callback: Callback<ThermalLevel>): void;
127
128  /**
129   * Unsubscribes from the callbacks of thermal level changes.
130   *
131   * @param { AsyncCallback<void> } callback Callback of thermal level changes.
132   * @syscap SystemCapability.PowerManager.ThermalManager
133   * @since 8
134   * @deprecated since 9
135   * @useinstead thermal#unregisterThermalLevelCallback
136   */
137  function unsubscribeThermalLevel(callback?: AsyncCallback<void>): void;
138
139  /**
140   * Unregisters from the callbacks of thermal level changes.
141   *
142   * @param { Callback<void> } callback Callback of thermal level changes.
143   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types;
144   * @throws { BusinessError } 4800101 - Failed to connect to the service.
145   * @syscap SystemCapability.PowerManager.ThermalManager
146   * @since 9
147   */
148  function unregisterThermalLevelCallback(callback?: Callback<void>): void;
149
150  /**
151   * Obtains the current thermal level.
152   *
153   * @returns { ThermalLevel } Returns the thermal level.
154   * @syscap SystemCapability.PowerManager.ThermalManager
155   * @since 8
156   * @deprecated since 9
157   * @useinstead thermal#getLevel
158   */
159  function getThermalLevel(): ThermalLevel;
160
161  /**
162   * Obtains the current thermal level.
163   *
164   * @returns { ThermalLevel } The thermal level.
165   * @throws { BusinessError } 4800101 - Failed to connect to the service.
166   * @syscap SystemCapability.PowerManager.ThermalManager
167   * @since 9
168   */
169  function getLevel(): ThermalLevel;
170}
171export default thermal;
172