1 /* 2 * Copyright (c) 2021-2025 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_definition.h" 31 32 namespace OHOS { 33 namespace HiviewDFX { 34 class HiSysEventDelegate : public HiSysEventListenningOperate { 35 public: 36 static void BinderFunc(); 37 38 public: 39 int32_t AddListener(const std::shared_ptr<HiSysEventBaseListener> listener, 40 const std::vector<ListenerRule>& rules); 41 int32_t RemoveListener(const std::shared_ptr<HiSysEventBaseListener> listener); 42 int32_t Query(const struct QueryArg& arg, const std::vector<QueryRule>& rules, 43 const std::shared_ptr<HiSysEventBaseQueryCallback> callback) const; 44 int64_t Export(const struct QueryArg& arg, const std::vector<QueryRule>& rules) const; 45 int64_t Subscribe(const std::vector<QueryRule>& rules) const; 46 int32_t Unsubscribe() const; 47 48 private: 49 void ConvertListenerRule(const std::vector<ListenerRule>& rules, 50 std::vector<SysEventRule>& sysRules) const; 51 void ConvertQueryRule(const std::vector<QueryRule>& rules, 52 std::vector<SysEventQueryRule>& sysRules) const; 53 sptr<IRemoteObject> GetSysEventService() const; 54 bool CreateHiviewDir() const; 55 bool SetDirPermission() const; 56 57 private: 58 sptr<HiSysEventListenerProxy> spListenerCallBack = nullptr; 59 }; 60 } // namespace HiviewDFX 61 } // namespace OHOS 62 63 #endif // HISYSEVENT_DELEGATE_H 64