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