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 #include "permission_used_type_info.h" 29 30 namespace OHOS { 31 namespace Security { 32 namespace AccessToken { 33 struct RecordManagerAsyncContext : public PrivacyAsyncWorkData { RecordManagerAsyncContextRecordManagerAsyncContext34 explicit RecordManagerAsyncContext(napi_env env) : PrivacyAsyncWorkData(env) {} 35 36 AccessTokenID tokenId = 0; 37 std::string permissionName; 38 int32_t successCount = 0; 39 int32_t failCount = 0; 40 int32_t pid = -1; 41 PermissionUsedType type = PermissionUsedType::NORMAL_TYPE; 42 PermissionUsedRequest request; 43 PermissionUsedResult result; 44 int32_t retCode = -1; 45 bool status = true; 46 }; 47 48 struct PermissionUsedTypeAsyncContext : public PrivacyAsyncWorkData { PermissionUsedTypeAsyncContextPermissionUsedTypeAsyncContext49 explicit PermissionUsedTypeAsyncContext(napi_env env) : PrivacyAsyncWorkData(env) {} 50 AccessTokenID tokenId = 0; 51 std::string permissionName; 52 std::vector<PermissionUsedTypeInfo> results; 53 int32_t retCode = -1; 54 }; 55 56 typedef PermActiveChangeContext RegisterPermActiveChangeContext; 57 58 struct UnregisterPermActiveChangeContext : public PermActiveChangeContext { 59 std::vector<std::string> permList; 60 }; 61 62 napi_value AddPermissionUsedRecord(napi_env env, napi_callback_info cbinfo); 63 napi_value StartUsingPermission(napi_env env, napi_callback_info cbinfo); 64 napi_value StopUsingPermission(napi_env env, napi_callback_info cbinfo); 65 napi_value GetPermissionUsedRecords(napi_env env, napi_callback_info cbinfo); 66 napi_value RegisterPermActiveChangeCallback(napi_env env, napi_callback_info cbInfo); 67 napi_value UnregisterPermActiveChangeCallback(napi_env env, napi_callback_info cbInfo); 68 napi_value GetPermissionUsedTypeInfos(napi_env env, napi_callback_info cbInfo); 69 napi_value SetPermissionUsedRecordToggleStatus(napi_env env, napi_callback_info cbInfo); 70 napi_value GetPermissionUsedRecordToggleStatus(napi_env env, napi_callback_info cbinfo); 71 } // namespace AccessToken 72 } // namespace Security 73 } // namespace OHOS 74 #endif /* INTERFACES_KITS_PERMISSION_USED_MANAGER_NAPI_H */ 75