• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "security_guard_sdk_adaptor.h"
17 #include "data_collect_manager.h"
18 #include "sg_collect_client.h"
19 #include "sg_classify_client.h"
20 #include "security_guard_log.h"
21 
22 namespace OHOS::Security::SecurityGuard {
RequestSecurityEventInfo(std::string & devId,std::string & eventList,RequestRiskDataCallback callback)23 int32_t SecurityGuardSdkAdaptor::RequestSecurityEventInfo(std::string &devId, std::string &eventList,
24     RequestRiskDataCallback callback)
25 {
26     SGLOGI("enter SecurityGuardSdkAdaptor RequestSecurityEventInfo");
27     return DataCollectManager::GetInstance().RequestSecurityEventInfo(devId, eventList, callback);
28 }
29 
InnerRequestSecurityModelResult(const std::string & devId,uint32_t modelId,const std::string & param,SecurityGuardRiskCallback callback)30 int32_t SecurityGuardSdkAdaptor::InnerRequestSecurityModelResult(const std::string &devId, uint32_t modelId,
31     const std::string &param, SecurityGuardRiskCallback callback)
32 {
33     SGLOGI("enter SecurityGuardSdkAdaptor InnerRequestSecurityModelResult");
34     return RequestSecurityModelResultAsync(devId, modelId, param, callback);
35 }
36 
InnerReportSecurityInfo(const std::shared_ptr<EventInfo> & info)37 int32_t SecurityGuardSdkAdaptor::InnerReportSecurityInfo(const std::shared_ptr<EventInfo> &info)
38 {
39     SGLOGD("enter SecurityGuardSdkAdaptor InnerReportSecurityInfo");
40     return  DataCollectManager::GetInstance().ReportSecurityEvent(info, true);
41 }
42 
StartCollector(const SecurityCollector::Event & event,int64_t duration)43 int32_t SecurityGuardSdkAdaptor::StartCollector(const SecurityCollector::Event &event,
44     int64_t duration)
45 {
46     SGLOGI("enter SecurityGuardSdkAdaptor StartCollector");
47     return DataCollectManager::GetInstance().StartCollector(event, duration);
48 }
49 
StopCollector(const SecurityCollector::Event & event)50 int32_t SecurityGuardSdkAdaptor::StopCollector(const SecurityCollector::Event &event)
51 {
52     SGLOGI("in SecurityGuardSdkAdaptor StopCollector");
53     return DataCollectManager::GetInstance().StopCollector(event);
54 }
55 
QuerySecurityEvent(std::vector<SecurityCollector::SecurityEventRuler> rulers,std::shared_ptr<SecurityEventQueryCallback> callback)56 int32_t SecurityGuardSdkAdaptor::QuerySecurityEvent(std::vector<SecurityCollector::SecurityEventRuler> rulers,
57     std::shared_ptr<SecurityEventQueryCallback> callback)
58 {
59     SGLOGI("enter SecurityGuardSdkAdaptor QuerySecurityEvent");
60     return DataCollectManager::GetInstance().QuerySecurityEvent(rulers, callback);
61 }
62 
Subscribe(const std::shared_ptr<SecurityCollector::ICollectorSubscriber> & subscriber)63 int32_t SecurityGuardSdkAdaptor::Subscribe(const std::shared_ptr<SecurityCollector::ICollectorSubscriber> &subscriber)
64 {
65     SGLOGI("enter SecurityGuardSdkAdaptor Subscribe");
66     return DataCollectManager::GetInstance().Subscribe(subscriber);
67 }
68 
Unsubscribe(const std::shared_ptr<SecurityCollector::ICollectorSubscriber> & subscriber)69 int32_t SecurityGuardSdkAdaptor::Unsubscribe(const std::shared_ptr<SecurityCollector::ICollectorSubscriber> &subscriber)
70 {
71     SGLOGI("enter SecurityGuardSdkAdaptor Unsubscribe");
72     return DataCollectManager::GetInstance().Unsubscribe(subscriber);
73 }
74 
ConfigUpdate(const SecurityGuard::SecurityConfigUpdateInfo & updateInfo)75 int32_t SecurityGuardSdkAdaptor::ConfigUpdate(const SecurityGuard::SecurityConfigUpdateInfo &updateInfo)
76 {
77     SGLOGI("enter SecurityGuardSdkAdaptor ConfigUpdate");
78     return DataCollectManager::GetInstance().SecurityGuardConfigUpdate(updateInfo.GetFd(), updateInfo.GetFileName());
79 }
80 } // OHOS::Security::SecurityGuard