• 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 
32 /**
33  * 鉴权参数
34  */
35 struct PermParam {
36     bool isWrite = false; // true-鉴权写权限,false-鉴权读权限
37     bool isOpenFile = false; // 是否OpenFile接口鉴权
38     std::string openFileNode = ""; // isOpenFile=true时使用,文件模式的含义
39 };
40 
41 /**
42  * 获取客户端appId
43  */
44 std::string GetClientAppId();
45 
46 /**
47  * 是否需要鉴权Mediatool
48  */
49 bool IsMediatoolOperation(MediaLibraryCommand &cmd);
50 
51 /**
52  * 是否是DeveloperMediaTool
53  */
54 bool IsDeveloperMediaTool(MediaLibraryCommand &cmd, const std::string &openFileMode = "");
55 
56 /**
57  * 转换鉴权结果
58  */
59 int32_t ConvertPermResult(bool isPermSuccess);
60 
61 } // namespace OHOS::Media
62 
63 #endif