• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 keep or stop running background for inner ability.
35      *
36      * @param taskParam Request params.
37      * @return ERR_OK if success, else fail.
38      */
39     static ErrCode RequestBackgroundRunningForInner(const ContinuousTaskParamForInner &taskParam);
40 
41     /**
42      * @brief Request service to stop running background
43      *
44      * @param abilityName Ability name of the requester ability
45      * @param abilityToken Ability token to mark an unique running ability instance
46      * @return ERR_OK if success, else fail.
47      */
48     static ErrCode RequestStopBackgroundRunning(const std::string &abilityName,
49         const sptr<IRemoteObject> &abilityToken);
50 
51     /**
52      * @brief Subscribes background task event.
53      *
54      * @param subscriber Subscriber token.
55      * @return ERR_OK if success, else fail.
56      */
57     static ErrCode SubscribeBackgroundTask(const BackgroundTaskSubscriber &subscriber);
58 
59     /**
60      * @brief Unsubscribes background task event.
61      *
62      * @param subscriber Subscriber token.
63      * @return ERR_OK if success, else fail.
64      */
65     static ErrCode UnsubscribeBackgroundTask(const BackgroundTaskSubscriber &subscriber);
66 
67     /**
68      * @brief Get transient task applications.
69      * @param list transient task apps.
70      * @return Returns ERR_OK if success, else failure.
71      */
72     static ErrCode GetTransientTaskApps(std::vector<std::shared_ptr<TransientTaskAppInfo>> &list);
73 
74     /**
75      * @brief Get all continuous task running infos.
76      * @param list continuous task infos.
77      * @return Returns ERR_OK if success, else failure.
78      */
79     static ErrCode GetContinuousTaskApps(std::vector<std::shared_ptr<ContinuousTaskCallbackInfo>> &list);
80 
81     /**
82      * @brief Get all effficiency resources running infos.
83      * @param appList EFficiency Resources infos of apps.
84      * @param procList  EFficiency Resources infos of processes.
85      * @return Returns ERR_OK on success, others on failure.
86      */
87     static ErrCode GetEfficiencyResourcesInfos(std::vector<std::shared_ptr<ResourceCallbackInfo>> &appList,
88         std::vector<std::shared_ptr<ResourceCallbackInfo>> &procList);
89 
90     /**
91      * @brief Request stop continuous task.
92      * @param uid app uid.
93      * @param pid app pid.
94      * @param taskType continuous task type.
95      * @return Returns ERR_OK if success, else failure.
96      */
97     static ErrCode StopContinuousTask(int32_t uid, int32_t pid, uint32_t taskType);
98 };
99 }  // namespace BackgroundTaskMgr
100 }  // namespace OHOS
101 #endif  // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_BACKGROUND_TASK_MGR_HELPER_H