1 /*
2  * Copyright (c) 2023 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 REQUEST_SECURITY_EVENT_INFO_NAPI_H
17 #define REQUEST_SECURITY_EVENT_INFO_NAPI_H
18 #include <map>
19 #include "event_info.h"
20 #include "event_define.h"
21 #include "security_guard_define.h"
22 #include "system_ability_load_callback_stub.h"
23 #include "security_event_query_callback.h"
24 #include "security_event_ruler.h"
25 #include "i_collector_subscriber.h"
26 #include "acquire_data_manager_callback_service.h"
27 namespace OHOS::Security::SecurityGuard {
28 class SecurityGuardSdkAdaptor {
29 public:
30     static int32_t RequestSecurityEventInfo(std::string &devId, std::string &eventList,
31         RequestRiskDataCallback callback);
32     static int32_t RequestSecurityModelResult(const std::string &devId, uint32_t modelId,
33         const std::string &param, ResultCallback callback);
34     static int32_t ReportSecurityInfo(const std::shared_ptr<EventInfo> &info);
35     static int32_t SetModelState(uint32_t modelId, bool enable);
36     static int32_t NotifyCollector(const SecurityCollector::Event &event, int64_t duration);
37     static int32_t StartCollector(const SecurityCollector::Event &event, int64_t duration);
38     static int32_t StopCollector(const SecurityCollector::Event &event);
39     static int32_t QuerySecurityEvent(std::vector<SecurityCollector::SecurityEventRuler> rulers,
40         std::shared_ptr<SecurityEventQueryCallback> callback);
41     static int32_t Subscribe(const std::shared_ptr<SecurityCollector::ICollectorSubscriber> &subscriber);
42     static int32_t Unsubscribe(const std::shared_ptr<SecurityCollector::ICollectorSubscriber> &subscriber);
43     static int32_t ConfigUpdate(const SecurityGuard::SecurityConfigUpdateInfo &updateInfo);
44 private:
45     SecurityGuardSdkAdaptor() = delete;
46     ~SecurityGuardSdkAdaptor() = delete;
47     static std::map<std::shared_ptr<SecurityCollector::ICollectorSubscriber>,
48         sptr<AcquireDataManagerCallbackService>> subscribers_;
49     static sptr<IDataCollectManager> LoadDataCollectManageService();
50     static sptr<IRemoteObject> object_;
51     static std::mutex objMutex_;
52 };
53 } // OHOS::Security::SecurityGuard
54 
55 #endif // REQUEST_SECURITY_EVENT_INFO_NAPI_H