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 SECURITY_GUARD_I_DATA_COLLECT_MANAGER_H 17 #define SECURITY_GUARD_I_DATA_COLLECT_MANAGER_H 18 19 #include <cstdint> 20 21 #include "iremote_broker.h" 22 23 #include "data_collect_manager_service_ipc_interface_code.h" 24 #include "security_collector_subscribe_info.h" 25 #include "security_event_ruler.h" 26 #include "security_event.h" 27 #include "security_config_update_info.h" 28 29 namespace OHOS::Security::SecurityGuard { 30 constexpr int32_t DATA_COLLECT_MANAGER_SA_ID = 3524; 31 32 class IDataCollectManager : public IRemoteBroker { 33 public: 34 using InterfaceCode = DataCollectManagerInterfaceCode; 35 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Security.DataCollectManager"); 36 enum { 37 CMD_DATA_COLLECT = static_cast<uint32_t>(InterfaceCode::CMD_DATA_COLLECT), 38 CMD_DATA_REQUEST = static_cast<uint32_t>(InterfaceCode::CMD_DATA_REQUEST), 39 CMD_DATA_SUBSCRIBE = static_cast<uint32_t>(InterfaceCode::CMD_DATA_SUBSCRIBE), 40 CMD_DATA_UNSUBSCRIBE = static_cast<uint32_t>(InterfaceCode::CMD_DATA_UNSUBSCRIBE), 41 CMD_SECURITY_EVENT_QUERY = static_cast<uint32_t>(InterfaceCode::CMD_SECURITY_EVENT_QUERY), 42 CMD_SECURITY_COLLECTOR_START = static_cast<uint32_t>(InterfaceCode::CMD_SECURITY_COLLECTOR_START), 43 CMD_SECURITY_COLLECTOR_STOP = static_cast<uint32_t>(InterfaceCode::CMD_SECURITY_COLLECTOR_STOP), 44 CMD_SECURITY_CONFIG_UPDATE = static_cast<uint32_t>(InterfaceCode::CMD_SECURITY_CONFIG_UPDATE), 45 }; 46 47 virtual int32_t RequestDataSubmit(int64_t eventId, std::string &version, std::string &time, 48 std::string &content, bool isSync = true) = 0; 49 virtual int32_t RequestRiskData(std::string &devId, std::string &eventList, 50 const sptr<IRemoteObject> &callback) = 0; 51 virtual int32_t Subscribe(const SecurityCollector::SecurityCollectorSubscribeInfo &subscribeInfo, 52 const sptr<IRemoteObject> &callback) = 0; 53 virtual int32_t Unsubscribe(const sptr<IRemoteObject> &callback) = 0; 54 virtual int32_t QuerySecurityEvent(std::vector<SecurityCollector::SecurityEventRuler> rulers, 55 const sptr<IRemoteObject> &callback) = 0; 56 virtual int32_t CollectorStart(const SecurityCollector::SecurityCollectorSubscribeInfo &subscribeInfo, 57 const sptr<IRemoteObject> &callback) = 0; 58 virtual int32_t CollectorStop(const SecurityCollector::SecurityCollectorSubscribeInfo &subscribeInfo, 59 const sptr<IRemoteObject> &callback) = 0; 60 virtual int32_t ConfigUpdate(const SecurityGuard::SecurityConfigUpdateInfo &updateInfo) = 0; 61 }; 62 63 class IDataCollectManagerCallback : public IRemoteBroker { 64 public: 65 using InterfaceCode = DataCollectManagerCallbackInterfaceCode; 66 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Security.DataCollectManager.Callback"); 67 enum { 68 CMD_SET_REQUEST_DATA = static_cast<uint32_t>(InterfaceCode::CMD_SET_REQUEST_DATA), 69 }; 70 71 virtual int32_t ResponseRiskData(std::string &devId, std::string &riskData, uint32_t status, 72 const std::string& errMsg = "") = 0; 73 }; 74 75 class IAcquireDataCallback : public IRemoteBroker { 76 public: 77 using InterfaceCode = DataCollectManagerCallbackInterfaceCode; 78 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Security.AcquireData.Callback"); 79 enum { 80 CMD_DATA_SUBSCRIBE_CALLBACK = static_cast<uint32_t>(InterfaceCode::CMD_DATA_SUBSCRIBE_CALLBACK), 81 }; 82 83 virtual int32_t OnNotify(const SecurityCollector::Event &event) = 0; 84 }; 85 86 class ISecurityEventQueryCallback : public IRemoteBroker { 87 public: 88 using InterfaceCode = SecurityEventQueryCallbackInterfaceCode; 89 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Security.SecurityEventQuery.Callback"); 90 enum { 91 CMD_ON_QUERY = static_cast<uint32_t>(InterfaceCode::CMD_ON_QUERY), 92 CMD_ON_COMPLETE = static_cast<uint32_t>(InterfaceCode::CMD_ON_COMPLETE), 93 CMD_ON_ERROR = static_cast<uint32_t>(InterfaceCode::CMD_ON_ERROR), 94 }; 95 96 virtual void OnQuery(const std::vector<SecurityCollector::SecurityEvent> &events) = 0; 97 virtual void OnComplete() = 0; 98 virtual void OnError(const std::string &message) = 0; 99 }; 100 } // namespace OHOS::Security::SecurityGuard 101 102 #endif // SECURITY_GUARD_I_DATA_COLLECT_MANAGER_H