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 #define MLOG_TAG "MediaLibraryBackupUtils"
17 
18 #include "backup_dfx_utils.h"
19 
20 #include "hisysevent.h"
21 #include "media_log.h"
22 
23 namespace OHOS {
24 namespace Media {
25 static constexpr char MEDIA_LIBRARY[] = "MEDIALIBRARY";
26 const std::string KEY_ALBUM_COUNT = "ALBUM_COUNT";
27 const std::string KEY_PHOTO_COUNT = "PHOTO_COUNT";
28 const std::string KEY_FACE_COUNT = "FACE_COUNT";
29 const std::string KEY_TOTAL_TIME_COST = "TOTAL_TIME_COST";
30 
PostPortraitStat(uint32_t albumCount,uint64_t photoCount,uint64_t faceCount,uint64_t totalTimeCost)31 void BackupDfxUtils::PostPortraitStat(uint32_t albumCount, uint64_t photoCount, uint64_t faceCount,
32     uint64_t totalTimeCost)
33 {
34     int32_t ret = HiSysEventWrite(
35         MEDIA_LIBRARY,
36         "MEDIALIB_BACKUP_PORTRAIT_STAT",
37         HiviewDFX::HiSysEvent::EventType::STATISTIC,
38         KEY_ALBUM_COUNT, albumCount,
39         KEY_PHOTO_COUNT, photoCount,
40         KEY_FACE_COUNT, faceCount,
41         KEY_TOTAL_TIME_COST, totalTimeCost);
42     if (ret != 0) {
43         MEDIA_ERR_LOG("PostPortraitStat error:%{public}d", ret);
44     }
45 }
46 } // namespace Media
47 } // namespace OHOS