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 OBJECT_RADAR_REPORTER_H
17 #define OBJECT_RADAR_REPORTER_H
18 
19 #include "hisysevent_c.h"
20 #include <string>
21 #include "visibility.h"
22 
23 namespace OHOS::ObjectStore {
24 enum BizScene {
25     CREATE = 1,
26     SAVE = 2,
27     DATA_RESTORE = 3,
28 };
29 enum CreateStage {
30     INIT_STORE = 1,
31     CREATE_TABLE = 2,
32     RESTORE = 3,
33     TRANSFER = 4,
34 };
35 enum SaveStage {
36     SAVE_TO_SERVICE = 1,
37     SAVE_TO_STORE = 2,
38     PUSH_ASSETS = 3,
39     SYNC_DATA = 4,
40 };
41 enum DataRestoreStage {
42     DATA_RECV = 1,
43     ASSETS_RECV = 2,
44     NOTIFY = 3,
45 };
46 enum StageRes {
47     IDLE = 0,
48     RADAR_SUCCESS = 1,
49     RADAR_FAILED = 2,
50     CANCELLED = 3,
51 };
52 enum BizState {
53     START = 1,
54     FINISHED = 2,
55 };
56 enum ErrorCode {
57     OFFSET = 27525120,
58     DUPLICATE_CREATE = OFFSET,
59     NO_MEMORY = OFFSET + 1,
60     SA_DIED = OFFSET + 2,
61     TIMEOUT = OFFSET + 3,
62     IPC_ERROR = OFFSET + 4,
63     NO_PERMISSION = OFFSET + 5,
64     GETKV_FAILED = OFFSET + 6,
65     DB_NOT_INIT = OFFSET + 7,
66 };
67 constexpr char DOMAIN[] = "DISTDATAMGR";
68 constexpr char EVENT_NAME[] = "DISTRIBUTED_DATA_OBJECT_BEHAVIOR";
69 constexpr char ORG_PKG[] = "distributeddata";
70 
71 class API_EXPORT RadarReporter {
72 public:
73     static void ReportStateStart(std::string func, int32_t scene, int32_t stage, int32_t stageRes,
74         int32_t state, std::string appCaller);
75     static void ReportStateFinished(std::string func, int32_t scene, int32_t stage,
76         int32_t stageRes, int32_t state);
77     static void ReportStateError(std::string func, int32_t scene, int32_t stage, int32_t stageRes,
78         int32_t errCode, int32_t state);
79     static void ReportStage(std::string func, int32_t scene, int32_t stage, int32_t stageRes);
80     static void ReportStageError(std::string func, int32_t scene, int32_t stage,
81         int32_t stageRes, int32_t errCode);
82 };
83 } // namespace OHOS::ObjectStore
84 #endif // OBJECT_RADAR_REPORTER_H
85