1 /* 2 * Copyright (c) 2023-2025 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 PERMISSION_MAP_H 17 #define PERMISSION_MAP_H 18 19 #include <map> 20 #include <string> 21 #include "access_token.h" 22 23 #include "access_token.h" 24 #include "permission_def.h" 25 26 namespace OHOS { 27 namespace Security { 28 namespace AccessToken { 29 struct PermissionBriefDef { 30 char* permissionName; 31 GrantMode grantMode; 32 ATokenAplEnum availableLevel; 33 ATokenAvailableTypeEnum availableType; 34 bool provisionEnable; 35 bool distributedSceneEnable; 36 bool isKernelEffect; 37 bool hasValue; 38 }; 39 40 bool TransferPermissionToOpcode(const std::string& permissionName, uint32_t& opCode); 41 bool TransferOpcodeToPermission(uint32_t opCode, std::string& permissionName); 42 bool IsUserGrantPermission(const std::string& permission); 43 bool IsDefinedPermission(const std::string& permission); 44 bool GetPermissionBriefDef(const std::string& permission, PermissionBriefDef &permissionBriefDef); 45 void GetPermissionBriefDef(uint32_t code, PermissionBriefDef &permissionBriefDef); 46 void ConvertPermissionBriefToDef(const PermissionBriefDef& briefDef, PermissionDef &def); 47 bool IsPermissionValidForHap(const std::string& permissionName); 48 size_t GetDefPermissionsSize(); 49 const char* GetPermDefVersion(); 50 } // namespace AccessToken 51 } // namespace Security 52 } // namespace OHOS 53 #endif // PERMISSION_CODE_H 54