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_FRAMEWORKS_INCLUDE_IBACKGROUND_TASK_MGR_H 17 #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_FRAMEWORKS_INCLUDE_IBACKGROUND_TASK_MGR_H 18 19 #include <string> 20 21 #include <ipc_types.h> 22 #include <iremote_broker.h> 23 #include <nocopyable.h> 24 25 #include "bgtaskmgr_inner_errors.h" 26 #include "continuous_task_param.h" 27 #include "delay_suspend_info.h" 28 #include "iexpired_callback.h" 29 #include "ibackground_task_subscriber.h" 30 #include "want_agent.h" 31 32 namespace OHOS { 33 namespace BackgroundTaskMgr { 34 class IBackgroundTaskMgr : public IRemoteBroker { 35 public: 36 IBackgroundTaskMgr() = default; 37 ~IBackgroundTaskMgr() override = default; 38 DISALLOW_COPY_AND_MOVE(IBackgroundTaskMgr); 39 40 virtual ErrCode RequestSuspendDelay(const std::u16string& reason, 41 const sptr<IExpiredCallback>& callback, std::shared_ptr<DelaySuspendInfo> &delayInfo) = 0; 42 virtual ErrCode CancelSuspendDelay(int32_t requestId) = 0; 43 virtual ErrCode GetRemainingDelayTime(int32_t requestId, int32_t &delayTime) = 0; 44 virtual ErrCode StartBackgroundRunning(const sptr<ContinuousTaskParam> taskParam) = 0; 45 virtual ErrCode StopBackgroundRunning(const std::string &abilityName, const sptr<IRemoteObject> &abilityToken) = 0; 46 virtual ErrCode SubscribeBackgroundTask(const sptr<IBackgroundTaskSubscriber> &subscriber) = 0; 47 virtual ErrCode UnsubscribeBackgroundTask(const sptr<IBackgroundTaskSubscriber> &subscriber) = 0; 48 virtual ErrCode ShellDump(const std::vector<std::string> &dumpOption, std::vector<std::string> &dumpInfo) = 0; 49 50 public: 51 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.resourceschedule.IBackgroundTaskMgr"); 52 53 protected: 54 enum InterfaceId : uint32_t { 55 REQUEST_SUSPEND_DELAY = MIN_TRANSACTION_ID, 56 CANCEL_SUSPEND_DELAY, 57 GET_REMAINING_DELAY_TIME, 58 START_BACKGROUND_RUNNING, 59 STOP_BACKGROUND_RUNNING, 60 SUBSCRIBE_BACKGROUND_TASK, 61 UNSUBSCRIBE_BACKGROUND_TASK, 62 SHELL_DUMP, 63 }; 64 }; 65 } // namespace BackgroundTaskMgr 66 } // namespace OHOS 67 #endif // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_FRAMEWORKS_INCLUDE_IBACKGROUND_TASK_MGR_H