11401458bSopenharmony_ci/*
21401458bSopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
31401458bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
41401458bSopenharmony_ci * you may not use this file except in compliance with the License.
51401458bSopenharmony_ci * You may obtain a copy of the License at
61401458bSopenharmony_ci *
71401458bSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
81401458bSopenharmony_ci *
91401458bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
101401458bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
111401458bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121401458bSopenharmony_ci * See the License for the specific language governing permissions and
131401458bSopenharmony_ci * limitations under the License.
141401458bSopenharmony_ci */
151401458bSopenharmony_ci
161401458bSopenharmony_ci#ifndef HISYSEVENT_DELEGATE_H
171401458bSopenharmony_ci#define HISYSEVENT_DELEGATE_H
181401458bSopenharmony_ci
191401458bSopenharmony_ci#include <mutex>
201401458bSopenharmony_ci#include <string>
211401458bSopenharmony_ci#include <thread>
221401458bSopenharmony_ci
231401458bSopenharmony_ci#include "hisysevent_base_listener.h"
241401458bSopenharmony_ci#include "hisysevent_base_query_callback.h"
251401458bSopenharmony_ci#include "hisysevent_listener_proxy.h"
261401458bSopenharmony_ci#include "hisysevent_listenning_operate.h"
271401458bSopenharmony_ci#include "hisysevent_manager.h"
281401458bSopenharmony_ci#include "sys_event_query_rule.h"
291401458bSopenharmony_ci#include "sys_event_rule.h"
301401458bSopenharmony_ci#include "system_ability_definition.h"
311401458bSopenharmony_ci
321401458bSopenharmony_cinamespace OHOS {
331401458bSopenharmony_cinamespace HiviewDFX {
341401458bSopenharmony_ciclass HiSysEventDelegate : public HiSysEventListenningOperate {
351401458bSopenharmony_cipublic:
361401458bSopenharmony_ci    HiSysEventDelegate() {}
371401458bSopenharmony_ci    virtual ~HiSysEventDelegate();
381401458bSopenharmony_ci
391401458bSopenharmony_cipublic:
401401458bSopenharmony_ci    static void BinderFunc();
411401458bSopenharmony_ci
421401458bSopenharmony_cipublic:
431401458bSopenharmony_ci    int32_t AddListener(const std::shared_ptr<HiSysEventBaseListener> listener,
441401458bSopenharmony_ci        const std::vector<ListenerRule>& rules);
451401458bSopenharmony_ci    int32_t RemoveListener(const std::shared_ptr<HiSysEventBaseListener> listener);
461401458bSopenharmony_ci    int32_t Query(const struct QueryArg& arg, const std::vector<QueryRule>& rules,
471401458bSopenharmony_ci        const std::shared_ptr<HiSysEventBaseQueryCallback> callback) const;
481401458bSopenharmony_ci    int32_t SetDebugMode(const std::shared_ptr<HiSysEventBaseListener> listener,
491401458bSopenharmony_ci        const bool mode);
501401458bSopenharmony_ci    int64_t Export(const struct QueryArg& arg, const std::vector<QueryRule>& rules) const;
511401458bSopenharmony_ci    int64_t Subscribe(const std::vector<QueryRule>& rules) const;
521401458bSopenharmony_ci    int32_t Unsubscribe() const;
531401458bSopenharmony_ci
541401458bSopenharmony_ciprivate:
551401458bSopenharmony_ci    void ConvertListenerRule(const std::vector<ListenerRule>& rules,
561401458bSopenharmony_ci        std::vector<SysEventRule>& sysRules) const;
571401458bSopenharmony_ci    void ConvertQueryRule(const std::vector<QueryRule>& rules,
581401458bSopenharmony_ci        std::vector<SysEventQueryRule>& sysRules) const;
591401458bSopenharmony_ci    sptr<IRemoteObject> GetSysEventService() const;
601401458bSopenharmony_ci    bool CreateHiviewDir() const;
611401458bSopenharmony_ci    bool SetDirPermission() const;
621401458bSopenharmony_ci
631401458bSopenharmony_ciprivate:
641401458bSopenharmony_ci    sptr<HiSysEventListenerProxy> spListenerCallBack = nullptr;
651401458bSopenharmony_ci};
661401458bSopenharmony_ci} // namespace HiviewDFX
671401458bSopenharmony_ci} // namespace OHOS
681401458bSopenharmony_ci
691401458bSopenharmony_ci#endif // HISYSEVENT_DELEGATE_H
70