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