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 PREFERENCES_DFX_ADAPTER_H
17 #define PREFERENCES_DFX_ADAPTER_H
18 
19 #include <string>
20 
21 #include "preferences_errno.h"
22 namespace OHOS {
23 namespace NativePreferences {
24 
25 static constexpr const char *NORMAL_DB = "XMLDB";
26 static constexpr const char *ENHANCE_DB = "ENHANCEDB";
27 static constexpr const char *EVENT_NAME_DB_CORRUPTED = "DATABASE_CORRUPTED";
28 static constexpr const char *DISTRIBUTED_DATAMGR = "DISTDATAMGR";
29 
30 struct ReportParam {
31     std::string bundleName; // bundleName
32     std::string dbType;     // NORMAL_DB or ENHANCE_DB
33     std::string storeName; // filename
34     uint32_t errCode = E_OK;
35     int32_t errnoCode = 0; // errno
36     // additional info, "operation: reason", such as "read failed"
37     std::string appendix; // additional info
38 };
39 
40 class PreferencesDfxManager {
41 public:
42     static void ReportDbFault(const ReportParam &reportParam);
43     static std::string GetModuleName();
44 };
45 } // namespace NativePreferences
46 } // namespace OHOS
47 #endif