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 #include "trash_asset_helper.h"
17 #include "userfile_manager_types.h"
18 #include "medialibrary_type_const.h"
19
20 namespace OHOS {
21 namespace Media::AccurateRefresh {
22
IsAsset(const PhotoAssetChangeInfo & assetInfo)23 bool TrashAssetHelper::IsAsset(const PhotoAssetChangeInfo &assetInfo)
24 {
25 return assetInfo.syncStatus_ == static_cast<int32_t> (SyncStatusType::TYPE_VISIBLE) &&
26 assetInfo.cleanFlag_ == static_cast<int32_t> (CleanType::TYPE_NOT_CLEAN) &&
27 assetInfo.dateTrashedMs_ > 0 &&
28 assetInfo.burstCoverLevel_ == static_cast<int32_t> (BurstCoverLevelType::COVER) &&
29 assetInfo.timePending_ == 0 &&
30 !assetInfo.isTemp_;
31 }
32
IsVideoAsset(const PhotoAssetChangeInfo & assetInfo)33 bool TrashAssetHelper::IsVideoAsset(const PhotoAssetChangeInfo &assetInfo)
34 {
35 return IsAsset(assetInfo) && AlbumAssetHelper::IsVideoAsset(assetInfo);
36 }
37
IsHiddenAsset(const PhotoAssetChangeInfo & assetInfo)38 bool TrashAssetHelper::IsHiddenAsset(const PhotoAssetChangeInfo &assetInfo)
39 {
40 return assetInfo.syncStatus_ == static_cast<int32_t> (SyncStatusType::TYPE_VISIBLE) &&
41 assetInfo.cleanFlag_ == static_cast<int32_t> (CleanType::TYPE_NOT_CLEAN) &&
42 assetInfo.dateTrashedMs_ > 0 &&
43 assetInfo.burstCoverLevel_ == static_cast<int32_t> (BurstCoverLevelType::COVER) &&
44 assetInfo.timePending_ == 0 &&
45 !assetInfo.isTemp_ &&
46 assetInfo.isHidden_;
47 }
48
IsNewerAsset(const PhotoAssetChangeInfo & compareAssetInfo,const PhotoAssetChangeInfo & currentAssetInfo)49 bool TrashAssetHelper::IsNewerAsset(const PhotoAssetChangeInfo &compareAssetInfo,
50 const PhotoAssetChangeInfo ¤tAssetInfo)
51 {
52 return IsAsset(compareAssetInfo) && IsAsset(currentAssetInfo) &&
53 AlbumAssetHelper::IsNewerByDateTaken(compareAssetInfo, currentAssetInfo);
54 }
IsNewerHiddenAsset(const PhotoAssetChangeInfo & compareAssetInfo,const PhotoAssetChangeInfo & currentAssetInfo)55 bool TrashAssetHelper::IsNewerHiddenAsset(const PhotoAssetChangeInfo &compareAssetInfo,
56 const PhotoAssetChangeInfo ¤tAssetInfo)
57 {
58 return IsHiddenAsset(compareAssetInfo) && IsHiddenAsset(currentAssetInfo) &&
59 AlbumAssetHelper::IsNewerByHiddenTime(compareAssetInfo, currentAssetInfo);
60 }
61
62 } // namespace Media
63 } // namespace OHOS