1 /* 2 * Copyright (c) 2021-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 HISYSEVENT_DELEGATE_H 17 #define HISYSEVENT_DELEGATE_H 18 19 #include <mutex> 20 #include <string> 21 #include <thread> 22 23 #include "hisysevent_base_listener.h" 24 #include "hisysevent_base_query_callback.h" 25 #include "hisysevent_listener_proxy.h" 26 #include "hisysevent_listenning_operate.h" 27 #include "hisysevent_manager.h" 28 #include "sys_event_query_rule.h" 29 #include "sys_event_rule.h" 30 #include "system_ability.h" 31 #include "system_ability_definition.h" 32 33 namespace OHOS { 34 namespace HiviewDFX { 35 class HiSysEventDelegate : public HiSysEventListenningOperate { 36 public: HiSysEventDelegate()37 HiSysEventDelegate() {} 38 virtual ~HiSysEventDelegate(); 39 40 public: 41 static void BinderFunc(); 42 43 public: 44 int32_t AddListener(const std::shared_ptr<HiSysEventBaseListener> listener, 45 const std::vector<ListenerRule>& rules); 46 int32_t RemoveListener(const std::shared_ptr<HiSysEventBaseListener> listener); 47 int32_t Query(const struct QueryArg& arg, const std::vector<QueryRule>& rules, 48 const std::shared_ptr<HiSysEventBaseQueryCallback> callback) const; 49 int32_t SetDebugMode(const std::shared_ptr<HiSysEventBaseListener> listener, 50 const bool mode); 51 52 private: 53 void ConvertListenerRule(const std::vector<ListenerRule>& rules, 54 std::vector<SysEventRule>& sysRules) const; 55 void ConvertQueryRule(const std::vector<QueryRule>& rules, 56 std::vector<SysEventQueryRule>& sysRules) const; 57 sptr<IRemoteObject> GetSysEventService() const; 58 59 private: 60 sptr<HiSysEventListenerProxy> spListenerCallBack = nullptr; 61 }; 62 } // namespace HiviewDFX 63 } // namespace OHOS 64 65 #endif // HISYSEVENT_DELEGATE_H 66