• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 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 BackgroundTasksKit
19 */
20
21/**
22 * Declares the BackgroundProcessManager interfaces.
23 *
24 * @namespace backgroundProcessManager
25 * @syscap SystemCapability.Resourceschedule.BackgroundProcessManager
26 * @since 17
27 */
28declare namespace backgroundProcessManager {
29    /**
30     * Describes the level of BackgroundProcessManager priority.
31     *
32     * @enum { number }
33     * @syscap SystemCapability.Resourceschedule.BackgroundProcessManager
34     * @since 17
35     */
36    export enum ProcessPriority {
37        /**
38         * Means the process has stopped working and in the background
39         *
40         * @syscap SystemCapability.Resourceschedule.BackgroundProcessManager
41         * @since 17
42         */
43        PROCESS_BACKGROUND = 1,
44
45        /**
46         * Means the process is working in the background
47         *
48         * @syscap SystemCapability.Resourceschedule.BackgroundProcessManager
49         * @since 17
50         */
51        PROCESS_INACTIVE = 2,
52    }
53
54    /**
55     * Set the priority of process.
56     *
57     * @param { number } pid - Indicates the pid of the process to be set.
58     * @param { ProcessPriority } priority - Indicates the priority to set. Specific priority can be referenced ProcessPriority
59     * @returns { Promise<void> } The promise returned by the function.
60     * @throws { BusinessError } 401 - Parameter error. Possible causes: priority is out of range.
61     * @syscap SystemCapability.Resourceschedule.BackgroundProcessManager
62     * @since 17
63     */
64    function setProcessPriority(pid: number, priority: ProcessPriority): Promise<void>;
65
66    /**
67     * Reset the priority of process.
68     *
69     * @param { number } pid - Indicates the pid of the process to be reset.
70     * @returns { Promise<void> } The promise returned by the function.
71     * @syscap SystemCapability.Resourceschedule.BackgroundProcessManager
72     * @since 17
73     */
74    function resetProcessPriority(pid: number): Promise<void>;
75}
76
77export default backgroundProcessManager;
78