1 /*
2  * Copyright (c) 2024 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 WIFI_DIRECT_DFX_H
17 #define WIFI_DIRECT_DFX_H
18 
19 #include <mutex>
20 #include <shared_mutex>
21 #include <functional>
22 #include <map>
23 #include "command/connect_command.h"
24 #include "conn_event.h"
25 #include "wifi_direct_types.h"
26 
27 namespace OHOS::SoftBus {
28 class WifiDirectDfx {
29 public:
GetInstance()30     static WifiDirectDfx &GetInstance()
31     {
32         static WifiDirectDfx instance;
33         return instance;
34     }
35     void DfxRecord(bool success, int32_t reason, const ConnectInfo &connectInfo);
36     void Record(uint32_t requestId, uint16_t challengeCode);
37     void Clear(uint32_t requestId);
38 
39 private:
40     void ReportConnEventExtra(ConnEventExtra &extra, const ConnectInfo &connectInfo);
41 
42     std::map<uint32_t, uint16_t> challengeCodeMap_;
43     std::recursive_mutex mutex_;
44 };
45 } // namespace OHOS::SoftBus
46 
47 #endif