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