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  * miscservices under the License is miscservices 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 #ifndef SOFTBUS_HISYSEVENT_BUS_CENTER_H
16 #define SOFTBUS_HISYSEVENT_BUS_CENTER_H
17 
18 #include <stdint.h>
19 
20 #include "common_list.h"
21 #include "softbus_adapter_hisysevent.h"
22 #include "softbus_common.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 typedef enum {
29     MODULE_TYPE_DISCOVERY = 1,
30     MODULE_TYPE_CONNECT = 2,
31     MODULE_TYPE_AUTH = 3,
32     MODULE_TYPE_BUS_CENTER = 4,
33     MODULE_TYPE_ONLINE = 5,
34     MODULE_TYPE_TRANSPORT = 6,
35     MODULE_TYPE_API_CALLED = 7,
36     MODULE_TYPE_BUTT = 8,
37 } SoftBusModuleType;
38 
39 typedef enum {
40     SOFTBUS_HISYSEVT_LINK_TYPE_BR = 0,
41     SOFTBUS_HISYSEVT_LINK_TYPE_BLE = 1,
42     SOFTBUS_HISYSEVT_LINK_TYPE_WLAN = 2,
43     SOFTBUS_HISYSEVT_LINK_TYPE_P2P = 3,
44     SOFTBUS_HISYSEVT_LINK_TYPE_HML = 4,
45     SOFTBUS_HISYSEVT_LINK_TYPE_BUTT = 5,
46 } SoftBusLinkType;
47 
48 typedef enum {
49     AUTH_CONNECT_STAGE = 1,
50     AUTH_VERIFY_STAGE = 2,
51     AUTH_EXCHANGE_STAGE = 3,
52     AUTH_STAGE_BUTT,
53 } AuthFailStage;
54 
55 typedef enum {
56     START_DISCOVERY = 1,
57     SEND_BROADCAST = 2,
58     RECV_BROADCAST = 3,
59     DEVICE_FOUND = 4,
60     BUSINESS_DISCOVERY = 5,
61 } DiscoveryStage;
62 
63 typedef struct {
64     uint32_t onlineDevNum;
65     uint32_t btOnlineDevNum;
66     uint32_t wifiOnlineDevNum;
67     uint32_t peerDevType;
68     int32_t insertFileResult;
69     char peerSoftBusVer[SOFTBUS_HISYSEVT_NAME_LEN];
70     char peerDevName[SOFTBUS_HISYSEVT_NAME_LEN];
71     char localSoftBusVer[SOFTBUS_HISYSEVT_NAME_LEN];
72     char peerPackVer[SOFTBUS_HISYSEVT_NAME_LEN];
73     char localPackVer[SOFTBUS_HISYSEVT_NAME_LEN];
74 } OnlineDeviceInfo;
75 
76 typedef struct {
77     uint8_t moduleType;
78     uint8_t linkType;
79     float channelQuality;
80     int32_t errorCode;
81     int32_t peerDevType;
82     int32_t onLineDevNum;
83     int32_t connNum;
84     int32_t nightMode;
85     int32_t wifiStatue;
86     int32_t bleStatue;
87     int32_t callerAppMode;
88     int32_t subErrCode;
89     int32_t connBrNum;
90     int32_t connBleNum;
91     bool bleBradStatus;
92     bool bleScanStatus;
93     char businessName[SOFTBUS_HISYSEVT_NAME_LEN];
94     char callerPackName[SOFTBUS_HISYSEVT_NAME_LEN];
95     char remoteBizUuid[SOFTBUS_HISYSEVT_NAME_LEN];
96 } SoftBusFaultEvtInfo;
97 
98 typedef struct {
99     int32_t appDiscCnt;
100     char appName[SOFTBUS_HISYSEVT_NAME_LEN];
101     ListNode node;
102 } AppDiscNode;
103 
104 typedef struct {
105     uint64_t startAuthTime;
106     uint64_t endAuthTime;
107 } AuthStatisticData;
108 
109 typedef struct {
110     int64_t beginJoinLnnTime;
111     int64_t beginOnlineTime;
112     int64_t offLineTime;
113 } LnnStatisticData;
114 
115 int64_t LnnUpTimeMs(void);
116 void DeinitBusCenterDfx(void);
117 int32_t InitBusCenterDfx(void);
118 int32_t SoftBusRecordDiscoveryResult(DiscoveryStage stage, AppDiscNode *discNode);
119 int32_t SoftBusReportBusCenterFaultEvt(SoftBusFaultEvtInfo *info);
120 int32_t SoftBusReportDevOnlineEvt(OnlineDeviceInfo *info, const char *udid);
121 int32_t SoftBusRecordDevOnlineDurResult(uint64_t constTime);
122 int32_t SoftBusRecordBusCenterResult(SoftBusLinkType linkType, uint64_t constTime);
123 int32_t SoftBusRecordAuthResult(SoftBusLinkType linkType, int32_t ret, uint64_t constTime, AuthFailStage stage);
124 #ifdef __cplusplus
125 }
126 #endif
127 #endif /* SOFTBUS_HISYSEVENT_BUS_CENTER_H */
128