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_DAEMON_EVENT_DFX_H
17 #define DISTRIBUTEDFILE_DAEMON_EVENT_DFX_H
18 
19 #include "hisysevent.h"
20 
21 namespace OHOS {
22 namespace Storage {
23 namespace DistributedFile {
24 namespace RadarReporter {
25 using namespace OHOS::HiviewDFX;
26 static constexpr int DIST_DATA_MGR_SYS_ID = 0xd;
27 static constexpr int DFS_ID = 13;
28 enum BizScene : std::int32_t {
29     DFX_SET_DFS = 1,
30 };
31 
32 enum BizStageSetDfs : std::int32_t {
33     DFX_SET_BIZ_SCENE = 1,
34     DFX_BUILD__LINK = 2,
35 };
36 
37 enum StageRes : std::int32_t {
38     DFX_IDLE = 0,
39     DFX_SUCCESS = 1,
40     DFX_FAILED = 2,
41     DFX_CANCELLED = 3,
42 };
43 
44 enum BizState : std::int32_t {
45     DFX_BEGIN = 1,
46     DFX_END = 2,
47 };
48 
49 enum ErrorCode : std::int32_t {
50     DFS_ERROR = (DIST_DATA_MGR_SYS_ID << 21) | (DFS_ID << 16),
51     PREPARE_COPY_SESSION_ERROR,
52     COPY_TO_SANDBOX_ERROR,
53     SEND_FILE_ERROR,
54     GET_SAME_ACCOUNT_ERROR,
55     CREAT_SOCKET_ERROR,
56     BIND_SOCKET_ERROR,
57     CHECK_URI_PREMISSION_ERROR,
58     GET_SYSTEM_ABILITY_ERROR,
59     GET_REMOTE_COPY_INFO_ERROR,
60     GET_HAP_TOKEN_INFO_ERROR,
61     CREAT_VALID_PATH_ERROR,
62     FILE_TRANS_ERROR,
63     REQUEST_SEND_FILE_ERROR,
64 };
65 
66 const std::string uriPermMgr = "UriPermMgr";
67 const std::string appFileService = "APPFILESERVICE";
68 const std::string dSoftBus = "DSOFTBUS";
69 const std::string saMgr = "SAMGR";
70 const std::string deviceManager = "DeviceManager";
71 const std::string accessTokenKit = "AccessTokenKit";
72 
73 static constexpr char DOMAIN[] = "DISTDATAMGR";
74 constexpr const char* EVENT_NAME = "DISTRIBUTED_DFS_BEHAVIOR";
75 constexpr const char* ORG_PKG = "distributedfile";
76 constexpr const char* BIZ_STATE = "BIZ_STATE";
77 constexpr const char* ERROR_CODE = "ERROR_CODE";
78 constexpr const char* PACKAGE_NAME = "PACKAGE_NAME";
79 constexpr const char* CONCURRENT_ID = "CONCURRENT_ID";
80 static constexpr HiviewDFX::HiSysEvent::EventType TYPE = HiviewDFX::HiSysEvent::EventType::BEHAVIOR;
81 
82 #define RADAR_REPORT(bizScene, bizStage, stageRes, ...)                                    \
83 ({                                                                                         \
84     HiSysEventWrite(RadarReporter::DOMAIN, RadarReporter::EVENT_NAME, RadarReporter::TYPE, \
85         "ORG_PKG", RadarReporter::ORG_PKG, "FUNC", __FUNCTION__,                           \
86         "BIZ_SCENE", bizScene, "BIZ_STAGE", bizStage, "STAGE_RES", stageRes,               \
87         ##__VA_ARGS__);                                                                    \
88 })
89 } // namespace RadarReporter
90 } // namespace DistributedFile
91 } // namespace Storage
92 } // namespace OHOS
93 #endif //DISTRIBUTEDFILE_DAEMON_EVENT_DFX_H