• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023-2024 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_MEDIA_BACKUP_DEFINES_H
17 #define OHOS_MEDIA_BACKUP_DEFINES_H
18 
19 #include <string>
20 #include <unordered_set>
21 #include <variant>
22 #include <vector>
23 #include <optional>
24 
25 #include "photo_album_column.h"
26 #include "photo_map_column.h"
27 #include "vision_column.h"
28 
29 namespace OHOS {
30 namespace Media {
31 constexpr int32_t QUERY_COUNT = 200;
32 constexpr int32_t PRE_CLONE_PHOTO_BATCH_COUNT = 100;
33 constexpr int32_t CONNECT_SIZE = 10;
34 constexpr int32_t MILLISECONDS = 1000;
35 constexpr int32_t GALLERY_HIDDEN_ID = -4;
36 constexpr int32_t GALLERY_TRASHED_ID = 0;
37 constexpr int32_t UPGRADE_RESTORE_ID = 0;
38 constexpr int32_t DUAL_FRAME_CLONE_RESTORE_ID = 1;
39 constexpr int32_t CLONE_RESTORE_ID = 2;
40 constexpr int32_t I_PHONE_CLONE_RESTORE = 3;
41 constexpr int32_t OTHERS_PHONE_CLONE_RESTORE = 4;
42 constexpr int32_t DEFAULT_RESTORE_ID = -1;
43 constexpr int32_t RETRY_TIME = 5;
44 constexpr int32_t SLEEP_INTERVAL = 1;
45 constexpr int32_t GARBAGE_PHOTO_SIZE = 2048;
46 constexpr int32_t LIVE_PHOTO_TYPE = 50;
47 constexpr int32_t LIVE_PHOTO_HDR_TYPE = 1050;
48 constexpr size_t GARBLE_UNIT = 2;
49 constexpr uint32_t COVER_URI_NUM = 3;
50 constexpr int32_t EXTERNAL_DB_NOT_EXIST = -3;
51 constexpr uint32_t UNIQUE_NUMBER_NUM = 3;
52 constexpr uint32_t THUMBNAIL_NUM = 500;
53 constexpr size_t MAX_FAILED_FILES_LIMIT = 100;
54 
55 const std::string RESTORE_CLOUD_DIR = "/storage/cloud/files/Photo";
56 const std::string RESTORE_AUDIO_CLOUD_DIR = "/storage/cloud/files/Audio";
57 const std::string RESTORE_LOCAL_DIR = "/storage/media/local/files/Photo";
58 const std::string RESTORE_AUDIO_LOCAL_DIR = "/storage/media/local/files/Audio";
59 const std::string RESTORE_MUSIC_LOCAL_DIR = "/storage/media/local/files/Docs/Music/";
60 const std::string UPGRADE_FILE_DIR = "/storage/media/local/files/data";
61 const std::string GARBLE_DUAL_FRAME_CLONE_DIR = "/storage/media/local/files/data/storage/emulated";
62 const std::string OTHER_CLONE_PATH = "/storage/media/local/files/.backup/restore/";
63 const std::string GARBLE = "***";
64 const std::string GALLERT_IMPORT = "/Pictures/cloud/Imports";
65 const std::string GALLERT_HIDDEN_ALBUM = "/Pictures/hiddenAlbum";
66 const std::string GALLERT_ROOT_PATH = "/storage/emulated/";
67 const std::string RESTORE_FAILED_FILES_PATH = "/storage/media/local/files/Docs/Documents/restore_failed_files";
68 const std::string PHOTO_FILTER_SELECTED_SIZE = "filter_selected_size";
69 const std::string RESTORE_SANDBOX_DIR = "/data/storage/el2/base/.backup/restore";
70 
71 // DB field for update scene
72 const std::string GALLERY_ID = "_id";
73 const std::string GALLERY_LOCAL_MEDIA_ID = "local_media_id";
74 const std::string GALLERY_FILE_DATA = "_data";
75 const std::string GALLERY_TITLE = "title";
76 const std::string GALLERY_DISPLAY_NAME = "_display_name";
77 const std::string GALLERY_DESCRIPTION = "description";
78 const std::string GALLERY_IS_FAVORITE = "is_hw_favorite";
79 const std::string GALLERY_IS_BURST = "is_hw_burst";
80 const std::string GALLERY_RECYCLED_TIME = "recycledTime";
81 const std::string GALLERY_FILE_SIZE = "_size";
82 const std::string GALLERY_DURATION = "duration";
83 const std::string GALLERY_MEDIA_TYPE = "media_type";
84 const std::string GALLERY_SHOW_DATE_TOKEN = "showDateToken";
85 const std::string GALLERY_HEIGHT = "height";
86 const std::string GALLERY_WIDTH = "width";
87 const std::string GALLERY_ORIENTATION = "orientation";
88 const std::string GALLERY_MEDIA_BUCKET_ID = "relative_bucket_id";
89 const std::string GALLERY_MEDIA_SOURCE_PATH = "sourcePath";
90 const std::string GALLERY_RECYCLE_FLAG = "recycleFlag";
91 const std::string GALLERY_HASH = "hash";
92 const std::string GALLERY_SPECIAL_FILE_TYPE = "special_file_type";
93 const std::string GALLERY_FIRST_UPDATE_TIME = "first_update_time";
94 const std::string GALLERY_DATE_TAKEN = "datetaken";
95 const std::string GALLERY_DETAIL_TIME = "detail_time";
96 
97 // external column
98 const std::string EXTERNAL_IS_FAVORITE = "is_favorite";
99 const std::string EXTERNAL_DATE_MODIFIED = "date_modified";
100 const std::string EXTERNAL_DATE_ADDED = "date_added";
101 const std::string EXTERNAL_FILE_DATA = "_data";
102 const std::string EXTERNAL_TITLE = "title";
103 const std::string EXTERNAL_DISPLAY_NAME = "_display_name";
104 const std::string EXTERNAL_FILE_SIZE = "_size";
105 const std::string EXTERNAL_DURATION = "duration";
106 const std::string EXTERNAL_MEDIA_TYPE = "media_type";
107 const std::string EXTERNAL_DATE_TAKEN = "datetaken";
108 
109 // custom column
110 const std::string CUSTOM_COUNT = "count";
111 const std::string UNIQUE_NUMBER = "unique_number";
112 const std::string CUSTOM_MAX_ID = "max_id";
113 const std::string PRAGMA_TABLE_NAME = "name";
114 const std::string PRAGMA_TABLE_TYPE = "type";
115 
116 // audio column
117 const std::string AUDIO_DATA = "_data";
118 const std::string AUDIO_DATE_MODIFIED = "date_modified";
119 const std::string AUDIO_DATE_TAKEN = "datetaken";
120 
121 // statistics
122 const int32_t STAT_DEFAULT_ERROR_CODE_SUCCESS = 0;
123 const int32_t STAT_DEFAULT_ERROR_CODE_FAILED = 13500099;
124 const std::string STAT_KEY_RESULT_INFO = "resultInfo";
125 const std::string STAT_KEY_TYPE = "type";
126 const std::string STAT_KEY_ERROR_CODE = "errorCode";
127 const std::string STAT_KEY_ERROR_INFO = "errorInfo";
128 const std::string STAT_KEY_INFOS = "infos";
129 const std::string STAT_KEY_BACKUP_INFO = "backupInfo";
130 const std::string STAT_KEY_SUCCESS_COUNT = "successCount";
131 const std::string STAT_KEY_DUPLICATE_COUNT = "duplicateCount";
132 const std::string STAT_KEY_FAILED_COUNT = "failedCount";
133 const std::string STAT_KEY_DETAILS = "details";
134 const std::string STAT_KEY_NUMBER = "number";
135 const std::string STAT_KEY_PROGRESS_INFO = "progressInfo";
136 const std::string STAT_KEY_NAME = "name";
137 const std::string STAT_KEY_PROCESSED = "processed";
138 const std::string STAT_KEY_TOTAL = "total";
139 const std::string STAT_KEY_IS_PERCENTAGE = "isPercentage";
140 const std::string STAT_VALUE_ERROR_INFO = "ErrorInfo";
141 const std::string STAT_VALUE_COUNT_INFO = "CountInfo";
142 const std::string STAT_TYPE_PHOTO = "photo";
143 const std::string STAT_TYPE_VIDEO = "video";
144 const std::string STAT_TYPE_AUDIO = "audio";
145 const std::string STAT_TYPE_PHOTO_VIDEO = "photo&video";
146 const std::string STAT_TYPE_UPDATE = "update";
147 const std::string STAT_TYPE_OTHER = "other";
148 const std::string STAT_TYPE_ONGOING = "ongoing";
149 const std::vector<std::string> STAT_TYPES = { STAT_TYPE_PHOTO, STAT_TYPE_VIDEO, STAT_TYPE_AUDIO };
150 const std::vector<std::string> STAT_PROGRESS_TYPES = { STAT_TYPE_PHOTO_VIDEO, STAT_TYPE_AUDIO, STAT_TYPE_UPDATE,
151     STAT_TYPE_OTHER, STAT_TYPE_ONGOING };
152 
153 const std::string GALLERY_DB_NAME = "gallery.db";
154 const std::string EXTERNAL_DB_NAME = "external.db";
155 const std::string AUDIO_DB_NAME = "audio_MediaInfo.db";
156 const std::string PHOTO_SD_DB_NAME = "photo_sd_MediaInfo.db";
157 const std::string VIDEO_SD_DB_NAME = "video_sd_MediaInfo.db";
158 
159 const std::string GALLERY_ALBUM = "gallery_album";
160 const std::string GALLERY_ALBUM_NAME = "albumName";
161 const std::string GALLERY_ALBUM_BUCKETID = "relativeBucketId";
162 const std::string GALLERY_ALBUM_IPATH = "lPath";
163 const std::string GALLERY_NICK_NAME = "nick_name";
164 
165 const std::string FILE_SEPARATOR = "/";
166 
167 constexpr int32_t INDEX_TYPE = 0;
168 constexpr int32_t INDEX_CACHE_DIR = 1;
169 constexpr int32_t INDEX_NICK_DIR = 2;
170 constexpr int32_t INDEX_NICK_NAME = 3;
171 
172 constexpr int32_t NICK = 0;
173 constexpr int32_t CACHE = 1;
174 
175 constexpr int32_t DEFAULT_AREA_VERSION = -1;
176 
177 enum SourceType {
178     GALLERY = 0,
179     EXTERNAL_CAMERA,
180     EXTERNAL_OTHERS,
181     PHOTOS,
182     AUDIOS,
183 };
184 
185 enum class PrefixType {
186     CLOUD = 0,
187     LOCAL,
188     CLOUD_EDIT_DATA,
189     LOCAL_EDIT_DATA,
190 };
191 
192 enum DUAL_MEDIA_TYPE {
193     IMAGE_TYPE = 1,
194     AUDIO_TYPE,
195     VIDEO_TYPE,
196 };
197 
198 enum RestoreError {
199     SUCCESS = 0,
200     INIT_FAILED,
201     FILE_INVALID,
202     PATH_INVALID,
203     GET_PATH_FAILED,
204     INSERT_FAILED,
205     MOVE_FAILED,
206 };
207 
208 enum class PhotoRelatedType {
209     PHOTO_MAP = 0,
210     PORTRAIT,
211 };
212 
213 enum ProcessStatus {
214     STOP = 0,
215     START,
216 };
217 
218 const std::unordered_map<int32_t, std::string> RESTORE_ERROR_MAP = {
219     { RestoreError::INIT_FAILED, "Init failed" },
220     { RestoreError::FILE_INVALID, "File is invalid" },
221     { RestoreError::PATH_INVALID, "File path is invalid" },
222     { RestoreError::GET_PATH_FAILED, "Get path failed" },
223     { RestoreError::INSERT_FAILED, "Insert failed" },
224     { RestoreError::MOVE_FAILED, "Move failed" },
225 };
226 
227 const std::unordered_map<PrefixType, std::string> PREFIX_MAP = {
228     { PrefixType::CLOUD, "/storage/cloud/files" },
229     { PrefixType::LOCAL, "/storage/media/local/files" },
230     { PrefixType::CLOUD_EDIT_DATA, "/storage/cloud/files/.editData" },
231     { PrefixType::LOCAL_EDIT_DATA, "/storage/media/local/files/.editData" },
232 };
233 
234 const std::vector<std::vector<std::string>> CLONE_TABLE_LISTS_AUDIO = {
235     { AudioColumn::AUDIOS_TABLE },
236 };
237 
238 const std::vector<std::vector<std::string>> CLONE_TABLE_LISTS_PHOTO = {
239     { PhotoColumn::PHOTOS_TABLE },
240     { PhotoAlbumColumns::TABLE, PhotoMap::TABLE },
241     { ANALYSIS_ALBUM_TABLE, ANALYSIS_PHOTO_MAP_TABLE },
242 };
243 
244 const std::vector<std::vector<std::string>> CLONE_TABLE_LISTS_OLD_DEVICE = {
245     { PhotoColumn::PHOTOS_TABLE },
246     { AudioColumn::AUDIOS_TABLE },
247 };
248 
249 struct FileInfo {
250     std::string filePath;
251     std::string displayName;
252     std::string title;
253     std::string userComment;
254     std::string relativePath;
255     std::string cloudPath;
256     std::string packageName;
257     std::string bundleName;
258     std::string oldPath;
259     std::string movingPhotoVideoPath;
260     std::string extraDataPath;
261     std::string detailTime;
262     int32_t fileIdOld {-1};
263     int32_t fileIdNew {-1};
264     int64_t fileSize {0};
265     int64_t duration {0};
266     int64_t recycledTime {0};
267     int32_t hidden {0};
268     int32_t isFavorite {0};
269     int32_t fileType {0};
270     int32_t specialFileType {0};
271     int32_t subtype {0};
272     int64_t showDateToken {0};
273     int32_t height {0};
274     int32_t width {0};
275     int64_t dateAdded {0};
276     int32_t orientation {0};
277     int64_t dateModified {0};
278     int32_t mediaAlbumId {-1};  // 单相册id
279     int32_t localMediaId {-1};
280     bool isNew {true};
281     int64_t dateTaken {0};
282     int64_t firstUpdateTime {0};
283     std::unordered_map<std::string, std::variant<int32_t, int64_t, double, std::string>> valMap;
284     std::unordered_map<std::string, std::unordered_set<int32_t>> tableAlbumSetMap;
285     /**
286      * @brief the field data from gallery.db # gallery_media # relative_bucket_id.
287      */
288     std::string relativeBucketId;
289     /**
290      * @brief the field data from gallery.db # gallery_media # recycleFlag.
291      */
292     int32_t recycleFlag {0};
293     /**
294      * @brief the field data from gallery.db # gallery_media # is_hw_burst. 0=normal, 1=burst cover, 2=burst members.
295      */
296     int32_t isBurst {0};
297     /**
298      * @brief the field data from gallery.db # gallery_media # hash.
299      */
300     std::string hashCode;
301     /**
302      * @brief the field data for media_library.db # Photos # burst_key. 36 length of uuid.
303      */
304     std::string burstKey;
305     /**
306      *  @brief the associate file id, used for cloud enhancement pair relationship
307      */
308     int32_t associateFileId;
309 
310     bool needMove {true};
311 
312     std::string sourcePath;
313     std::string lPath;
314     int32_t ownerAlbumId;
315     /**
316      * @brief The PhotoMap is Deprecated. Hitory Data may still be transfered from Old Device by PhotoMap.
317      *   Use the isRelatedToPhotoMap field to identify if the photo is related to PhotoMap.
318      *   0 - not related, 1 - related.
319      */
320     int32_t isRelatedToPhotoMap = 0;
321     int32_t photoQuality;
322 };
323 
324 struct AlbumInfo {
325     int32_t albumIdOld {-1};
326     int32_t albumIdNew {-1};
327     std::string albumName;
328     std::string albumBundleName;
329     PhotoAlbumType albumType;
330     PhotoAlbumSubType albumSubType;
331     std::string lPath;
332     std::unordered_map<std::string, std::variant<int32_t, int64_t, double, std::string>> valMap;
333 };
334 
335 struct GalleryAlbumInfo {
336     int32_t mediaAlbumId {-1};  // 单相册id
337     std::string albumRelativeBucketId ;  //双相册id
338     std::string albumName;        //相册名称
339     std::string albumNickName;   //映射表名称
340     std::string albumCNName;     //映射表名称
341     std::string albumENName;     //映射表名称
342     std::string albumListName;      //白名单相册名称
343     std::string albumBundleName;    //白名单包名
344     std::string albumMediaName;     //单相册名称
345     std::string albumlPath;     //相册IPath
346 };
347 
348 struct MapInfo {
349     int32_t albumId {-1};
350     int32_t fileId {-1};
351 };
352 
353 struct FailedFileInfo {
354     std::string albumName;
355     std::string displayName;
356     std::string errorCode;
357     FailedFileInfo() = default;
FailedFileInfoFailedFileInfo358     FailedFileInfo(int32_t sceneCode, const FileInfo &fileInfo, int32_t givenErrorCode)
359     {
360         displayName = fileInfo.displayName;
361         errorCode = std::to_string(givenErrorCode);
362         if (fileInfo.recycledTime > 0) {
363             albumName = "最近删除";
364             return;
365         }
366         if (fileInfo.hidden > 0) {
367             albumName = sceneCode == CLONE_RESTORE_ID ? "已隐藏" : "隐藏相册";
368             return;
369         }
370         albumName = fileInfo.packageName;
371     }
372 };
373 
374 struct SubCountInfo {
375     uint64_t successCount {0};
376     uint64_t duplicateCount {0};
377     std::unordered_map<std::string, FailedFileInfo> failedFiles;
SubCountInfoSubCountInfo378     SubCountInfo(int64_t successCount, int64_t duplicateCount,
379         const std::unordered_map<std::string, FailedFileInfo> &failedFiles)
380         : successCount(successCount), duplicateCount(duplicateCount), failedFiles(failedFiles) {}
381 };
382 
383 struct SubProcessInfo {
384     uint64_t processed {0};
385     uint64_t total {0};
SubProcessInfoSubProcessInfo386     SubProcessInfo(uint64_t processed, uint64_t total) : processed(processed), total(total) {}
387 };
388 
389 struct PortraitAlbumInfo {
390     int32_t userOperation {0};
391     int32_t renameOperation {0};
392     std::string tagIdOld;
393     std::string tagIdNew;
394     std::string groupTagOld;
395     std::string groupTagNew;
396     std::string tagName;
397 };
398 
399 struct FaceInfo {
400     float scaleX {0.0};
401     float scaleY {0.0};
402     float scaleWidth {0.0};
403     float scaleHeight {0.0};
404     float pitch {0.0};
405     float yaw {0.0};
406     float roll {0.0};
407     float prob {0.0};
408     int32_t albumIdNew {-1};
409     int32_t fileIdNew {-1};
410     int32_t totalFaces {0};
411     std::string hash;
412     std::string faceId;
413     std::string tagIdOld;
414     std::string tagIdNew;
415     std::string landmarks;
416 };
417 
418 struct AnalysisAlbumTbl {
419     std::optional<int32_t> albumId;
420     std::optional<int32_t> albumType;
421     std::optional<int32_t> albumSubtype;
422     std::optional<std::string> albumName;
423     std::optional<std::string> coverUri;
424     std::optional<int32_t> count;
425     std::optional<int64_t> dateModified;
426     std::optional<int32_t> rank;
427     std::optional<std::string> tagId;
428     std::optional<int32_t> userOperation;
429     std::optional<std::string> groupTag;
430     std::optional<int32_t> userDisplayLevel;
431     std::optional<int32_t> isMe;
432     std::optional<int32_t> isRemoved;
433     std::optional<int32_t> renameOperation;
434     std::optional<int32_t> isLocal;
435     std::optional<int32_t> isCoverSatisfied;
436 };
437 
438 struct PortraitAlbumDfx {
439     std::optional<std::string> albumName;
440     std::optional<std::string> coverUri;
441     std::optional<std::string> tagId;
442     std::optional<int32_t> count;
443 };
444 
445 struct FaceTagTbl {
446     std::optional<int32_t> id;
447     std::optional<std::string> tagId;
448     std::optional<std::string> tagName;
449     std::optional<int32_t> userOperation;
450     std::optional<std::string> groupTag;
451     std::optional<int32_t> renameOperation;
452     std::optional<std::string> centerFeatures;
453     std::optional<std::string> tagVersion;
454     std::optional<int32_t> userDisplayLevel;
455     std::optional<int32_t> tagOrder;
456     std::optional<int32_t> isMe;
457     std::optional<std::string> coverUri;
458     std::optional<int32_t> count;
459     std::optional<int64_t> dateModify;
460     std::optional<int32_t> albumType;
461     std::optional<int32_t> isRemoved;
462     std::optional<std::string> analysisVersion;
463 };
464 
465 struct ImageFaceTbl {
466     std::optional<int32_t> id;
467     std::optional<int32_t> fileId;
468     std::optional<std::string> faceId;
469     std::optional<std::string> tagId;
470     std::optional<double> scaleX;
471     std::optional<double> scaleY;
472     std::optional<double> scaleWidth;
473     std::optional<double> scaleHeight;
474     std::optional<std::string> landmarks;
475     std::optional<double> pitch;
476     std::optional<double> yaw;
477     std::optional<double> roll;
478     std::optional<double> prob;
479     std::optional<int32_t> totalFaces;
480     std::optional<std::string> faceVersion;
481     std::optional<std::string> featuresVersion;
482     std::optional<std::string> features;
483     std::optional<int32_t> faceOcclusion;
484     std::optional<std::string> analysisVersion;
485     std::optional<double> beautyBounderX;
486     std::optional<double> beautyBounderY;
487     std::optional<double> beautyBounderWidth;
488     std::optional<double> beautyBounderHeight;
489     std::optional<double> aestheticsScore;
490     std::optional<std::string> beautyBounderVersion;
491     std::optional<int32_t> isExcluded;
492 };
493 
494 struct AnalysisPhotoMapTbl {
495     std::optional<int32_t> mapAlbum;
496     std::optional<int32_t> mapAsset;
497 };
498 
499 using NeedQueryMap = std::unordered_map<PhotoRelatedType, std::unordered_set<std::string>>;
500 
501 // sql for external
502 const std::string QUERY_FILE_COLUMN = "SELECT _id, " + GALLERY_FILE_DATA + ", " + GALLERY_DISPLAY_NAME + ", " +
503     EXTERNAL_IS_FAVORITE + ", " + GALLERY_FILE_SIZE + ", " + GALLERY_DURATION + ", " + GALLERY_MEDIA_TYPE + ", " +
504     EXTERNAL_DATE_MODIFIED + ", " + GALLERY_HEIGHT + ", " + GALLERY_WIDTH + ", " + GALLERY_TITLE + ", " +
505     GALLERY_ORIENTATION + ", " + EXTERNAL_DATE_ADDED + ", " + EXTERNAL_DATE_TAKEN + ", " +
506     GALLERY_SPECIAL_FILE_TYPE + " FROM files WHERE ";
507 
508 const std::string IN_CAMERA = " bucket_id IN (-1739773001, 0, 1028075469, 0) AND (is_pending = 0)";
509 
510 const std::string NOT_IN_CAMERA = " bucket_id NOT IN (-1739773001, 0, 1028075469, 0 ) AND is_pending = 0";
511 
512 const std::string QUERY_NOT_SYNC = " _id < 1000000000 AND media_type IN (1, 3) AND _size > 0 ";
513 
514 const std::string COMPARE_ID = " _id > ";
515 
516 const std::string QUERY_COUNT_FROM_FILES = "SELECT count(1) AS count FROM files WHERE";
517 
518 // sql for gallery
519 const std::string QUERY_GARBAGE_ALBUM = "SELECT type, cache_dir, nick_dir, nick_name FROM garbage_album";
520 
521 const std::string QUERY_MAX_ID_CAMERA_SCREENSHOT = "SELECT max(local_media_id) AS max_id FROM gallery_media \
522     WHERE local_media_id > 0 AND bucket_id IN (-1739773001, 0, 1028075469, 0) AND \
523     (recycleFlag NOT IN (2, -1, 1, -2, -4) OR recycleFlag IS NULL) AND \
524     (storage_id IN (0, 65537) or storage_id IS NULL) AND _size > 0 "; // only in upgrade external
525 
526 const std::string QUERY_MAX_ID_OTHERS = "SELECT max(local_media_id) AS max_id FROM gallery_media \
527     WHERE local_media_id > 0 AND bucket_id NOT IN (-1739773001, 0, 1028075469, 0) AND \
528     (recycleFlag NOT IN (2, -1, 1, -2, -4) OR recycleFlag IS NULL) AND \
529     (storage_id IN (0, 65537) or storage_id IS NULL) AND _size > 0 "; // only in upgrade external
530 
531 const std::string ALL_PHOTOS_WHERE_CLAUSE = " (local_media_id != -1) AND (relative_bucket_id IS NULL OR \
532     relative_bucket_id NOT IN (SELECT DISTINCT relative_bucket_id FROM garbage_album WHERE type = 1)) AND _size > 0 \
533     AND _data NOT LIKE '/storage/emulated/0/Pictures/cloud/Imports%' ";
534 
535 const std::string ALL_PHOTOS_ORDER_BY = " ORDER BY showDateToken ASC ";
536 
537 const std::string EXCLUDE_SD = " (storage_id IN (0, 65537)) ";
538 
539 const std::string QUERY_MAX_ID = "SELECT max(local_media_id) AS max_id FROM gallery_media \
540     WHERE local_media_id > 0 AND (recycleFlag NOT IN (2, -1, 1, -2, -4) OR recycleFlag IS NULL) AND \
541     (storage_id IN (0, 65537) or storage_id IS NULL) AND _size > 0 "; // only in upgrade external
542 
543 const std::string DUAL_CLONE_AUDIO_FULL_TABLE = "mediainfo INNER JOIN mediafile ON mediainfo." + AUDIO_DATA +
544     " = '/storage/emulated/0'||mediafile.filepath";
545 
546 const std::string QUERY_ALL_AUDIOS_FROM_AUDIODB = "SELECT " + AUDIO_DATA + "," + AUDIO_DATE_MODIFIED + "," +
547     AUDIO_DATE_TAKEN + " FROM " + DUAL_CLONE_AUDIO_FULL_TABLE;
548 
549 const std::string QUERY_DUAL_CLONE_AUDIO_COUNT = "SELECT count(1) as count FROM " + DUAL_CLONE_AUDIO_FULL_TABLE;
550 
551 const std::vector<std::string> EXCLUDED_PORTRAIT_COLUMNS = {"album_id", "count", "rank"};
552 const std::vector<std::string> EXCLUDED_FACE_TAG_COLUMNS = {"id", "user_operation", "rename_operation", "group_tag",
553     "user_display_level", "tag_order", "is_me", "cover_uri", "count", "date_modify", "album_type", "is_removed"};
554 const std::vector<std::string> EXCLUDED_IMAGE_FACE_COLUMNS = {"id"};
555 } // namespace Media
556 } // namespace OHOS
557 
558 #endif  // OHOS_MEDIA_BACKUP_DEFINES_H
559