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