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 #include "permission_used_type.h"
43 
44 namespace OHOS {
45 namespace Security {
46 namespace AccessToken {
47 /**
48  * @brief Record used detail struct
49  */
50 struct UsedRecordDetail {
51     /**
52      * permission active state, for details about the valid values,
53      * see the definition of ActiveChangeType in
54      * the active_change_response_info.h file.
55      */
56     int32_t status = 0;
57     /**
58      * permission lockscreen state, for details about the valid values,
59      * see the definition of ActiveChangeType in
60      * the active_change_response_info.h file.
61      */
62     int32_t lockScreenStatus = LockScreenStatusChangeType::PERM_ACTIVE_IN_UNLOCKED;
63     /** permission active state change timestamp */
64     int64_t timestamp = 0L;
65     /** permission active state remain times */
66     int64_t accessDuration = 0L;
67     /** The value of successCount or failCount passed in to addPermissionUsedRecord */
68     int32_t count = 0;
69     /** permission used type */
70     PermissionUsedType type;
71 };
72 
73 /**
74  * @brief Permission used record struct
75  */
76 struct PermissionUsedRecord {
77     /** permission name */
78     std::string permissionName;
79     /** permission access count */
80     int32_t accessCount = 0;
81     /** permission reject count */
82     int32_t rejectCount = 0;
83     /** permission last access timestamp */
84     int64_t lastAccessTime = 0L;
85     /** permission last reject timestamp */
86     int64_t lastRejectTime = 0L;
87     /** permission last access remain time */
88     int64_t lastAccessDuration = 0L;
89     /** UsedRecordDetail list */
90     std::vector<UsedRecordDetail> accessRecords;
91     /** UsedRecordDetail list */
92     std::vector<UsedRecordDetail> rejectRecords;
93 };
94 
95 /**
96  * @brief Bundle used record struct
97  */
98 struct BundleUsedRecord {
99     /** token id */
100     AccessTokenID tokenId;
101     /** is remote token */
102     bool isRemote;
103     /** device id */
104     std::string deviceId;
105     /** bundle name */
106     std::string bundleName;
107     /** PermissionUsedRecord list */
108     std::vector<PermissionUsedRecord> permissionRecords;
109 };
110 
111 /**
112  * @brief Permission used result struct
113  */
114 struct PermissionUsedResult {
115     /** begin timestamp */
116     int64_t beginTimeMillis = 0L;
117     /** end timestamp */
118     int64_t endTimeMillis = 0L;
119     /** BundleUsedRecord list */
120     std::vector<BundleUsedRecord> bundleRecords;
121 };
122 } // namespace AccessToken
123 } // namespace Security
124 } // namespace OHOS
125 #endif // PERMISSION_USED_RESPONSE_H
126