• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 OHOS_ROSEN_SESSION_PERMISSION_H
17 #define OHOS_ROSEN_SESSION_PERMISSION_H
18 
19 #include <string>
20 
21 namespace OHOS {
22 namespace Rosen {
23 namespace PermissionConstants {
24 constexpr const char* PERMISSION_MANAGE_MISSION = "ohos.permission.MANAGE_MISSIONS";
25 constexpr const char* PERMISSION_KILL_APP_PROCESS = "ohos.permission.KILL_APP_PROCESSES";
26 constexpr const char* PERMISSION_MAIN_WINDOW_TOPMOST = "ohos.permission.WINDOW_TOPMOST";
27 constexpr const char* PERMISSION_CALLED_EXTENSION_ON_LOCK_SCREEN = "ohos.permission.CALLED_UIEXTENSION_ON_LOCK_SCREEN";
28 constexpr const char* PERMISSION_WRITE_APP_LOCK = "ohos.permission.WRITE_APP_LOCK";
29 constexpr const char* PERMISSION_SET_ABILITY_INSTANCE_INFO = "ohos.permission.SET_ABILITY_INSTANCE_INFO";
30 constexpr const char* PERMISSION_VISIBLE_WINDOW_INFO = "ohos.permission.VISIBLE_WINDOW_INFO";
31 constexpr const char* PERMISSION_FLOATING_BALL = "ohos.permission.USE_FLOAT_BALL";
32 constexpr const char* PERMISSION_WINDOW_TRANSPARENT = "ohos.permission.SET_WINDOW_TRANSPARENT";
33 }
34 class SessionPermission {
35 public:
36     static bool IsSystemServiceCalling(bool needPrintLog = true);
37     static bool IsSystemCalling();
38     static bool VerifySessionPermission();
39     static bool JudgeCallerIsAllowedToUseSystemAPI();
40     static bool IsShellCall();
41     static bool IsStartByHdcd();
42     static bool IsStartedByInputMethod();
43     static bool IsSACalling();
44     static bool VerifyCallingPermission(const std::string& permissionName);
45     static bool VerifyPermissionByCallerToken(const uint32_t callerToken, const std::string& permissionName);
46     static bool VerifyPermissionByBundleName(
47         const std::string& permissionName, const std::string& bundleName, uint32_t userId);
48     static bool IsSameBundleNameAsCalling(const std::string& bundleName);
49     static bool IsSameAppAsCalling(const std::string& bundleName, const std::string& appIdentifier);
50     static bool IsStartedByUIExtension();
51     static bool CheckCallingIsUserTestMode(pid_t pid);
52     static bool IsBetaVersion();
53     static bool IsSystemAppCall();
54     static bool IsSystemAppCallByCallingTokenID(uint32_t callingTokenId);
55     static bool IsFoundationCall();
56     static std::string GetCallingBundleName();
57     static bool IsTokenNativeOrShellType(uint32_t tokenId);
58 };
59 } // Rosen
60 } // OHOS
61 #endif // OHOS_ROSEN_SESSION_PERMISSION_H