• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License"){return 0;}
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 #ifndef OHOS_MEDIALIBRARY_COMPOSITE_PERMISSION_CHECK_H
16 #define OHOS_MEDIALIBRARY_COMPOSITE_PERMISSION_CHECK_H
17 
18 #include "media_permission_check.h"
19 #include "medialibrary_asset_operations.h"
20 
21 namespace OHOS::Media {
22 // Corresponds to the inner vector in the permission map.
23 // Authentication succeeds only when all permissions in the singlePermChecks_ element are met.
24 class SinglePermissionCheck : public PermissionCheck {
25 private:
26     std::vector<std::shared_ptr<PermissionCheck>> singlePermChecks_;
27     std::mutex mutex_;
28 public:
29     void AddCheck(std::shared_ptr<PermissionCheck> check);
30     int32_t CheckPermission(uint32_t businessCode, const PermissionHeaderReq &data) override;
31 };
32 
33 // Corresponding to the outer vector in the permission map, compositePermChecks_ consists of singlePermChecks_ elements.
34 // If any group of elements passes the verification, the authentication is successful.
35 class CompositePermissionCheck : public PermissionCheck {
36 private:
37     std::vector<std::shared_ptr<SinglePermissionCheck>> compositePermChecks_;
38     std::mutex mutex_;
39 public:
40     void AddCheck(std::shared_ptr<SinglePermissionCheck> check);
41     int32_t CheckPermission(uint32_t businessCode, const PermissionHeaderReq &data) override;
42 };
43 
44 class MediaLibraryAssetOperationsWrapper : public MediaLibraryAssetOperations {
45 public:
46     static std::shared_ptr<FileAsset> GetFileAssetByUriWrapper(const std::string &fileUri, bool isPhoto,
47         const std::vector<std::string> &columns, const std::string &pendingStatus = "")
48     {
49         return MediaLibraryAssetOperations::GetFileAssetByUri(fileUri, isPhoto, columns, pendingStatus);
50     }
51 };
52 } // namespace OHOS::Media
53 #endif  // OHOS_MEDIALIBRARY_COMPOSITE_PERMISSION_CHECK_H
54