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 "thumbnail_data.h" 22 23 namespace OHOS { 24 namespace Media { 25 26 struct AlbumFusionDfxDataPoint { 27 int64_t albumFusionTag; 28 int64_t reportTimeStamp; 29 int32_t albumFusionState; // 1: Before fusion starts 2: After fusion successfully finished 3: when fusion fails 30 int32_t imageAssetCount; 31 int32_t videoAssetCount; 32 int32_t numberOfSourceAlbum; 33 int32_t numberOfUserAlbum; 34 int32_t totalAssetsInSourceAlbums; 35 int32_t totalAssetsInUserAlbums; 36 std::string albumDetails; 37 std::string hiddenAssetInfo; 38 }; 39 40 struct PhotoStatistics { 41 int32_t localImageCount; // 纯本地照片数量 42 int32_t localVideoCount; // 纯本地视频数量 43 int32_t cloudImageCount; // 纯云端图片数量 44 int32_t cloudVideoCount; // 纯云端视频数量 45 int32_t sharedImageCount; // 端云共存照片数量 46 int32_t sharedVideoCount; // 端云共存视频数量 47 }; 48 49 class DfxReporter { 50 public: 51 DfxReporter(); 52 ~DfxReporter(); 53 54 void ReportTimeOutOperation(std::string &bundleName, int32_t type, int32_t object, int32_t time); 55 int32_t ReportHighMemoryImageThumbnail(std::string &path, std::string &suffix, int32_t width, int32_t height); 56 int32_t ReportHighMemoryVideoThumbnail(std::string &path, std::string &suffix, int32_t width, int32_t height); 57 void ReportThumbnailError(); 58 void ReportCommonBehavior(); 59 void ReportDeleteStatistic(); 60 void ReportDeleteBehavior(std::string bundleName, int32_t type, std::string path); 61 void ReportThumbnailGeneration(const ThumbnailData::GenerateStats &stats); 62 void ReportPhotoInfo(const PhotoStatistics& stats); 63 void ReportAlbumInfo(const std::string &albumName, int32_t albumImageCount, int32_t albumVideoCount, 64 bool isLocal); 65 void ReportDirtyCloudPhoto(const std::string &data, int32_t dirty, int32_t cloudVersion); 66 void ReportCommonVersion(int32_t dbVersion); 67 void ReportAnalysisVersion(const std::string &analysisName, int32_t version); 68 void ReportAdaptationToMovingPhoto(); 69 static int32_t ReportCloudSyncThumbGenerationStatus(const int32_t& downloadedThumb, const int32_t& generatedThumb, 70 const int32_t& totalDownload); 71 static void ReportStartResult(int32_t scene, int32_t errorCode, int32_t startTime); 72 void ReportPhotoRecordInfo(); 73 static int32_t ReportMedialibraryAPI(const std::string& callerPackage, const std::string& saveUri); 74 static int32_t ReportAlbumFusion(const AlbumFusionDfxDataPoint& reportData); 75 }; 76 } // namespace Media 77 } // namespace OHOS 78 79 #endif // OHOS_MEDIA_DFX_REPORTER_H