• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     DatabaseReport &ReportAudio(const uint64_t audioCount);
42 
43 public:
44     enum { PERIOD_OLD = -1, PERIOD_BEFORE = 0, PERIOD_AFTER = 1 };
45 
46 private:
47     std::vector<AlbumMediaStatisticInfo> LoadGallery(
48         std::shared_ptr<NativeRdb::RdbStore> galleryRdb, bool shouldIncludeSd);
49     std::vector<AlbumMediaStatisticInfo> LoadExternal(std::shared_ptr<NativeRdb::RdbStore> externalRdb,
50         std::shared_ptr<NativeRdb::RdbStore> galleryRdb);
51     std::vector<AlbumMediaStatisticInfo> LoadMedia(
52         std::shared_ptr<NativeRdb::RdbStore> mediaLibraryRdb, int32_t period);
53     std::vector<AlbumMediaStatisticInfo> LoadAudio(const uint64_t audioCount);
54     int32_t Report(std::vector<AlbumMediaStatisticInfo> statisticInfos);
55     int32_t PostInfoDfx(const AlbumMediaStatisticInfo &info);
56     int32_t PostInfoAuditLog(const AlbumMediaStatisticInfo &info);
57 
58 private:
59     int32_t sceneCode_;
60     std::string taskId_;
61     bool shouldIncludeSd_;
62 };
63 }  // namespace OHOS::Media
64 #endif  // OHOS_MEDIA_BACKUP_DATABASE_REPORT_H