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_SG_COLLECT_CLIENT_H 17 #define SECURITY_GUARD_SG_COLLECT_CLIENT_H 18 19 #include <mutex> 20 21 #include "iremote_object.h" 22 23 #include "event_info.h" 24 #include "i_data_collect_manager.h" 25 #include "security_guard_api.h" 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 int32_t ReportSecurityInfo(const struct EventInfoSt *info); 32 33 #ifdef __cplusplus 34 } 35 #endif 36 37 namespace OHOS::Security::SecurityGuard { 38 class NativeDataCollectKit { 39 public: 40 static int32_t ReportSecurityInfo(const std::shared_ptr<EventInfo> &info); 41 }; 42 43 class SgCollectClient { 44 public: 45 static SgCollectClient &GetInstance(); 46 sptr<IDataCollectManager> GetProxy(); 47 void InitProxy(); 48 void ReleaseProxy(); 49 50 private: 51 SgCollectClient() = default; 52 ~SgCollectClient() = default; 53 std::mutex proxyMutex_; 54 sptr<IDataCollectManager> proxy_ = nullptr; 55 sptr<IRemoteObject::DeathRecipient> deathRecipient_ = nullptr; 56 }; 57 58 class SgCollectClientDeathRecipient : public IRemoteObject::DeathRecipient { 59 public: 60 SgCollectClientDeathRecipient() = default; 61 ~SgCollectClientDeathRecipient() override = default; 62 63 void OnRemoteDied(const wptr<IRemoteObject> &object) override; 64 }; 65 } // namespace OHOS::Security::SecurityGuard 66 67 #endif // SECURITY_GUARD_SG_COLLECT_CLIENT_H