• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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 type { Callback } from './@ohos.base';
22
23/**
24 * This module provides the capability to get systemLoad.
25 *
26 * @namespace systemLoad
27 * @syscap SystemCapability.ResourceSchedule.SystemLoad
28 * @since 12
29 */
30declare namespace systemLoad {
31    /**
32     * Enumerates the {@link SystemLoadLevel} types.
33     *
34     * @enum {number}
35     * @syscap SystemCapability.ResourceSchedule.SystemLoad
36     * @since 12
37     */
38    export enum SystemLoadLevel {
39        /**
40         * level low
41         *
42         * @syscap SystemCapability.ResourceSchedule.SystemLoad
43         * @since 12
44         */
45        LOW = 0,
46        /**
47         * level NORMAL
48         *
49         * @syscap SystemCapability.ResourceSchedule.SystemLoad
50         * @since 12
51         */
52        NORMAL = 1,
53        /**
54         * level MEDIUM
55         *
56         * @syscap SystemCapability.ResourceSchedule.SystemLoad
57         * @since 12
58         */
59        MEDIUM = 2,
60        /**
61         * level HIGH
62         *
63         * @syscap SystemCapability.ResourceSchedule.SystemLoad
64         * @since 12
65         */
66        HIGH = 3,
67        /**
68         * level OVERHEATED
69         *
70         * @syscap SystemCapability.ResourceSchedule.SystemLoad
71         * @since 12
72         */
73        OVERHEATED = 4,
74        /**
75         * level WARNING
76         *
77         * @syscap SystemCapability.ResourceSchedule.SystemLoad
78         * @since 12
79         */
80        WARNING = 5,
81        /**
82         * level EMERGENCY
83         *
84         * @syscap SystemCapability.ResourceSchedule.SystemLoad
85         * @since 12
86         */
87        EMERGENCY = 6,
88        /**
89         * level ESCAPE
90         *
91         * @syscap SystemCapability.ResourceSchedule.SystemLoad
92         * @since 12
93         */
94        ESCAPE = 7
95    }
96
97    /**
98     * Register system load callback for perception system load change
99     * @param { 'systemLoadChange' } type system load change type.
100     * @param { Callback<SystemLoadLevel> } callback Asynchronous callback interface.
101     * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Callback parameter error;
102     * <br> 2. Register a exist callback type; 3. Parameter verification failed.
103     * @syscap SystemCapability.ResourceSchedule.SystemLoad
104     * @since 12
105     */
106    function on(type: 'systemLoadChange', callback: Callback<SystemLoadLevel>): void;
107
108    /**
109     * Unregister system load callback for perception system load change
110     * @param { 'systemLoadChange' } type system load change type.
111     * @param { Callback<SystemLoadLevel> } callback Asynchronous callback interface.
112     * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Callback parameter error;
113     * <br> 2. Unregister type has not register; 3. Parameter verification failed.
114     * @syscap SystemCapability.ResourceSchedule.SystemLoad
115     * @since 12
116     */
117    function off(type: 'systemLoadChange', callback?: Callback<SystemLoadLevel>): void;
118
119    /**
120     * @returns { Promise<SystemLoadLevel> } The promise form returns the SystemLoadLevel result
121     * Queries the current system level
122     * @syscap SystemCapability.ResourceSchedule.SystemLoad
123     * @since 12
124     */
125    function getLevel(): Promise<SystemLoadLevel>;
126}
127export default systemLoad;