1 /* 2 * Copyright (c) 2024 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 ACCESS_BACKGROUND_TASK_MANAGER_ACCESS_PROXY_H 17 #define ACCESS_BACKGROUND_TASK_MANAGER_ACCESS_PROXY_H 18 19 #include <iremote_proxy.h> 20 21 #include "continuous_task_callback_info.h" 22 #include "service_ipc_interface_code.h" 23 24 namespace OHOS { 25 namespace Security { 26 namespace AccessToken { 27 class IBackgroundTaskSubscriber : public IRemoteBroker { 28 public: 29 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.resourceschedule.IBackgroundTaskSubscriber"); 30 31 virtual void OnContinuousTaskStart( 32 const std::shared_ptr<ContinuousTaskCallbackInfo> &continuousTaskCallbackInfo) = 0; 33 34 virtual void OnContinuousTaskStop( 35 const std::shared_ptr<ContinuousTaskCallbackInfo> &continuousTaskCallbackInfo) = 0; 36 37 enum class Message { 38 ON_CONTINUOUS_TASK_START = 7, 39 ON_CONTINUOUS_TASK_STOP = 9, 40 }; 41 }; 42 43 class IBackgroundTaskMgr : public IRemoteBroker { 44 public: 45 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.resourceschedule.IBackgroundTaskMgr"); 46 47 virtual int32_t SubscribeBackgroundTask(const sptr<IBackgroundTaskSubscriber> &subscriber) = 0; 48 virtual int32_t UnsubscribeBackgroundTask(const sptr<IBackgroundTaskSubscriber> &subscriber) = 0; 49 virtual int32_t GetContinuousTaskApps(std::vector<std::shared_ptr<ContinuousTaskCallbackInfo>> &list) = 0; 50 51 enum class Message { 52 SUBSCRIBE_BACKGROUND_TASK = 7, 53 UNSUBSCRIBE_BACKGROUND_TASK = 8, 54 GET_CONTINUOUS_TASK_APPS = 10, 55 }; 56 }; 57 58 class BackgroundTaskManagerAccessProxy : public IRemoteProxy<IBackgroundTaskMgr> { 59 public: BackgroundTaskManagerAccessProxy(const sptr<IRemoteObject> & impl)60 explicit BackgroundTaskManagerAccessProxy( 61 const sptr<IRemoteObject>& impl) : IRemoteProxy<IBackgroundTaskMgr>(impl) {} 62 63 virtual ~BackgroundTaskManagerAccessProxy() = default; 64 65 int32_t SubscribeBackgroundTask(const sptr<IBackgroundTaskSubscriber>& subscriber) override; 66 int32_t UnsubscribeBackgroundTask(const sptr<IBackgroundTaskSubscriber>& subscriber) override; 67 int32_t GetContinuousTaskApps(std::vector<std::shared_ptr<ContinuousTaskCallbackInfo>> &list) override; 68 private: 69 static inline BrokerDelegator<BackgroundTaskManagerAccessProxy> delegator_; 70 }; 71 } // namespace AccessToken 72 } // namespace Security 73 } // namespace OHOS 74 #endif // ACCESS_BACKGROUND_TASK_MANAGER_ACCESS_PROXY_H 75