1e0dac50fSopenharmony_ci/* 2e0dac50fSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3e0dac50fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4e0dac50fSopenharmony_ci * you may not use this file except in compliance with the License. 5e0dac50fSopenharmony_ci * You may obtain a copy of the License at 6e0dac50fSopenharmony_ci * 7e0dac50fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8e0dac50fSopenharmony_ci * 9e0dac50fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10e0dac50fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11e0dac50fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e0dac50fSopenharmony_ci * See the License for the specific language governing permissions and 13e0dac50fSopenharmony_ci * limitations under the License. 14e0dac50fSopenharmony_ci */ 15e0dac50fSopenharmony_ci 16e0dac50fSopenharmony_ci#ifndef OHOS_ROSEN_SESSION_PERMISSION_H 17e0dac50fSopenharmony_ci#define OHOS_ROSEN_SESSION_PERMISSION_H 18e0dac50fSopenharmony_ci 19e0dac50fSopenharmony_ci#include <string> 20e0dac50fSopenharmony_ci 21e0dac50fSopenharmony_cinamespace OHOS { 22e0dac50fSopenharmony_cinamespace Rosen { 23e0dac50fSopenharmony_cinamespace PermissionConstants { 24e0dac50fSopenharmony_ciconstexpr const char* PERMISSION_MANAGE_MISSION = "ohos.permission.MANAGE_MISSIONS"; 25e0dac50fSopenharmony_ciconstexpr const char* PERMISSION_KILL_APP_PROCESS = "ohos.permission.KILL_APP_PROCESSES"; 26e0dac50fSopenharmony_ciconstexpr const char* PERMISSION_MAIN_WINDOW_TOPMOST = "ohos.permission.WINDOW_TOPMOST"; 27e0dac50fSopenharmony_ci} 28e0dac50fSopenharmony_ciclass SessionPermission { 29e0dac50fSopenharmony_cipublic: 30e0dac50fSopenharmony_ci static bool IsSystemServiceCalling(bool needPrintLog = true); 31e0dac50fSopenharmony_ci static bool IsSystemCalling(); 32e0dac50fSopenharmony_ci static bool VerifySessionPermission(); 33e0dac50fSopenharmony_ci static bool JudgeCallerIsAllowedToUseSystemAPI(); 34e0dac50fSopenharmony_ci static bool IsShellCall(); 35e0dac50fSopenharmony_ci static bool IsStartByHdcd(); 36e0dac50fSopenharmony_ci static bool IsStartedByInputMethod(); 37e0dac50fSopenharmony_ci static bool IsSACalling(); 38e0dac50fSopenharmony_ci static bool VerifyCallingPermission(const std::string& permissionName); 39e0dac50fSopenharmony_ci static bool VerifyPermissionByCallerToken(const uint32_t callerToken, const std::string& permissionName); 40e0dac50fSopenharmony_ci static bool IsSameBundleNameAsCalling(const std::string& bundleName); 41e0dac50fSopenharmony_ci static bool IsSameAppAsCalling(const std::string& bundleName, const std::string& appIdentifier); 42e0dac50fSopenharmony_ci static bool IsStartedByUIExtension(); 43e0dac50fSopenharmony_ci static bool CheckCallingIsUserTestMode(pid_t pid); 44e0dac50fSopenharmony_ci static bool IsBetaVersion(); 45e0dac50fSopenharmony_ci static bool IsSystemAppCall(); 46e0dac50fSopenharmony_ci static bool IsFoundationCall(); 47e0dac50fSopenharmony_ci static std::string GetCallingBundleName(); 48e0dac50fSopenharmony_ci}; 49e0dac50fSopenharmony_ci} // Rosen 50e0dac50fSopenharmony_ci} // OHOS 51e0dac50fSopenharmony_ci#endif // OHOS_ROSEN_SESSION_PERMISSION_H