1 /* 2 * Copyright (C) 2021-2023 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 OHOS_MEDIALIBRARY_SMARTALBUM_MAP_OPERATIONS_H 17 #define OHOS_MEDIALIBRARY_SMARTALBUM_MAP_OPERATIONS_H 18 19 #include <string> 20 #include <variant> 21 #include <grp.h> 22 #include <memory> 23 #include <mutex> 24 #include <securec.h> 25 #include <unistd.h> 26 #include <unordered_map> 27 28 #include "dir_asset.h" 29 #include "file_asset.h" 30 #include "medialibrary_db_const.h" 31 #include "medialibrary_command.h" 32 #include "native_album_asset.h" 33 #include "rdb_store.h" 34 #include "values_bucket.h" 35 36 namespace OHOS { 37 namespace Media { 38 #define EXPORT __attribute__ ((visibility ("default"))) 39 constexpr int32_t DEFAULT_ALBUMID = -1; 40 constexpr int32_t DEFAULT_ASSETID = -1; 41 class MediaLibrarySmartAlbumMapOperations { 42 public: 43 EXPORT static int32_t HandleSmartAlbumMapOperation(MediaLibraryCommand &cmd); 44 EXPORT static int32_t HandleAddAssetOperation(const int32_t albumId, const int32_t childFileAssetId, 45 const int32_t childAlbumId, MediaLibraryCommand &cmd); 46 EXPORT static int32_t HandleRemoveAssetOperation(const int32_t albumId, const int32_t childFileAssetId, 47 MediaLibraryCommand &cmd); 48 EXPORT static int32_t HandleAgingOperation(std::shared_ptr<int> countPtr = nullptr); 49 static void SetInterrupt(bool interrupt); 50 51 private: 52 static bool GetInterrupt(); 53 54 static std::atomic<bool> isInterrupt_; 55 static std::mutex g_opMutex; 56 }; 57 } // namespace Media 58 } // namespace OHOS 59 #endif // OHOS_MEDIALIBRARY_SMARTALBUM_MAP_OPERATIONS_H 60