1 /* 2 * Copyright (c) 2023 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 SOFTBUS_HIDUMPER_UTIL_H 17 #define SOFTBUS_HIDUMPER_UTIL_H 18 19 #include <stdint.h> 20 #include <stdbool.h> 21 #include <stdlib.h> 22 23 #ifdef __cplusplus 24 #if __cplusplus 25 extern "C" { 26 #endif 27 #endif 28 29 #define SOFTBUS_ZERO 0 30 #define SOFTBUS_ONE 1 31 #define SOFTBUS_ALARM_TIME_LEN 26 32 33 typedef enum { 34 SOFTBUS_MANAGEMENT_ALARM_TYPE, 35 SOFTBUS_CONTROL_ALARM_TYPE, 36 ALARM_UNUSE_BUTT, 37 } SoftBusAlarmType; 38 39 typedef struct { 40 char time[SOFTBUS_ALARM_TIME_LEN]; 41 int32_t type; 42 int32_t callerPid; 43 int32_t errorCode; 44 int32_t linkType; 45 int32_t minBw; 46 int32_t methodId; 47 char *permissionName; 48 char *sessionName; 49 } AlarmRecord; 50 51 typedef struct { 52 AlarmRecord *records; 53 size_t recordSize; 54 } SoftBusAlarmEvtResult; 55 56 typedef struct { 57 int32_t btFlow; 58 float successRate; 59 int32_t maxParaSessionNum; 60 int32_t sessionSuccessDuration; 61 int32_t deviceOnlineNum; 62 int32_t deviceOnlineTimes; 63 int32_t deviceOfflineTimes; 64 int32_t laneScoreOverTimes; 65 float activityRate; 66 int32_t detectionTimes; 67 char *successRateDetail; 68 } SoftBusStatsResult; 69 70 SoftBusStatsResult* MallocSoftBusStatsResult(unsigned int size); 71 72 void FreeSoftBusStatsResult(SoftBusStatsResult* result); 73 74 int32_t SoftBusQueryStatsInfo(int time, SoftBusStatsResult* result); 75 76 int32_t SoftBusQueryAlarmInfo(int time, int type, SoftBusAlarmEvtResult* result); 77 78 int32_t SoftBusHidumperUtilInit(void); 79 80 void SoftBusHidumperUtilDeInit(void); 81 82 #ifdef __cplusplus 83 #if __cplusplus 84 } 85 #endif /* __cplusplus */ 86 #endif /* __cplusplus */ 87 #endif /* SOFTBUS_HIDUMPER_ALARM_H */