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 * 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 OS_ACCOUNT_DFX_HISYSEVENT_ADAPTER_H 17 #define OS_ACCOUNT_DFX_HISYSEVENT_ADAPTER_H 18 19 #include <string> 20 #include "account_log_wrapper.h" 21 22 namespace OHOS { 23 namespace AccountSA { 24 void ReportServiceStartFail(int32_t errCode, const std::string& errMsg); 25 void ReportPermissionFail(int32_t callerUid, int32_t callerPid, const std::string& permName); 26 void ReportOsAccountOperationFail( 27 int32_t id, const std::string& operationStr, int32_t errCode, const std::string& errMsg); 28 void ReportOhosAccountOperationFail( 29 int32_t userId, const std::string& operationStr, int32_t errCode, const std::string& errMsg); 30 void ReportAppAccountOperationFail(const std::string &name, const std::string &owner, const std::string& operationStr, 31 int32_t errCode, const std::string& errMsg); 32 void ReportOsAccountLifeCycle(int32_t id, const std::string& operationStr); 33 void ReportOsAccountSwitch(int32_t currentId, int32_t oldId); 34 void ReportOhosAccountStateChange(int32_t userId, int32_t operateType, int32_t oldStat, int32_t newStat); 35 void ReportOsAccountDataTampered(int32_t id, const std::string& dataPath, const std::string& dataLabel); 36 37 #define ASSEMBLE_ERRMSG(str) \ 38 ("[" + std::string(__FUNCTION__) + "@" + std::string(LOG_FILE_NAME) + ":" + std::to_string(__LINE__) + "] " + (str)) 39 #define REPORT_OS_ACCOUNT_FAIL(id, operationStr, errCode, errMsg) \ 40 ReportOsAccountOperationFail(id, operationStr, errCode, ASSEMBLE_ERRMSG(errMsg)) 41 #define REPORT_OHOS_ACCOUNT_FAIL(userId, operationStr, errCode, errMsg) \ 42 ReportOhosAccountOperationFail(userId, operationStr, errCode, ASSEMBLE_ERRMSG(errMsg)) 43 #define REPORT_APP_ACCOUNT_FAIL(name, owner, operationStr, errCode, errMsg) \ 44 ReportAppAccountOperationFail(name, owner, operationStr, errCode, ASSEMBLE_ERRMSG(errMsg)) 45 #define REPORT_PERMISSION_FAIL() \ 46 ReportPermissionFail(IPCSkeleton::GetCallingUid(), IPCSkeleton::GetCallingRealPid(), __FUNCTION__) 47 } // AccountSA 48 } // OHOS 49 #endif // OS_ACCOUNT_DFX_HISYSEVENT_ADAPTER_H 50