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 * Called back when the app has transient task. 64 * 65 * @param info App info of transient task. 66 **/ 67 virtual void OnAppTransientTaskStart(const std::shared_ptr<TransientTaskAppInfo>& info) = 0; 68 69 /** 70 * Called back when the app does not have transient task. 71 * 72 * @param info App info transient task . 73 **/ 74 virtual void OnAppTransientTaskEnd(const std::shared_ptr<TransientTaskAppInfo>& info) = 0; 75 76 /** 77 * @brief Called back when a continuous task start. 78 * 79 * @param continuousTaskCallbackInfo Continuous task app info. 80 */ 81 virtual void OnContinuousTaskStart( 82 const std::shared_ptr<ContinuousTaskCallbackInfo> &continuousTaskCallbackInfo) = 0; 83 84 /** 85 * @brief Called back when a continuous task stop. 86 * 87 * @param continuousTaskCallbackInfo Continuous task app info. 88 */ 89 virtual void OnContinuousTaskStop( 90 const std::shared_ptr<ContinuousTaskCallbackInfo> &continuousTaskCallbackInfo) = 0; 91 92 /** 93 * Called back when the app does not have continuous task. 94 * 95 * @param uid App uid. 96 **/ 97 virtual void OnAppContinuousTaskStop(int32_t uid) = 0; 98 99 /** 100 * @brief Apply or unapply efficiency resources of App. 101 * 102 * @param resourceInfo Request params. 103 */ 104 virtual void OnAppEfficiencyResourcesApply( 105 const std::shared_ptr<ResourceCallbackInfo> &resourceInfo) = 0; 106 107 /** 108 * @brief Called back when the efficiency resources of App reset. 109 * 110 * @param resourceInfo Request params. 111 */ 112 virtual void OnAppEfficiencyResourcesReset( 113 const std::shared_ptr<ResourceCallbackInfo> &resourceInfo) = 0; 114 115 /** 116 * @brief Apply or unapply efficiency resources of process. 117 * 118 * @param resourceInfo Request params. 119 */ 120 virtual void OnProcEfficiencyResourcesApply( 121 const std::shared_ptr<ResourceCallbackInfo> &resourceInfo) = 0; 122 123 /** 124 * @brief Called back when the efficiency resources of process reset. 125 * 126 * @param resourceInfo Request params. 127 */ 128 virtual void OnProcEfficiencyResourcesReset( 129 const std::shared_ptr<ResourceCallbackInfo> &resourceInfo) = 0; 130 public: 131 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.resourceschedule.IBackgroundTaskSubscriber"); 132 }; 133 } // namespace BackgroundTaskMgr 134 } // namespace OHOS 135 #endif // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_FRAMEWORKS_INCLUDE_IBACKGROUND_TASK_SUBSCRIBER_H