1 /* 2 * Copyright (c) 2022 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 #ifndef FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_BACKGROUND_TASK_MGR_HELPER_H 17 #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_BACKGROUND_TASK_MGR_HELPER_H 18 19 #include "background_task_subscriber.h" 20 21 namespace OHOS { 22 namespace BackgroundTaskMgr { 23 class BackgroundTaskMgrHelper { 24 public: 25 /** 26 * @brief Request service to keep running background 27 * 28 * @param taskParam Request params. 29 * @return ERR_OK if success, else fail. 30 */ 31 static ErrCode RequestStartBackgroundRunning(const ContinuousTaskParam &taskParam); 32 33 /** 34 * @brief Request service to stop running background 35 * 36 * @param abilityName Ability name of the requester ability 37 * @param abilityToken Ability token to mark an unique running ability instance 38 * @return ERR_OK if success, else fail. 39 */ 40 static ErrCode RequestStopBackgroundRunning(const std::string &abilityName, 41 const sptr<IRemoteObject> &abilityToken); 42 43 /** 44 * @brief Subscribes background task event. 45 * 46 * @param subscriber Subscriber token. 47 * @return ERR_OK if success, else fail. 48 */ 49 static ErrCode SubscribeBackgroundTask(const BackgroundTaskSubscriber &subscriber); 50 51 /** 52 * @brief Unsubscribes background task event. 53 * 54 * @param subscriber Subscriber token. 55 * @return ERR_OK if success, else fail. 56 */ 57 static ErrCode UnsubscribeBackgroundTask(const BackgroundTaskSubscriber &subscriber); 58 59 /** 60 * @brief Get transient task applications. 61 * @param list transient task apps. 62 * @return Returns ERR_OK if success, else failure. 63 */ 64 static ErrCode GetTransientTaskApps(std::vector<std::shared_ptr<TransientTaskAppInfo>> &list); 65 66 /** 67 * @brief Get all continuous task running infos. 68 * @param list continuous task infos. 69 * @return Returns ERR_OK if success, else failure. 70 */ 71 static ErrCode GetContinuousTaskApps(std::vector<std::shared_ptr<ContinuousTaskCallbackInfo>> &list); 72 73 /** 74 * @brief Get all effficiency resources running infos. 75 * @param appList EFficiency Resources infos of apps. 76 * @param procList EFficiency Resources infos of processes. 77 * @return Returns ERR_OK on success, others on failure. 78 */ 79 static ErrCode GetEfficiencyResourcesInfos(std::vector<std::shared_ptr<ResourceCallbackInfo>> &appList, 80 std::vector<std::shared_ptr<ResourceCallbackInfo>> &procList); 81 82 /** 83 * @brief Request stop continuous task. 84 * @param uid app uid. 85 * @param pid app pid. 86 * @param taskType continuous task type. 87 * @return Returns ERR_OK if success, else failure. 88 */ 89 static ErrCode StopContinuousTask(int32_t uid, int32_t pid, uint32_t taskType); 90 }; 91 } // namespace BackgroundTaskMgr 92 } // namespace OHOS 93 #endif // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_BACKGROUND_TASK_MGR_HELPER_H