• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 ACCESSTOKEN_HISYSEVENT_ADAPTER_H
17 #define ACCESSTOKEN_HISYSEVENT_ADAPTER_H
18 
19 #include <string>
20 #include "access_token.h"
21 #include "hisysevent_common.h"
22 
23 namespace OHOS {
24 namespace Security {
25 namespace AccessToken {
26 // base info
27 struct BaseDfxInfo {
28     AccessTokenID tokenId = 0;
29     int32_t userID = 0;
30     std::string bundleName;
31     int32_t instIndex;
32     int64_t duration = 0;
33     int32_t ipcCode = -1;
34 };
35 
36 // add or update or delete
37 struct HapDfxInfo : public BaseDfxInfo {
38     AccessTokenID oriTokenId;
39     AccessTokenIDEx tokenIdEx;
40     std::string permInfo;
41     std::string aclInfo;
42     std::string preauthInfo;
43     std::string extendInfo;
44 
45     // only for add
46     int32_t sceneCode;
47     HapDlpType dlpType;
48     bool isRestore;
49 };
50 
51 // init
52 struct InitDfxInfo {
53     int32_t pid;
54     uint32_t hapSize;
55     uint32_t nativeSize;
56     uint32_t permDefSize;
57     uint32_t dlpSize;
58     uint32_t parseConfigFlag;
59 };
60 
61 void ReportSysEventPerformance();
62 void ReportSysEventServiceStart(const InitDfxInfo& info);
63 void ReportSysEventServiceStartError(SceneCode scene, const std::string& errMsg, int32_t errCode);
64 void ReportSysCommonEventError(int32_t ipcCode, int32_t errCode);
65 void ReportSysEventAddHap(int32_t errorCode, const HapDfxInfo& info, bool needReportFault);
66 void ReportSysEventUpdateHap(int32_t errorCode, const HapDfxInfo& info);
67 void ReportSysEventDelHap(int32_t errorCode, const HapDfxInfo& info);
68 void ReportSysEventDbException(AccessTokenDbSceneCode sceneCode, int32_t errCode, const std::string& tableName);
69 } // namespace AccessToken
70 } // namespace Security
71 } // namespace OHOS
72 #endif // ACCESSTOKEN_HISYSEVENT_ADAPTER_H
73