• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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_DFX_REPORTER_H
17 #define OHOS_MEDIA_DFX_REPORTER_H
18 
19 #include <string>
20 
21 #include "dfx_cloud_const.h"
22 #include "thumbnail_data.h"
23 
24 namespace OHOS {
25 namespace Media {
26 
27 #define EXPORT __attribute__ ((visibility ("default")))
28 
29 struct AlbumFusionDfxDataPoint {
30     int64_t albumFusionTag;
31     int64_t reportTimeStamp;
32     int32_t albumFusionState; // 1: Before fusion starts 2: After fusion successfully finished 3: when fusion fails
33     int32_t imageAssetCount;
34     int32_t videoAssetCount;
35     int32_t numberOfSourceAlbum;
36     int32_t numberOfUserAlbum;
37     int32_t totalAssetsInSourceAlbums;
38     int32_t totalAssetsInUserAlbums;
39     std::string albumDetails;
40     std::string hiddenAssetInfo;
41 };
42 
43 struct CustomRestoreDfxDataPoint {
44     std::string customRestorePackageName = "";
45     std::string albumLPath = "";
46     std::string keyPath = "";
47     int32_t totalNum = -1;
48     int32_t successNum = -1;
49     int32_t failedNum = -1;
50     int32_t sameNum = -1;
51     int32_t cancelNum = -1;
52     uint64_t totalTime = 0;
53 };
54 
55 struct QuerySizeAndResolution {
56     std::string localImageSize;
57     std::string localVideoSize;
58     std::string cloudImageSize;
59     std::string cloudVideoSize;
60     std::string localImageResolution;
61     std::string localVideoResolution;
62     std::string cloudImageResolution;
63     std::string cloudVideoResolution;
64     std::string localImageRomSize;
65     std::string localVideoRomSize;
66     std::string cacheRomSize;
67     std::string highlightRomSize;
68     std::string ThumbnailRomSize;
69     std::string EditdataRomSize;
70     std::string totalSize;
71 };
72 
73 struct PhotoStatistics {
74     int32_t localImageCount;   // 纯本地照片数量
75     int32_t localVideoCount;   // 纯本地视频数量
76     int32_t cloudImageCount;   // 纯云端图片数量
77     int32_t cloudVideoCount;   // 纯云端视频数量
78     int32_t sharedImageCount;  // 端云共存照片数量
79     int32_t sharedVideoCount;  // 端云共存视频数量
80 };
81 
82 struct LcdAndAstcCount {
83     int32_t localLcdCount;
84     int32_t localAstcCount;
85     int32_t cloudLcdCount;
86     int32_t cloudAstcCount;
87 };
88 
89 enum PhotoErrorType : int32_t {
90     PHOTO_INVALID_TYPE = -1,  // 无效参数
91     PHOTO_MISS_TYPE = 1,    // 图片丢失
92 };
93 
94 struct PhotoErrorCount {
95     std::vector<int32_t> photoErrorTypes;     // 图片故障类型
96     std::vector<int32_t> photoErrorCounts;    // 图片故障数量
97 };
98 
99 struct AccurateRefreshDfxDataPoint {
100     std::string targetBusiness;
101     std::string sqlStr;
102     int32_t totalCostTime = 0;
103     int32_t standardCostTime = 0;
104     int32_t photoOperationTotalTime = 0;
105     int32_t albumOperationTotalTime = 0;
106     std::vector<int32_t> albumId;
107     std::string albumOperationTime;
108     std::string albumHiddenInfoOperationTime;
109 };
110 
111 class DfxReporter {
112 public:
113     DfxReporter();
114     ~DfxReporter();
115 
116     void ReportControllerService(uint32_t operationCode, int32_t errorCode);
117     void ReportTimeOutOperation(std::string &bundleName, int32_t type, int32_t object, int32_t time);
118     int32_t ReportHighMemoryImageThumbnail(std::string &path, std::string &suffix, int32_t width, int32_t height);
119     int32_t ReportHighMemoryVideoThumbnail(std::string &path, std::string &suffix, int32_t width, int32_t height);
120     void ReportThumbnailError();
121     void ReportCommonBehavior();
122     void ReportDeleteStatistic();
123     void ReportDeleteBehavior(std::string bundleName, int32_t type, std::string path);
124     void ReportThumbnailGeneration(const ThumbnailData::GenerateStats &stats);
125     void ReportPhotoInfo(const PhotoStatistics& stats);
126     void ReportAlbumInfo(const std::string &albumName, int32_t albumImageCount, int32_t albumVideoCount,
127         bool isLocal);
128     void ReportDirtyCloudPhoto(const std::string &data, int32_t dirty, int32_t cloudVersion);
129     void ReportCommonVersion(int32_t dbVersion);
130     void ReportAnalysisVersion(const std::string &analysisName, int32_t version);
131     void ReportAdaptationToMovingPhoto();
132     static int32_t ReportCloudSyncThumbGenerationStatus(const int32_t& downloadedThumb, const int32_t& generatedThumb,
133         const int32_t& totalDownload);
134     EXPORT static void ReportStartResult(int32_t scene, int32_t errorCode, int32_t startTime);
135     void ReportPhotoRecordInfo();
136     static int32_t ReportMedialibraryAPI(const std::string& callerPackage, const std::string& saveUri);
137     static int32_t ReportAlbumFusion(const AlbumFusionDfxDataPoint& reportData);
138     void ReportAstcInfo(const LcdAndAstcCount& count);
139     static int32_t ReportCustomRestoreFusion(const CustomRestoreDfxDataPoint& reportData);
140     void ReportOperationRecordInfo();
141     static int32_t ReportPhotoError(const PhotoErrorCount& reportData);
142 
143     static int32_t ReportSyncFault(const std::string& taskId, const std::string& position,
144         const SyncFaultEvent& event);
145     static int32_t ReportSyncStat(const std::string& taskId, const CloudSyncInfo& info, const CloudSyncStat& stat,
146         const std::string& syncInfo);
147     void ReportPhotoSizeAndResolutionInfo(const QuerySizeAndResolution& querySizeAndResolution,
148         const std::string& photoMimeType);
149     void ReportAccurateRefreshResult(const AccurateRefreshDfxDataPoint& reportData);
150 };
151 } // namespace Media
152 } // namespace OHOS
153 
154 #endif  // OHOS_MEDIA_DFX_REPORTER_H