• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #ifndef  INTERFACES_KITS_PERMISSION_USED_MANAGER_NAPI_H
16 #define  INTERFACES_KITS_PERMISSION_USED_MANAGER_NAPI_H
17 
18 #include <string>
19 #include <vector>
20 
21 #include "access_token.h"
22 #include "active_change_response_info.h"
23 #include "napi/native_api.h"
24 #include "napi/native_node_api.h"
25 #include "napi_context_common.h"
26 #include "permission_used_request.h"
27 #include "permission_used_result.h"
28 
29 namespace OHOS {
30 namespace Security {
31 namespace AccessToken {
32 struct RecordManagerAsyncContext : public PrivacyAsyncWorkData {
RecordManagerAsyncContextRecordManagerAsyncContext33     explicit RecordManagerAsyncContext(napi_env env) : PrivacyAsyncWorkData(env) {}
34 
35     AccessTokenID   tokenId = 0;
36     std::string     permissionName;
37     int32_t         successCount = 0;
38     int32_t         failCount = 0;
39     PermissionUsedRequest request;
40     PermissionUsedResult result;
41     int32_t retCode = -1;
42 };
43 
44 typedef PermActiveChangeContext RegisterPermActiveChangeContext;
45 
46 struct UnregisterPermActiveChangeContext : public PermActiveChangeContext {
47     std::vector<std::string> permList;
48 };
49 
50 napi_value AddPermissionUsedRecord(napi_env env, napi_callback_info cbinfo);
51 napi_value StartUsingPermission(napi_env env, napi_callback_info cbinfo);
52 napi_value StopUsingPermission(napi_env env, napi_callback_info cbinfo);
53 napi_value GetPermissionUsedRecords(napi_env env, napi_callback_info cbinfo);
54 napi_value RegisterPermActiveChangeCallback(napi_env env, napi_callback_info cbInfo);
55 napi_value UnregisterPermActiveChangeCallback(napi_env env, napi_callback_info cbInfo);
56 }  // namespace AccessToken
57 }  // namespace Security
58 }  // namespace OHOS
59 #endif /*  INTERFACES_KITS_PERMISSION_USED_MANAGER_NAPI_H */
60