1 /* 2 * Copyright (C) 2024-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 #ifndef OHOS_MEDIA_BACKUP_DATABASE_REPORT_H 16 #define OHOS_MEDIA_BACKUP_DATABASE_REPORT_H 17 18 #include <string> 19 #include <vector> 20 21 #include "rdb_store.h" 22 #include "media_backup_report_data_type.h" 23 24 namespace OHOS::Media { 25 class DatabaseReport { 26 public: SetSceneCode(int32_t sceneCode)27 DatabaseReport &SetSceneCode(int32_t sceneCode) 28 { 29 this->sceneCode_ = sceneCode; 30 return *this; 31 } SetTaskId(const std::string & taskId)32 DatabaseReport &SetTaskId(const std::string &taskId) 33 { 34 this->taskId_ = taskId; 35 return *this; 36 } 37 DatabaseReport &ReportGallery(std::shared_ptr<NativeRdb::RdbStore> galleryRdb, bool shouldIncludeSd); 38 DatabaseReport &ReportExternal(std::shared_ptr<NativeRdb::RdbStore> externalRdb, 39 std::shared_ptr<NativeRdb::RdbStore> galleryRdb); 40 DatabaseReport &ReportMedia(std::shared_ptr<NativeRdb::RdbStore> mediaLibraryRdb, int32_t period); 41 42 public: 43 enum { PERIOD_OLD = -1, PERIOD_BEFORE = 0, PERIOD_AFTER = 1 }; 44 45 private: 46 std::vector<AlbumMediaStatisticInfo> LoadGallery( 47 std::shared_ptr<NativeRdb::RdbStore> galleryRdb, bool shouldIncludeSd); 48 std::vector<AlbumMediaStatisticInfo> LoadExternal(std::shared_ptr<NativeRdb::RdbStore> externalRdb, 49 std::shared_ptr<NativeRdb::RdbStore> galleryRdb); 50 std::vector<AlbumMediaStatisticInfo> LoadMedia( 51 std::shared_ptr<NativeRdb::RdbStore> mediaLibraryRdb, int32_t period); 52 int32_t Report(std::vector<AlbumMediaStatisticInfo> statisticInfos); 53 int32_t PostInfoDfx(const AlbumMediaStatisticInfo &info); 54 int32_t PostInfoAuditLog(const AlbumMediaStatisticInfo &info); 55 56 private: 57 int32_t sceneCode_; 58 std::string taskId_; 59 bool shouldIncludeSd_; 60 }; 61 } // namespace OHOS::Media 62 #endif // OHOS_MEDIA_BACKUP_DATABASE_REPORT_H 63