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 "favorite_asset_helper.h"
17 #include "userfile_manager_types.h"
18 #include "album_asset_helper.h"
19
20 namespace OHOS {
21 namespace Media::AccurateRefresh {
22
IsAsset(const PhotoAssetChangeInfo & assetInfo)23 bool FavoriteAssetHelper::IsAsset(const PhotoAssetChangeInfo &assetInfo)
24 {
25 return assetInfo.isFavorite_ && AlbumAssetHelper::IsCommonSystemAsset(assetInfo, false);
26 }
27
IsVideoAsset(const PhotoAssetChangeInfo & assetInfo)28 bool FavoriteAssetHelper::IsVideoAsset(const PhotoAssetChangeInfo &assetInfo)
29 {
30 return IsAsset(assetInfo) && AlbumAssetHelper::IsVideoAsset(assetInfo);
31 }
32
IsHiddenAsset(const PhotoAssetChangeInfo & assetInfo)33 bool FavoriteAssetHelper::IsHiddenAsset(const PhotoAssetChangeInfo &assetInfo)
34 {
35 return assetInfo.isFavorite_ && AlbumAssetHelper::IsCommonSystemAsset(assetInfo, true);
36 }
IsNewerAsset(const PhotoAssetChangeInfo & compareAssetInfo,const PhotoAssetChangeInfo & currentAssetInfo)37 bool FavoriteAssetHelper::IsNewerAsset(const PhotoAssetChangeInfo &compareAssetInfo,
38 const PhotoAssetChangeInfo ¤tAssetInfo)
39 {
40 return IsAsset(compareAssetInfo) && IsAsset(currentAssetInfo) &&
41 AlbumAssetHelper::IsNewerByDateTaken(compareAssetInfo, currentAssetInfo);
42 }
IsNewerHiddenAsset(const PhotoAssetChangeInfo & compareAssetInfo,const PhotoAssetChangeInfo & currentAssetInfo)43 bool FavoriteAssetHelper::IsNewerHiddenAsset(const PhotoAssetChangeInfo &compareAssetInfo,
44 const PhotoAssetChangeInfo ¤tAssetInfo)
45 {
46 return IsHiddenAsset(compareAssetInfo) && IsHiddenAsset(currentAssetInfo) &&
47 AlbumAssetHelper::IsNewerByHiddenTime(compareAssetInfo, currentAssetInfo);
48 }
49
50 } // namespace Media
51 } // namespace OHOS