1 /* 2 * Copyright (c) 2025 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 USER_AUTH_API_EVENT_REPORTER_H 17 #define USER_AUTH_API_EVENT_REPORTER_H 18 19 #include <cstdint> 20 #include <mutex> 21 #include <string> 22 23 #include "nocopyable.h" 24 25 #include "auth_common.h" 26 27 namespace OHOS { 28 namespace UserIam { 29 namespace UserAuth { 30 class UserAuthApiEventReporter : public NoCopyable { 31 public: 32 UserAuthApiEventReporter(std::string apiName); 33 ~UserAuthApiEventReporter() = default; 34 35 void ReportSuccess(); 36 void ReportFailed(UserAuthResultCode resultCode); 37 void ReportFailed(int32_t resultCode); 38 39 private: 40 static int64_t GetProcessorId(); 41 42 void Report(int32_t result, int32_t errCode); 43 44 static int64_t processorId_; 45 46 bool isReported_ = false; 47 std::string transId_; 48 std::string apiName_; 49 int64_t beginTime_{0}; 50 }; 51 } // namespace UserAuth 52 } // namespace UserIam 53 } // namespace OHOS 54 55 #endif // USER_AUTH_API_EVENT_REPORTER_H