161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit BasicServicesKit 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ciimport { AsyncCallback, BusinessError, Callback } from './@ohos.base'; 2261847f8eSopenharmony_ci 2361847f8eSopenharmony_ci/** 2461847f8eSopenharmony_ci * Provides thermal level-related callback and query APIs to obtain the information required for 2561847f8eSopenharmony_ci * temperature control. The APIs are as follows: 2661847f8eSopenharmony_ci * {@link registerThermalLevelCallback}: subscribes to callbacks of thermal level changes. 2761847f8eSopenharmony_ci * {@link getLevel}: obtains the thermal level of the system in real time. 2861847f8eSopenharmony_ci * 2961847f8eSopenharmony_ci * @namespace thermal 3061847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 3161847f8eSopenharmony_ci * @since 8 3261847f8eSopenharmony_ci */ 3361847f8eSopenharmony_cideclare namespace thermal { 3461847f8eSopenharmony_ci /** 3561847f8eSopenharmony_ci * Enumerates the {@link ThermalLevel} types. 3661847f8eSopenharmony_ci * 3761847f8eSopenharmony_ci * @enum {number} 3861847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 3961847f8eSopenharmony_ci * @since 8 4061847f8eSopenharmony_ci */ 4161847f8eSopenharmony_ci export enum ThermalLevel { 4261847f8eSopenharmony_ci /** 4361847f8eSopenharmony_ci * The device is cool, and services are not restricted. 4461847f8eSopenharmony_ci * 4561847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 4661847f8eSopenharmony_ci * @since 8 4761847f8eSopenharmony_ci */ 4861847f8eSopenharmony_ci COOL = 0, 4961847f8eSopenharmony_ci /** 5061847f8eSopenharmony_ci * The device is operational but is not cool. You need to pay attention to its heating. 5161847f8eSopenharmony_ci * 5261847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 5361847f8eSopenharmony_ci * @since 8 5461847f8eSopenharmony_ci */ 5561847f8eSopenharmony_ci NORMAL = 1, 5661847f8eSopenharmony_ci /** 5761847f8eSopenharmony_ci * The device is warm. You need to stop or delay some imperceptible services. 5861847f8eSopenharmony_ci * 5961847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 6061847f8eSopenharmony_ci * @since 8 6161847f8eSopenharmony_ci */ 6261847f8eSopenharmony_ci WARM = 2, 6361847f8eSopenharmony_ci /** 6461847f8eSopenharmony_ci * The device is heating up. You need to stop all imperceptible services and downgrade 6561847f8eSopenharmony_ci * or reduce the load of other services. 6661847f8eSopenharmony_ci * 6761847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 6861847f8eSopenharmony_ci * @since 8 6961847f8eSopenharmony_ci */ 7061847f8eSopenharmony_ci HOT = 3, 7161847f8eSopenharmony_ci /** 7261847f8eSopenharmony_ci * The device is overheated. You need to stop all imperceptible services and downgrade 7361847f8eSopenharmony_ci * or reduce the load of major services. 7461847f8eSopenharmony_ci * 7561847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 7661847f8eSopenharmony_ci * @since 8 7761847f8eSopenharmony_ci */ 7861847f8eSopenharmony_ci OVERHEATED = 4, 7961847f8eSopenharmony_ci /** 8061847f8eSopenharmony_ci * The device is overheated and is about to enter the emergency state. You need to stop 8161847f8eSopenharmony_ci * all imperceptible services and downgrade major services to the maximum extent. 8261847f8eSopenharmony_ci * 8361847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 8461847f8eSopenharmony_ci * @since 8 8561847f8eSopenharmony_ci */ 8661847f8eSopenharmony_ci WARNING = 5, 8761847f8eSopenharmony_ci /** 8861847f8eSopenharmony_ci * The device has entered the emergency state. The supply of equipment resources has been 8961847f8eSopenharmony_ci * minimized, leaving only the basic functions available. 9061847f8eSopenharmony_ci * 9161847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 9261847f8eSopenharmony_ci * @since 8 9361847f8eSopenharmony_ci */ 9461847f8eSopenharmony_ci EMERGENCY = 6, 9561847f8eSopenharmony_ci /** 9661847f8eSopenharmony_ci * The device is about to enter a thermal escape state. All abilities will be forcibly 9761847f8eSopenharmony_ci * stopped, you need to implement escape measures. 9861847f8eSopenharmony_ci * 9961847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 10061847f8eSopenharmony_ci * @since 11 10161847f8eSopenharmony_ci */ 10261847f8eSopenharmony_ci ESCAPE = 7 10361847f8eSopenharmony_ci } 10461847f8eSopenharmony_ci 10561847f8eSopenharmony_ci /** 10661847f8eSopenharmony_ci * Subscribes to callbacks of thermal level changes. 10761847f8eSopenharmony_ci * 10861847f8eSopenharmony_ci * @param { AsyncCallback<ThermalLevel> } callback Callback of thermal level changes. Returns the thermal level. 10961847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 11061847f8eSopenharmony_ci * @since 8 11161847f8eSopenharmony_ci * @deprecated since 9 11261847f8eSopenharmony_ci * @useinstead thermal#registerThermalLevelCallback 11361847f8eSopenharmony_ci */ 11461847f8eSopenharmony_ci function subscribeThermalLevel(callback: AsyncCallback<ThermalLevel>): void; 11561847f8eSopenharmony_ci 11661847f8eSopenharmony_ci /** 11761847f8eSopenharmony_ci * Registers to callbacks of thermal level changes. 11861847f8eSopenharmony_ci * 11961847f8eSopenharmony_ci * @param { Callback<ThermalLevel> } callback Callback of thermal level changes. 12061847f8eSopenharmony_ci * this param is a function type. 12161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; 12261847f8eSopenharmony_ci * @throws { BusinessError } 4800101 - Failed to connect to the service. 12361847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 12461847f8eSopenharmony_ci * @since 9 12561847f8eSopenharmony_ci */ 12661847f8eSopenharmony_ci function registerThermalLevelCallback(callback: Callback<ThermalLevel>): void; 12761847f8eSopenharmony_ci 12861847f8eSopenharmony_ci /** 12961847f8eSopenharmony_ci * Unsubscribes from the callbacks of thermal level changes. 13061847f8eSopenharmony_ci * 13161847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback Callback of thermal level changes. 13261847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 13361847f8eSopenharmony_ci * @since 8 13461847f8eSopenharmony_ci * @deprecated since 9 13561847f8eSopenharmony_ci * @useinstead thermal#unregisterThermalLevelCallback 13661847f8eSopenharmony_ci */ 13761847f8eSopenharmony_ci function unsubscribeThermalLevel(callback?: AsyncCallback<void>): void; 13861847f8eSopenharmony_ci 13961847f8eSopenharmony_ci /** 14061847f8eSopenharmony_ci * Unregisters from the callbacks of thermal level changes. 14161847f8eSopenharmony_ci * 14261847f8eSopenharmony_ci * @param { Callback<void> } callback Callback of thermal level changes. 14361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types; 14461847f8eSopenharmony_ci * @throws { BusinessError } 4800101 - Failed to connect to the service. 14561847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 14661847f8eSopenharmony_ci * @since 9 14761847f8eSopenharmony_ci */ 14861847f8eSopenharmony_ci function unregisterThermalLevelCallback(callback?: Callback<void>): void; 14961847f8eSopenharmony_ci 15061847f8eSopenharmony_ci /** 15161847f8eSopenharmony_ci * Obtains the current thermal level. 15261847f8eSopenharmony_ci * 15361847f8eSopenharmony_ci * @returns { ThermalLevel } Returns the thermal level. 15461847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 15561847f8eSopenharmony_ci * @since 8 15661847f8eSopenharmony_ci * @deprecated since 9 15761847f8eSopenharmony_ci * @useinstead thermal#getLevel 15861847f8eSopenharmony_ci */ 15961847f8eSopenharmony_ci function getThermalLevel(): ThermalLevel; 16061847f8eSopenharmony_ci 16161847f8eSopenharmony_ci /** 16261847f8eSopenharmony_ci * Obtains the current thermal level. 16361847f8eSopenharmony_ci * 16461847f8eSopenharmony_ci * @returns { ThermalLevel } The thermal level. 16561847f8eSopenharmony_ci * @throws { BusinessError } 4800101 - Failed to connect to the service. 16661847f8eSopenharmony_ci * @syscap SystemCapability.PowerManager.ThermalManager 16761847f8eSopenharmony_ci * @since 9 16861847f8eSopenharmony_ci */ 16961847f8eSopenharmony_ci function getLevel(): ThermalLevel; 17061847f8eSopenharmony_ci} 17161847f8eSopenharmony_ciexport default thermal; 172