• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
17  * @addtogroup Privacy
18  * @{
19  *
20  * @brief Provides sensitive data access management.
21  *
22  * @since 8.0
23  * @version 8.0
24  */
25 
26 /**
27  * @file permission_used_result.h
28  *
29  * @brief Declares structs.
30  *
31  * @since 8.0
32  * @version 8.0
33  */
34 
35 #ifndef PERMISSION_USED_RESPONSE_H
36 #define PERMISSION_USED_RESPONSE_H
37 
38 #include <string>
39 #include <vector>
40 #include "access_token.h"
41 #include "active_change_response_info.h"
42 
43 namespace OHOS {
44 namespace Security {
45 namespace AccessToken {
46 /**
47  * @brief Record used detail struct
48  */
49 struct UsedRecordDetail {
50     /**
51      * permission active state, for details about the valid values,
52      * see the definition of ActiveChangeType in
53      * the active_change_response_info.h file.
54      */
55     int32_t status = 0;
56     /**
57      * permission lockscreen state, for details about the valid values,
58      * see the definition of ActiveChangeType in
59      * the active_change_response_info.h file.
60      */
61     int32_t lockScreenStatus = LockScreenStatusChangeType::PERM_ACTIVE_IN_UNLOCKED;
62     /** permission active state change timestamp */
63     int64_t timestamp = 0L;
64     /** permission active state remain times */
65     int64_t accessDuration = 0L;
66     /** The value of successCount or failCount passed in to addPermissionUsedRecord */
67     int32_t count = 0;
68 };
69 
70 /**
71  * @brief Permission used record struct
72  */
73 struct PermissionUsedRecord {
74     /** permission name */
75     std::string permissionName;
76     /** permission access count */
77     int32_t accessCount = 0;
78     /** permission reject count */
79     int32_t rejectCount = 0;
80     /** permission last access timestamp */
81     int64_t lastAccessTime = 0L;
82     /** permission last reject timestamp */
83     int64_t lastRejectTime = 0L;
84     /** permission last access remain time */
85     int64_t lastAccessDuration = 0L;
86     /** UsedRecordDetail list */
87     std::vector<UsedRecordDetail> accessRecords;
88     /** UsedRecordDetail list */
89     std::vector<UsedRecordDetail> rejectRecords;
90 };
91 
92 /**
93  * @brief Bundle used record struct
94  */
95 struct BundleUsedRecord {
96     /** token id */
97     AccessTokenID tokenId;
98     /** is remote token */
99     bool isRemote;
100     /** device id */
101     std::string deviceId;
102     /** bundle name */
103     std::string bundleName;
104     /** PermissionUsedRecord list */
105     std::vector<PermissionUsedRecord> permissionRecords;
106 };
107 
108 /**
109  * @brief Permission used result struct
110  */
111 struct PermissionUsedResult {
112     /** begin timestamp */
113     int64_t beginTimeMillis = 0L;
114     /** end timestamp */
115     int64_t endTimeMillis = 0L;
116     /** BundleUsedRecord list */
117     std::vector<BundleUsedRecord> bundleRecords;
118 };
119 } // namespace AccessToken
120 } // namespace Security
121 } // namespace OHOS
122 #endif // PERMISSION_USED_RESPONSE_H
123