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 16 #ifndef INTERFACES_INNER_KITS_PRIVACY_KIT_H 17 #define INTERFACES_INNER_KITS_PRIVACY_KIT_H 18 19 #include <string> 20 21 #include "access_token.h" 22 #include "on_permission_used_record_callback.h" 23 #include "permission_used_request.h" 24 #include "permission_used_result.h" 25 #include "perm_active_status_customized_cbk.h" 26 #include "state_customized_cbk.h" 27 28 namespace OHOS { 29 namespace Security { 30 namespace AccessToken { 31 class PrivacyKit { 32 public: 33 static int32_t AddPermissionUsedRecord( 34 AccessTokenID tokenID, const std::string& permissionName, int32_t successCount, int32_t failCount); 35 static int32_t StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName); 36 static int32_t StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName, 37 const std::shared_ptr<StateCustomizedCbk>& callback); 38 static int32_t StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName); 39 static int32_t RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID); 40 static int32_t GetPermissionUsedRecords(const PermissionUsedRequest& request, PermissionUsedResult& result); 41 static int32_t GetPermissionUsedRecords( 42 const PermissionUsedRequest& request, const sptr<OnPermissionUsedRecordCallback>& callback); 43 static int32_t RegisterPermActiveStatusCallback(const std::shared_ptr<PermActiveStatusCustomizedCbk>& callback); 44 static int32_t UnRegisterPermActiveStatusCallback(const std::shared_ptr<PermActiveStatusCustomizedCbk>& callback); 45 static bool IsAllowedUsingPermission(AccessTokenID tokenID, const std::string& permissionName); 46 }; 47 } // namespace AccessToken 48 } // namespace Security 49 } // namespace OHOS 50 #endif 51