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