1 /* 2 * Copyright (c) 2024 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 DISTRIBUTEDFILE_DFS_EVENT_DFX_H 17 #define DISTRIBUTEDFILE_DFS_EVENT_DFX_H 18 19 #include "hisysevent.h" 20 namespace OHOS { 21 namespace FileManagement { 22 namespace ModuleFileIO { 23 namespace RadarReporter { 24 using namespace OHOS::HiviewDFX; 25 static constexpr int DIST_DATA_MGR_SYS_ID = 0xd; 26 static constexpr int DFS_ID = 13; 27 enum BizScene : std::int32_t { 28 DFX_SET_DFS = 1, 29 }; 30 31 enum BizStageSetDfs : std::int32_t { 32 DFX_SET_BIZ_SCENE = 1, 33 }; 34 35 enum StageRes : std::int32_t { 36 DFX_IDLE = 0, 37 DFX_SUCCESS = 1, 38 DFX_FAILED = 2, 39 DFX_CANCELLED = 3, 40 }; 41 42 enum BizState : std::int32_t { 43 DFX_BEGIN = 1, 44 DFX_END = 2, 45 }; 46 47 enum ErrorCode : std::int32_t { 48 DFS_ERROR = (DIST_DATA_MGR_SYS_ID << 21) | (DFS_ID << 16), 49 PREPARE_COPY_SESSION_ERROR, 50 COPY_TO_SANDBOX_ERROR, 51 SEND_FILE_ERROR, 52 }; 53 54 static constexpr char DOMAIN[] = "DISTDATAMGR"; 55 constexpr const char* EVENT_NAME = "DISTRIBUTED_DFS_BEHAVIOR"; 56 constexpr const char* ORG_PKG = "distributedfile"; 57 constexpr const char* BIZ_STATE = "BIZ_STATE"; 58 constexpr const char* ERROR_CODE = "ERROR_CODE"; 59 constexpr const char* PACKAGE_NAME = "PACKAGE_NAME"; 60 constexpr const char* CONCURRENT_ID = "CONCURRENT_ID"; 61 static constexpr HiviewDFX::HiSysEvent::EventType TYPE = HiviewDFX::HiSysEvent::EventType::BEHAVIOR; 62 63 #define RADAR_REPORT(bizScene, bizStage, stageRes, ...) \ 64 ({ \ 65 HiSysEventWrite(RadarReporter::DOMAIN, RadarReporter::EVENT_NAME, RadarReporter::TYPE, \ 66 "ORG_PKG", RadarReporter::ORG_PKG, "FUNC", __FUNCTION__, \ 67 "BIZ_SCENE", bizScene, "BIZ_STAGE", bizStage, "STAGE_RES", stageRes, \ 68 ##__VA_ARGS__); \ 69 }) 70 } // namespace RadarReporter 71 } // namespace ModuleFileIO 72 } // namespace FileManagement 73 } // namespace OHOS 74 #endif //DISTRIBUTEDFILE_DFS_EVENT_DFX_H