1 /* 2 * Copyright (c) 2021 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 SOFTBUS_PERMISSION_H 17 #define SOFTBUS_PERMISSION_H 18 19 #include <stdbool.h> 20 #include <stdint.h> 21 #include <sys/types.h> 22 23 #ifdef __cplusplus 24 #if __cplusplus 25 extern "C" { 26 #endif 27 #endif 28 29 #define ACTION_CREATE 0x1 30 #define ACTION_OPEN 0x2 31 32 enum { 33 SYSTEM_APP = 0, 34 NATIVE_APP, 35 SELF_APP, 36 NORMAL_APP, 37 GRANTED_APP, 38 }; 39 40 int32_t TransPermissionInit(void); 41 void TransPermissionDeinit(void); 42 int32_t CheckTransPermission(pid_t callingUid, pid_t callingPid, 43 const char *pkgName, const char *sessionName, uint32_t actions); 44 int32_t CheckTransSecLevel(const char *mySessionName, const char *peerSessionName); 45 bool CheckDiscPermission(pid_t callingUid, const char *pkgName); 46 bool CheckBusCenterPermission(pid_t callingUid, const char *pkgName); 47 int32_t CheckDynamicPermission(void); 48 int32_t GrantTransPermission(int32_t callingUid, int32_t callingPid, const char *sessionName); 49 int32_t RemoveTransPermission(const char *sessionName); 50 51 #ifdef __cplusplus 52 #if __cplusplus 53 } 54 #endif /* __cplusplus */ 55 #endif /* __cplusplus */ 56 57 #endif /* SOFTBUS_PERMISSION_H */ 58