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 22 namespace OHOS { 23 namespace MMI { 24 class PermissionHelper final { 25 DECLARE_DELAYED_SINGLETON(PermissionHelper); 26 public: 27 static const uint32_t APL_NORMAL = 1 << OHOS::Security::AccessToken::APL_NORMAL; 28 static const uint32_t APL_SYSTEM_BASIC = 1 << OHOS::Security::AccessToken::APL_SYSTEM_BASIC; 29 static const uint32_t APL_SYSTEM_CORE = 1 << OHOS::Security::AccessToken::APL_SYSTEM_CORE; 30 static const uint32_t APL_SYSTEM_BASIC_CORE = APL_SYSTEM_BASIC + APL_SYSTEM_CORE; 31 32 public: 33 DISALLOW_COPY_AND_MOVE(PermissionHelper); 34 bool CheckPermission(uint32_t required); 35 bool CheckMonitor(); 36 int32_t GetTokenType(); 37 38 private: 39 bool CheckHapPermission(uint32_t tokenId, uint32_t required); 40 bool CheckMonitorPermission(uint32_t tokenId); 41 }; 42 43 #define PerHelper ::OHOS::DelayedSingleton<PermissionHelper>::GetInstance() 44 } // namespace MMI 45 } // namespace OHOS 46 #endif // PERMISSION_HELPER_H 47