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 * @addtogroup BackgroundProcessManager 18 * @{ 19 * 20 * @brief BackgroundProcessManager provides APIs. 21 * 22 * @since 17 23 */ 24 25 /** 26 * @file background_process_manager.h 27 * 28 * @brief Declares the BackgroundProcessManager interfaces in C. 29 * 30 * BackgroundProcessManager refers to set or reset priority of process 31 * 32 * @library libbackground_process_manager.z.so 33 * @kit BackgroundTasksKit 34 * @syscap SystemCapability.Resourceschedule.BackgroundProcessManager 35 * @since 17 36 */ 37 38 #ifndef RESOURCESCHEDULE_BACKGROUND_PROCESS_MANAGER_H 39 #define RESOURCESCHEDULE_BACKGROUND_PROCESS_MANAGER_H 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 /** 46 * @brief Describes the level of BackgroundProcessManager priority. 47 * 48 * @since 17 49 */ 50 typedef enum BackgroundProcessManager_ProcessPriority { 51 /** 52 * @brief Means the process has stopped working and in the background 53 */ 54 PROCESS_BACKGROUND = 1, 55 56 /** 57 * @brief Means the process is working in the background 58 */ 59 PROCESS_INACTIVE = 2, 60 } BackgroundProcessManager_ProcessPriority; 61 62 /** 63 * @brief Enum for BackgroundProcessManager error code. 64 * 65 * @since 17 66 */ 67 typedef enum BackgroundProcessManager_ErrorCode { 68 /** 69 * @error result is OK. 70 */ 71 ERR_BACKGROUND_PROCESS_MANAGER_SUCCESS = 0, 72 73 /** 74 * @error invalid parameter. Possible causes: 75 * 1. priority is out of range. 76 */ 77 ERR_BACKGROUND_PROCESS_MANAGER_INVALID_PARAM = 401, 78 79 /** 80 * @error remote error. Possible causes: 81 * 1. remote is not work. 82 */ 83 ERR_BACKGROUND_PROCESS_MANAGER_REMOTE_ERROR = 31800001, 84 } BackgroundProcessManager_ErrorCode; 85 86 /** 87 * @brief Set the priority of process. 88 * 89 * @param pid Indicates the pid of the process to be set. 90 * @param priority Indicates the priority to be set. 91 Specific priority can be referenced {@link BackgroundProcessManager_ProcessPriority}. 92 * @return {@link ERR_BACKGROUND_PROCESS_MANAGER_SUCCESS} 0 - Success. 93 * {@link ERR_BACKGROUND_PROCESS_MANAGER_INVALID_PARAM} 401 - Parameter error. 94 * @since 17 95 */ 96 int OH_BackgroundProcessManager_SetProcessPriority(int pid, BackgroundProcessManager_ProcessPriority priority); 97 98 /** 99 * @brief Reset the priority of process. 100 * 101 * @param pid Indicates the pid of the process to be reset. 102 * @return {@link ERR_BACKGROUND_PROCESS_MANAGER_SUCCESS} 0 - Success. 103 * @since 17 104 */ 105 int OH_BackgroundProcessManager_ResetProcessPriority(int pid); 106 #ifdef __cplusplus 107 }; 108 #endif 109 #endif // RESOURCESCHEDULE_BACKGROUND_PROCESS_MANAGER_H 110 /** @} */ 111