• 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");
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_ALBUM_ASSET_HELPER
17 #define OHOS_MEDIALIBRARY_ALBUM_ASSET_HELPER
18 
19 #include <functional>
20 
21 #include "photo_asset_change_info.h"
22 #include "album_change_info.h"
23 #include "album_accurate_refresh_manager.h"
24 
25 namespace OHOS {
26 namespace Media::AccurateRefresh {
27 
28 // 计算指定系统相册类型资产的基类,包括收藏相册、视频相册、隐藏相册、回收站相册、图片相册、云增强相册
29 class AlbumAssetHelper {
30 public:
31     // 有效资产
32     static bool IsCommonSystemAsset(const PhotoAssetChangeInfo &assetInfo, bool isHiddenAsset = false);
33 
34     // 视频资产
35     static bool IsVideoAsset(const PhotoAssetChangeInfo &assetInfo);
36 
37     // 图片资产
38     static bool IsImageAsset(const PhotoAssetChangeInfo &assetInfo);
39 
40     // 根据data_added字段判断compareAssetInfo比currentAssetInfo新
41     static bool IsNewerByDateAdded(const PhotoAssetChangeInfo &compareAssetInfo,
42         const PhotoAssetChangeInfo &currentAssetInfo, bool isAsc = true);
43 
44     // 根据date_taken字段判断compareAssetInfo比currentAssetInfo新
45     static bool IsNewerByDateTaken(const PhotoAssetChangeInfo &compareAssetInfo,
46         const PhotoAssetChangeInfo &currentAssetInfo, bool isAsc = true);
47 
48     // 根据hidden_time字段判断compareAssetInfo比currentAssetInfo新
49     static bool IsNewerByHiddenTime(const PhotoAssetChangeInfo &compareAssetInfo,
50         const PhotoAssetChangeInfo &currentAssetInfo, bool isAsc = true);
51 
52     // 无效资产
53     static bool IsInvalidAsset(const PhotoAssetChangeInfo &assetInfo);
54     static bool UpdateCover(const PhotoAssetChangeData &assetChangeData,
55         std::function<bool(const PhotoAssetChangeInfo&)> isAlbumAsset,
56         std::function<bool(const PhotoAssetChangeInfo&, const PhotoAssetChangeInfo&)> isNewerAsset,
57         PhotoAssetChangeInfo &addCover, std::unordered_set<int32_t> &removeFileIds);
58     static bool UpdateCount(const PhotoAssetChangeData &assetChangeData,
59         std::function<bool(PhotoAssetChangeInfo)> isAlbumAsset, int32_t &count);
60     static bool CalAlbumRefreshInfo(std::function<bool(AlbumRefreshInfo &)> calFunc, AlbumRefreshInfo &refreshInfo,
61         int32_t albumId, bool isHidden, AlbumRefreshTimestamp &assetTimestamp);
62 };
63 
64 } // namespace Media
65 } // namespace OHOS
66 
67 #endif