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