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 * request service to keep running background 27 * 28 * @param taskParam request params. 29 * @return Returns ERR_OK on success, others on failure. 30 */ 31 static ErrCode RequestStartBackgroundRunning(const ContinuousTaskParam &taskParam); 32 33 /** 34 * 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 Returns ERR_OK on success, others on failure. 39 */ 40 static ErrCode RequestStopBackgroundRunning(const std::string &abilityName, 41 const sptr<IRemoteObject> &abilityToken); 42 43 /** 44 * Subscribes background task event. 45 * 46 * @param subscriber subscriber token. 47 * @return Returns ERR_OK on success, others on failure. 48 */ 49 static ErrCode SubscribeBackgroundTask(const BackgroundTaskSubscriber &subscriber); 50 51 /** 52 * Unsubscribes background task event. 53 * 54 * @param subscriber subscriber token. 55 * @return Returns ERR_OK on success, others on failure. 56 */ 57 static ErrCode UnsubscribeBackgroundTask(const BackgroundTaskSubscriber &subscriber); 58 }; 59 } // namespace BackgroundTaskMgr 60 } // namespace OHOS 61 #endif // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_BACKGROUND_TASK_MGR_HELPER_H