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 OHOS_SYSTEM_ABILITY_MANAGER_COLLECT_PLUGIN_INTERFACE_H 17 #define OHOS_SYSTEM_ABILITY_MANAGER_COLLECT_PLUGIN_INTERFACE_H 18 19 #include <list> 20 21 #include "errors.h" 22 #include "ireport.h" 23 #include "refbase.h" 24 #include "sa_profiles.h" 25 #include "system_ability_ondemand_reason.h" 26 27 namespace OHOS { 28 class ICollectPlugin : public virtual RefBase { 29 public: 30 explicit ICollectPlugin(const sptr<IReport>& report); 31 virtual ~ICollectPlugin() = default; 32 CleanFfrt()33 virtual void CleanFfrt() 34 { 35 } SetFfrt()36 virtual void SetFfrt() 37 { 38 } 39 RemoveWhiteCommonEvent()40 virtual void RemoveWhiteCommonEvent() {} 41 virtual int32_t OnStart() = 0; 42 virtual int32_t OnStop() = 0; Init(const std::list<SaProfile> & saProfiles)43 virtual void Init(const std::list<SaProfile>& saProfiles) {}; 44 CheckCondition(const OnDemandCondition & condition)45 virtual bool CheckCondition(const OnDemandCondition& condition) 46 { 47 return false; 48 } 49 CheckExtraMessage(int64_t extraDataId,const OnDemandEvent & profileEvent)50 virtual bool CheckExtraMessage(int64_t extraDataId, const OnDemandEvent& profileEvent) 51 { 52 return true; 53 } 54 GetOnDemandReasonExtraData(int64_t extraDataId,OnDemandReasonExtraData & extraData)55 virtual bool GetOnDemandReasonExtraData(int64_t extraDataId, OnDemandReasonExtraData& extraData) 56 { 57 return false; 58 } 59 AddCollectEvent(const OnDemandEvent & event)60 virtual int32_t AddCollectEvent(const OnDemandEvent& event) 61 { 62 return ERR_OK; 63 } 64 RemoveUnusedEvent(const OnDemandEvent & event)65 virtual int32_t RemoveUnusedEvent(const OnDemandEvent& event) 66 { 67 return ERR_OK; 68 } SaveSaExtraDataId(int32_t saId,int64_t extraDataId)69 virtual void SaveSaExtraDataId(int32_t saId, int64_t extraDataId) {}; ClearSaExtraDataId(int32_t saId)70 virtual void ClearSaExtraDataId(int32_t saId) {}; SaveCacheCommonEventSaExtraId(const OnDemandEvent & event,const std::list<SaControlInfo> & saControlList)71 virtual void SaveCacheCommonEventSaExtraId(const OnDemandEvent& event, 72 const std::list<SaControlInfo>& saControlList) {}; 73 virtual int32_t GetSaExtraDataIdList(int32_t saId, std::vector<int64_t>& extraDataIdList, 74 const std::string& eventName = "") 75 { 76 return ERR_OK; 77 } 78 void ReportEvent(const OnDemandEvent& event); 79 void PostDelayTask(std::function<void()> callback, int32_t delayTime); 80 private: 81 sptr<IReport> report_; 82 }; 83 } // namespace OHOS 84 #endif // OHOS_SYSTEM_ABILITY_MANAGER_COLLECT_PLUGIN_INTERFACE_H