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 ISECURITY_COLLECTOR_MANAGER_H
17 #define ISECURITY_COLLECTOR_MANAGER_H
18 
19 #include <cstdint>
20 #include <cstring>
21 
22 #include "iremote_broker.h"
23 
24 #include "event_define.h"
25 #include "security_collector_subscribe_info.h"
26 #include "security_collector_manager_service_ipc_interface_code.h"
27 #include "security_event.h"
28 #include "security_event_ruler.h"
29 
30 namespace OHOS::Security::SecurityCollector {
31 constexpr int32_t SECURITY_COLLECTOR_MANAGER_SA_ID = 3525;
32 
33 class ISecurityCollectorManager : public IRemoteBroker {
34 public:
35     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Security.SecurityCollectorManager");
36     using InterfaceCode = SecurityCollectManagerInterfaceCode;
37     enum {
38         CMD_COLLECTOR_SUBCRIBE = static_cast<uint32_t>(InterfaceCode::CMD_COLLECTOR_SUBCRIBE),
39         CMD_COLLECTOR_UNSUBCRIBE = static_cast<uint32_t>(InterfaceCode::CMD_COLLECTOR_UNSUBCRIBE),
40         CMD_COLLECTOR_START = static_cast<uint32_t>(InterfaceCode::CMD_COLLECTOR_START),
41         CMD_COLLECTOR_STOP =  static_cast<uint32_t>(InterfaceCode::CMD_COLLECTOR_STOP),
42         CMD_SECURITY_EVENT_QUERY = static_cast<uint32_t>(InterfaceCode::CMD_SECURITY_EVENT_QUERY),
43     };
44 
45     virtual int32_t Subscribe(const SecurityCollectorSubscribeInfo &subscribeInfo,
46         const sptr<IRemoteObject> &callback) = 0;
47     virtual int32_t Unsubscribe(const sptr<IRemoteObject> &callback) = 0;
48     virtual int32_t CollectorStart(const SecurityCollectorSubscribeInfo &subscribeInfo,
49         const sptr<IRemoteObject> &callback) = 0;
50     virtual int32_t CollectorStop(const SecurityCollectorSubscribeInfo &subscribeInfo,
51         const sptr<IRemoteObject> &callback) = 0;
52     virtual int32_t QuerySecurityEvent(const std::vector<SecurityEventRuler> rulers,
53         std::vector<SecurityEvent> &events) = 0;
54 };
55 
56 class ISecurityCollectorManagerCallback : public IRemoteBroker {
57 public:
58     using InterfaceCode = SecurityCollectManagerCallbackInterfaceCode;
59     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Security.SecurityCollectorManager.Callback");
60     enum {
61         CMD_COLLECTOR_NOTIFY = static_cast<uint32_t>(InterfaceCode::CMD_COLLECTOR_CALLBACK)
62     };
63 
64     virtual int32_t OnNotify(const Event &event) = 0;
65 };
66 
67 } // namespace OHOS::Security::SecurityCollector
68 
69 #endif // ISECURITY_COLLECTOR_MANAGER_H
70