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 "medialibrary_album_helper.h"
17
18 #include "media_log.h"
19 #include "media_column.h"
20 #include "photo_album_column.h"
21 #include "shooting_mode_column.h"
22
23 using namespace std;
24
25 namespace OHOS {
26 namespace Media {
27
GetAnalysisAlbumPredicates(const int32_t albumId,const PhotoAlbumSubType subType,const string albumName,NativeRdb::RdbPredicates & predicates,const bool hiddenState)28 bool MediaLibraryAlbumHelper::GetAnalysisAlbumPredicates(const int32_t albumId, const PhotoAlbumSubType subType,
29 const string albumName, NativeRdb::RdbPredicates& predicates, const bool hiddenState)
30 {
31 switch (subType) {
32 case PhotoAlbumSubType::PORTRAIT: {
33 PhotoAlbumColumns::GetPortraitAlbumPredicates(albumId, predicates);
34 return true;
35 }
36 case PhotoAlbumSubType::SHOOTING_MODE: {
37 ShootingModeAlbumType type {};
38 if (!ShootingModeAlbum::AlbumNameToShootingModeAlbumType(albumName, type)) {
39 MEDIA_ERR_LOG("Invalid shooting mode album name: %{public}s", albumName.c_str());
40 predicates.EqualTo(PhotoColumn::MEDIA_ID, to_string(0));
41 return false;
42 }
43 ShootingModeAlbum::GetShootingModeAlbumPredicates(type, predicates, hiddenState);
44 return true;
45 }
46 default: {
47 PhotoAlbumColumns::GetAnalysisPhotoMapPredicates(albumId, predicates, hiddenState);
48 return true;
49 }
50 }
51 }
52
53 } // namespace Media
54 } // namespace OHOS