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