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 PERMISSION_HELPER_H 17#define PERMISSION_HELPER_H 18 19#include "accesstoken_kit.h" 20#include "singleton.h" 21 22namespace OHOS { 23namespace MMI { 24class PermissionHelper final { 25public: 26 static const uint32_t APL_NORMAL = 1 << OHOS::Security::AccessToken::APL_NORMAL; 27 static const uint32_t APL_SYSTEM_BASIC = 1 << OHOS::Security::AccessToken::APL_SYSTEM_BASIC; 28 static const uint32_t APL_SYSTEM_CORE = 1 << OHOS::Security::AccessToken::APL_SYSTEM_CORE; 29 static const uint32_t APL_SYSTEM_BASIC_CORE = APL_SYSTEM_BASIC + APL_SYSTEM_CORE; 30 31public: 32 static PermissionHelper* GetInstance() 33 { 34 static PermissionHelper instance; 35 return &instance; 36 } 37 PermissionHelper(const PermissionHelper&) = delete; 38 PermissionHelper& operator=(const PermissionHelper&) = delete; 39 40 bool CheckMonitor(); 41 bool CheckInterceptor(); 42 int32_t GetTokenType(); 43 bool CheckDispatchControl(); 44 bool VerifySystemApp(); 45 bool CheckInfraredEmmit(); 46 bool RequestFromShell(); 47 bool CheckMouseCursor(); 48 bool CheckInputEventFilter(); 49 bool CheckAuthorize(); 50 51private: 52 PermissionHelper() {} 53 bool CheckHapPermission(uint32_t tokenId, std::string permissionCode); 54 bool CheckHapPermission(std::string permissionCode); 55}; 56 57#define PER_HELPER PermissionHelper::GetInstance() 58} // namespace MMI 59} // namespace OHOS 60#endif // PERMISSION_HELPER_H 61