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 DISTRIBUTEDDATAMGR_PASTEBOARD_EVENT_DFX_H
17#define DISTRIBUTEDDATAMGR_PASTEBOARD_EVENT_DFX_H
18
19#include "hisysevent.h"
20namespace OHOS {
21namespace MiscServices {
22namespace RadarReporter {
23using namespace OHOS::HiviewDFX;
24enum BizScene : std::int32_t {
25    DFX_SET_PASTEBOARD = 1,
26    DFX_DISTRIBUTED_PASTEBOARD_BROADCAST_SEND = 2,
27    DFX_DISTRIBUTED_PASTEBOARD_BROADCAST_RECEIVE = 3,
28    DFX_DISTRIBUTED_PASTEBOARD_BROADCAST_PULL = 4,
29    DFX_GET_PASTEBOARD = 5,
30    DFX_CLEAR_PASTEBOARD = 6,
31    DFX_OBSERVER = 7,
32    DFX_PLUGIN_CREATE_DESTROY = 8,
33};
34
35enum BizStageSetPasteboard : std::int32_t {
36    DFX_SET_BIZ_SCENE = 0,
37    DFX_CHECK_SET_SERVER = 1,
38    DFX_CHECK_SET_DELAY_COPY = 2,
39    DFX_CHECK_SET_AUTHORITY = 3,
40    DFX_CHECK_ONLINE_DEVICE = 4,
41    DFX_LOAD_DISTRIBUTED_PLUGIN = 5,
42};
43
44enum BizStageBroadcastSend : std::int32_t {
45    DFX_REGISTER_SEND_LISTEN = 1,
46    DFX_RECORD_SEND_BROADCAST = 2,
47};
48
49enum BizStageBroadcastReceive : std::int32_t {
50    DFX_REGISTER_RECEIVE_LISTEN = 1,
51    DFX_RECORD_RECEIVE_BROADCAST = 2,
52};
53
54enum BizStageBroadcastPull : std::int32_t {
55    DFX_PRE_SYNC = 1,
56    DFX_GET_PASTE_DATA_SYNC = 2,
57    DFX_SYNC_DETAIL = 3,
58};
59
60enum BizStageGetPasteboard : std::int32_t {
61    DFX_GET_BIZ_SCENE = 0,
62    DFX_CHECK_GET_SERVER = 1,
63    DFX_CHECK_GET_DELAY_PASTE = 2,
64    DFX_CHECK_GET_AUTHORITY = 3,
65    DFX_GET_DATA_INFO = 4,
66    DFX_LOCAL_PASTE_END = 5,
67    DFX_DISTRIBUTED_PASTE_END = 6,
68    DFX_DISTRIBUTED_FILE_START = 7,
69    DFX_DISTRIBUTED_FILE_END = 8,
70};
71
72enum BizStageClearPasteboard : std::int32_t {
73    DFX_MANUAL_CLEAR = 1,
74    DFX_AUTO_CLEAR = 2,
75};
76
77enum BizStageObserver : std::int32_t {
78    DFX_ADD_OBSERVER = 1,
79    DFX_REMOVE_SINGLE_OBSERVER = 2,
80    DFX_REMOVE_ALL_OBSERVER = 3,
81};
82
83enum BizStagePlugin : std::int32_t {
84    DFX_PLUGIN_CREATE = 1,
85    DFX_PLUGIN_DESTROY = 2,
86};
87
88enum StageRes : std::int32_t {
89    DFX_IDLE = 0,
90    DFX_SUCCESS = 1,
91    DFX_FAILED = 2,
92    DFX_CANCELLED = 3,
93};
94
95enum BizState : std::int32_t {
96    DFX_BEGIN = 1,
97    DFX_END = 2,
98};
99
100class PasteboardDfxUntil {
101public:
102    static std::string GetAnonymousID(const std::string &deviceId);
103
104private:
105    static constexpr int minIdLen = 10;
106    static constexpr int maskIdLen = 5;
107};
108
109constexpr char DOMAIN[] = "DISTDATAMGR";
110constexpr const char *EVENT_NAME = "DISTRIBUTED_PASTEBOARD_BEHAVIOR";
111constexpr const char *ORG_PKG = "distributeddata";
112constexpr const char *BIZ_STATE = "BIZ_STATE";
113constexpr const char *ERROR_CODE = "ERROR_CODE";
114constexpr const char *SET_DATA_APP = "SET_DATA_APP";
115constexpr const char *SET_DATA_TYPE = "SET_DATA_TYPE";
116constexpr const char *GET_DATA_APP = "GET_DATA_APP";
117constexpr const char *GET_DATA_TYPE = "GET_DATA_TYPE";
118constexpr const char *LOCAL_DEV_TYPE = "LOCAL_DEV_TYPE";
119constexpr const char *COVER_DELAY_DATA = "COVER_DELAY_DATA";
120constexpr const char *SEND_BROADCAST_TIME = "SEND_BROADCAST_TIME_64";
121constexpr const char *RECEIVE_BROADCAST_TIME = "RECEIVE_BROADCAST_TIME_64";
122constexpr const char *SEQ_ID = "SEQ_ID";
123constexpr const char *CONCURRENT_ID = "CONCURRENT_ID";
124constexpr const char *DIS_SYNC_TIME = "DIS_SYNC_TIME";
125constexpr const char *PACKAGE_NAME = "PACKAGE_NAME";
126constexpr const char *PEER_NET_ID = "PEER_NET_ID";
127constexpr const char *PEER_UDID = "PEER_UDID";
128constexpr HiviewDFX::HiSysEvent::EventType TYPE = HiviewDFX::HiSysEvent::EventType::BEHAVIOR;
129
130#define RADAR_REPORT(bizScene, bizStage, stageRes, ...)                                                              \
131    ({                                                                                                               \
132        HiSysEventWrite(RadarReporter::DOMAIN, RadarReporter::EVENT_NAME, RadarReporter::TYPE, "ORG_PKG",            \
133            RadarReporter::ORG_PKG, "FUNC", __FUNCTION__, "BIZ_SCENE", bizScene, "BIZ_STAGE", bizStage, "STAGE_RES", \
134            stageRes, ##__VA_ARGS__);                                                                                \
135    })
136} // namespace RadarReporter
137} // namespace MiscServices
138} // namespace OHOS
139#endif // DISTRIBUTEDDATAMGR_PASTEBOARD_EVENT_DFX_H
140