• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
23 namespace OHOS {
24 namespace Security {
25 namespace AccessToken {
26 class IBackgroundTaskSubscriber : public IRemoteBroker {
27 public:
28     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.BackgroundTaskMgr.IBackgroundTaskSubscriber");
29 
30     virtual void OnContinuousTaskStart(
31         const std::shared_ptr<ContinuousTaskCallbackInfo> &continuousTaskCallbackInfo) = 0;
32 
33     virtual void OnContinuousTaskStop(
34         const std::shared_ptr<ContinuousTaskCallbackInfo> &continuousTaskCallbackInfo) = 0;
35 
36     enum class Message {
37         ON_CONTINUOUS_TASK_START = 7,
38         ON_CONTINUOUS_TASK_STOP = 9,
39     };
40 };
41 
42 class IBackgroundTaskMgr : public IRemoteBroker {
43 public:
44     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.BackgroundTaskMgr.IBackgroundTaskMgr");
45 
46     virtual int32_t SubscribeBackgroundTask(const sptr<IBackgroundTaskSubscriber> &subscriber) = 0;
47     virtual int32_t UnsubscribeBackgroundTask(const sptr<IBackgroundTaskSubscriber> &subscriber) = 0;
48     virtual int32_t GetContinuousTaskApps(std::vector<std::shared_ptr<ContinuousTaskCallbackInfo>> &list) = 0;
49 
50     enum class Message {
51         SUBSCRIBE_BACKGROUND_TASK = 10,
52         UNSUBSCRIBE_BACKGROUND_TASK = 11,
53         GET_CONTINUOUS_TASK_APPS = 13,
54     };
55 };
56 
57 class BackgroundTaskManagerAccessProxy : public IRemoteProxy<IBackgroundTaskMgr> {
58 public:
BackgroundTaskManagerAccessProxy(const sptr<IRemoteObject> & impl)59     explicit BackgroundTaskManagerAccessProxy(
60         const sptr<IRemoteObject>& impl) : IRemoteProxy<IBackgroundTaskMgr>(impl) {}
61 
62     virtual ~BackgroundTaskManagerAccessProxy() = default;
63 
64     int32_t SubscribeBackgroundTask(const sptr<IBackgroundTaskSubscriber>& subscriber) override;
65     int32_t UnsubscribeBackgroundTask(const sptr<IBackgroundTaskSubscriber>& subscriber) override;
66     int32_t GetContinuousTaskApps(std::vector<std::shared_ptr<ContinuousTaskCallbackInfo>> &list) override;
67 private:
68     static inline BrokerDelegator<BackgroundTaskManagerAccessProxy> delegator_;
69 };
70 } // namespace AccessToken
71 } // namespace Security
72 } // namespace OHOS
73 #endif // ACCESS_BACKGROUND_TASK_MANAGER_ACCESS_PROXY_H
74