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_BACKGROUND_TASK_SUBSCRIBER_PROXY_H 17 #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_FRAMEWORKS_INCLUDE_BACKGROUND_TASK_SUBSCRIBER_PROXY_H 18 19 #include <iremote_proxy.h> 20 21 #include "ibackground_task_subscriber.h" 22 23 namespace OHOS { 24 namespace BackgroundTaskMgr { 25 class BackgroundTaskSubscriberProxy : public IRemoteProxy<IBackgroundTaskSubscriber> { 26 public: 27 BackgroundTaskSubscriberProxy() = delete; 28 explicit BackgroundTaskSubscriberProxy(const sptr<IRemoteObject>& impl); 29 ~BackgroundTaskSubscriberProxy() override; 30 DISALLOW_COPY_AND_MOVE(BackgroundTaskSubscriberProxy); 31 32 /** 33 * @brief Called back when the subscriber is connected to Background Task Manager Service. 34 */ 35 void OnConnected() override; 36 37 /** 38 * @brief Called back when the subscriber is disconnected from Background Task Manager Service. 39 */ 40 void OnDisconnected() override; 41 42 /** 43 * @brief Called back when a transient task start. 44 * 45 * @param info Transient task app info. 46 */ 47 void OnTransientTaskStart(const std::shared_ptr<TransientTaskAppInfo>& info) override; 48 49 /** 50 * @brief Called back when a transient task end. 51 * 52 * @param info Info of transient tasks. 53 */ 54 void OnTransientTaskEnd(const std::shared_ptr<TransientTaskAppInfo>& info) override; 55 56 /** 57 * @brief Called back when a transient task err. 58 * 59 * @param info Info of transient tasks. 60 */ 61 void OnTransientTaskErr(const std::shared_ptr<TransientTaskAppInfo>& info) override; 62 63 /** 64 * Called back when the app has transient task. 65 * 66 * @param info App info of transient task. 67 **/ 68 void OnAppTransientTaskStart(const std::shared_ptr<TransientTaskAppInfo>& info) override; 69 70 /** 71 * Called back when the app does not have transient task. 72 * 73 * @param info App info transient task . 74 **/ 75 void OnAppTransientTaskEnd(const std::shared_ptr<TransientTaskAppInfo>& info) override; 76 77 /** 78 * @brief Called back when a continuous task start. 79 * 80 * @param continuousTaskCallbackInfo Continuous task app info. 81 */ 82 void OnContinuousTaskStart( 83 const std::shared_ptr<ContinuousTaskCallbackInfo> &continuousTaskCallbackInfo) override; 84 85 /** 86 * @brief Called back when a continuous task update. 87 * 88 * @param continuousTaskCallbackInfo Continuous task app info. 89 */ 90 void OnContinuousTaskUpdate( 91 const std::shared_ptr<ContinuousTaskCallbackInfo> &continuousTaskCallbackInfo) override; 92 93 /** 94 * @brief Called back when a continuous task stop. 95 * 96 * @param continuousTaskCallbackInfo Continuous task app info. 97 */ 98 void OnContinuousTaskStop( 99 const std::shared_ptr<ContinuousTaskCallbackInfo> &continuousTaskCallbackInfo) override; 100 101 /** 102 * Called back when the app does not have continuous task. 103 * 104 * @param uid App uid. 105 **/ 106 void OnAppContinuousTaskStop(int32_t uid) override; 107 108 /** 109 * @brief Apply or unapply efficiency resources of App. 110 * 111 * @param resourceInfo Request params. 112 */ 113 void OnAppEfficiencyResourcesApply(const std::shared_ptr<ResourceCallbackInfo> &resourceInfo) override; 114 115 /** 116 * @brief Called back when the efficiency resources of App reset. 117 * 118 * @param resourceInfo Request params. 119 */ 120 void OnAppEfficiencyResourcesReset(const std::shared_ptr<ResourceCallbackInfo> &resourceInfo) override; 121 122 /** 123 * @brief Apply or unapply efficiency resources of process. 124 * 125 * @param resourceInfo Request params. 126 */ 127 void OnProcEfficiencyResourcesApply(const std::shared_ptr<ResourceCallbackInfo> &resourceInfo) override; 128 129 /** 130 * @brief Called back when the efficiency resources of process reset. 131 * 132 * @param resourceInfo Request params. 133 */ 134 void OnProcEfficiencyResourcesReset(const std::shared_ptr<ResourceCallbackInfo> &resourceInfo) override; 135 private: 136 static inline BrokerDelegator<BackgroundTaskSubscriberProxy> delegator_; 137 }; 138 } // namespace BackgroundTaskMgr 139 } // namespace OHOS 140 #endif // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_FRAMEWORKS_INCLUDE_BACKGROUND_TASK_SUBSCRIBER_PROXY_H