1 /* 2 * Copyright (c) 2022-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 HISYSEVENT_ADAPTER_H 17 #define HISYSEVENT_ADAPTER_H 18 19 #include <stddef.h> 20 21 #define CREATE_GROUP_EVENT "CreateGroup" 22 #define DELETE_GROUP_EVENT "DeleteGroup" 23 #define ADD_MEMBER_EVENT "AddMember" 24 #define DEL_MEMBER_EVENT "DelMember" 25 #define ADD_MULTI_MEMBER_EVENT "AddMultiMember" 26 #define DEL_MULTI_MEMBER_EVENT "DelMultiMember" 27 #define AUTH_DEV_EVENT "AuthDevice" 28 29 #define CANCEL_REQUEST_EVENT "CancelRequest" 30 #define GET_REGISTER_INFO_EVENT "GetRegisterInfo" 31 #define GET_PK_INFO_LIST_EVENT "GetPkInfoList" 32 33 #define ADD_CREDENTIAL_EVENT "AddCredential" 34 #define EXPORT_CREDENTIAL_EVENT "ExportCredential" 35 #define QUERY_CREDENTIAL_BY_PARAMS_EVENT "QueryCredentialByParams" 36 #define QUERY_CRED_INFO_BY_CRED_ID_EVENT "QueryCredInfoByCredId" 37 #define DELETE_CREDENTIAL_EVENT "DeleteCredential" 38 #define DELETE_CREDENTIAL_BY_PARAMS_EVENT "DeleteCredByParams" 39 #define UPDATE_CREDENTIAL_INFO_EVENT "UpdateCredInfo" 40 #define BATCH_UPDATE_CREDENTIALS_EVENT "BatchUpdateCredentials" 41 #define AGREE_CREDENTIAL_EVENT "AgreeCredential" 42 43 #define ADD_MEMBER_WITH_LITE_COMPATIBILITY "AddMemberWithLiteCompatibility" 44 #define ADD_MEMBER_WITH_LITE_STANDARD "AddMemberWithLiteStandard" 45 #define UPGRADE_DATA_EVENT "UpgradeData" 46 #define BIND_CONSUME_EVENT "BindConsume" 47 #define AUTH_CONSUME_EVENT "AuthConsume" 48 #define ADD_MEMBER_TO_CALL_PKG_NAME "dsoftbus" 49 #define ADD_MEMBER_HOST_PKG_NAME "deviceManager" 50 #define AUTH_DEVICE_HOST_PKG_NAME "dsoftbus" 51 52 #define ANONYMOUS_UDID_LEN 12 53 54 #define DEFAULT_GROUP_TYPE 0 55 #define DEFAULT_MULTI_MEMBER_GROUP_TYPE 1 56 #define DEFAULT_CRED_TYPE 0 57 #define DEFAULT_CALL_RESULT 0 58 #define DEFAULT_APPID NULL 59 60 #define DEFAULT_EXECUTION_TIME 0 61 #define DEFAULT_REQ_ID 0 62 #define DEFAULT_FAULT_INFO NULL 63 #define DEFAULT_EXT_INFO NULL 64 65 #include <stdint.h> 66 67 enum DevAuthReportProcessCode { 68 PROCESS_BIND_V1 = 0x001000, //4096 69 PROCESS_AUTH_V1, //4097 70 PROCESS_BIND_V2, //4098 71 PROCESS_AUTH_V2, //4099 72 PROCESS_CREATE_GROUP, //4100 73 PROCESS_DELETE_GROUP, //4101 74 PROCESS_DELETE_MEMBER_FROM_GROUP, //4102 75 PROCESS_ADD_MULTI_MEMBERS_TO_GROUP, //4103 76 PROCESS_DEL_MULTI_MEMBERS_FROM_GROUP, //4104 77 PROCESS_UPDATE, //4105 78 PROCESS_ADD_CREDENTIAL, //4106 79 PROCESS_EXPORT_CREDENTIAL, //4107 80 PROCESS_QUERY_CREDENTIAL_BY_PARAMS, //4108 81 PROCESS_QUERY_CRED_INFO_BY_CRED_ID, //4109 82 PROCESS_DELETE_CREDENTIAL, //4110 83 PROCESS_DELETE_CREDENTIAL_BY_PARAMS, //4111 84 PROCESS_UPDATE_CREDENTIAL_INFO, //4112 85 PROCESS_BATCH_UPDATE_CREDENTIALS, //4113 86 PROCESS_AGREE_CREDENTIAL //4114 87 }; 88 89 #define DEFAULT_PNAMEID "device_auth" 90 #define DEFAULT_PVERSIONID "1.0" 91 92 #ifndef DEV_AUTH_HIVIEW_ENABLE 93 94 #define DEV_AUTH_REPORT_CALL_EVENT(eventData) 95 #define DEV_AUTH_REPORT_FAULT_EVENT(eventdata) 96 #define DEV_AUTH_REPORT_FAULT_EVENT_WITH_ERR_CODE(funcName, processCode, errorCode) 97 #define DEV_AUTH_REPORT_UE_CALL_EVENT(osAccountId, groupType, appId, funcName) 98 #define DEV_AUTH_REPORT_UE_CALL_EVENT_BY_PARAMS(osAccountId, inParams, appId, funcName) 99 #else 100 101 #define DEV_AUTH_REPORT_CALL_EVENT(eventData) \ 102 DevAuthReportCallEvent(eventData) 103 #define DEV_AUTH_REPORT_FAULT_EVENT(eventdata) \ 104 DevAuthReportFaultEvent(eventdata) 105 #define DEV_AUTH_REPORT_FAULT_EVENT_WITH_ERR_CODE(funcName, processCode, errorCode) \ 106 DevAuthReportFaultEventWithErrCode(funcName, processCode, errorCode) 107 #define DEV_AUTH_REPORT_UE_CALL_EVENT(osAccountId, groupType, appId, funcName) \ 108 DevAuthReportUeCallEvent(osAccountId, groupType, appId, funcName) 109 #define DEV_AUTH_REPORT_UE_CALL_EVENT_BY_PARAMS(osAccountId, inParams, appId, funcName) \ 110 DevAuthReportUeCallEventByParams(osAccountId, inParams, appId, funcName) 111 112 #ifdef __cplusplus 113 extern "C" { 114 #endif 115 116 typedef struct { 117 const char *funcName; 118 const char *appId; 119 int32_t osAccountId; 120 int32_t callResult; 121 int32_t processCode; 122 uint8_t credType; 123 int32_t groupType; 124 int64_t executionTime; 125 const char *extInfo; 126 } DevAuthCallEvent; 127 128 typedef struct { 129 const char *orgPkg; 130 const char *funcName; 131 int32_t bizScene; 132 int32_t bizState; 133 int32_t bizStage; 134 int32_t stageRes; 135 int32_t errorCode; 136 const char *toCallPkg; 137 const char *hostPkg; 138 const char *localUdid; 139 const char *peerUdid; 140 const char *concurrentId; 141 } DevAuthBehaviorEvent; 142 143 typedef struct { 144 const char *appId; 145 int32_t processCode; 146 const char *funcName; 147 int64_t reqId; 148 int32_t errorCode; 149 const char *faultInfo; 150 } DevAuthFaultEvent; 151 152 typedef enum { 153 BIZ_SCENE_ADD_MEMBER_CLIENT = 1, 154 BIZ_SCENE_ADD_MEMBER_SERVER, 155 BIZ_SCENE_AUTH_DEVICE_CLIENT, 156 BIZ_SCENE_AUTH_DEVICE_SERVER 157 } DevAuthBizScene; 158 159 typedef enum { 160 BIZ_STATE_PROCESS = 0, 161 BIZ_STATE_BEGIN, 162 BIZ_STATE_END 163 } DevAuthBizState; 164 165 typedef enum { 166 BIZ_STAGE_BEGIN = 1, 167 BIZ_STAGE_PROCESS 168 } DevAuthBizStage; 169 170 typedef enum { 171 STAGE_RES_IDLE = 0, 172 STAGE_RES_SUCCESS, 173 STAGE_RES_FAILED, 174 STAGE_RES_CANCEL, 175 STAGE_RES_IGNORE 176 } DevAuthStageRes; 177 178 void DevAuthReportCallEvent(const DevAuthCallEvent eventData); 179 void DevAuthReportBehaviorEvent(const DevAuthBehaviorEvent *eventData); 180 void BuildBehaviorEventData(DevAuthBehaviorEvent *eventData, const char *funcName, int32_t bizScene, int32_t bizState, 181 int32_t bizStage); 182 void DevAuthReportFaultEvent(const DevAuthFaultEvent eventdata); 183 void DevAuthReportFaultEventWithErrCode(const char *funcName, const int32_t processCode, const int32_t errorCode); 184 void DevAuthReportUeCallEvent(int32_t osAccountId, int32_t groupType, const char *appId, 185 const char *funcName); 186 void DevAuthReportUeCallEventByParams(int32_t osAccountId, const char *inParams, const char *appId, 187 const char *funcName); 188 189 #ifdef __cplusplus 190 } 191 #endif 192 193 #endif 194 195 #endif 196