• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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_COMMON_H
17 #define PERMISSION_COMMON_H
18 
19 #include "medialibrary_command.h"
20 #include "media_log.h"
21 #include "medialibrary_errno.h"
22 
23 namespace OHOS::Media {
24 
25 static const std::string FIELD_PERMISSION_TYPE = "permission_type";
26 
27 static const std::string TABLE_PERMISSION = "UriPermission"; // 权限表
28 
29 static const int32_t GRANT_PERMISSION_CALLING_UID = 5523; // foundation调用方
30 static const int32_t ROOT_UID = 0;
31 static const int32_t SANDBOX_UID = 3076;
32 
33 /**
34  * 鉴权参数
35  */
36 struct PermParam {
37     bool isWrite = false; // true-鉴权写权限,false-鉴权读权限
38     bool isOpenFile = false; // 是否OpenFile接口鉴权
39     std::string openFileNode = ""; // isOpenFile=true时使用,文件模式的含义
40 };
41 
42 /**
43  * 获取客户端appId
44  */
45 std::string GetClientAppId();
46 
47 /**
48  * 是否需要鉴权Mediatool
49  */
50 bool IsMediatoolOperation(MediaLibraryCommand &cmd);
51 
52 /**
53  * 是否是DeveloperMediaTool
54  */
55 bool IsDeveloperMediaTool(MediaLibraryCommand &cmd, const std::string &openFileMode = "");
56 
57 /**
58  * 转换鉴权结果
59  */
60 int32_t ConvertPermResult(bool isPermSuccess);
61 
62 } // namespace OHOS::Media
63 
64 #endif