• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 #define MLOG_TAG "Media_Client"
16 
17 #include "cloud_media_data_client_handler.h"
18 
19 #include <string>
20 #include <vector>
21 
22 #include "cloud_data_convert_to_vo.h"
23 #include "cloud_media_operation_code.h"
24 #include "cloud_sync_unprepared_data_vo.h"
25 #include "media_itypes_utils.h"
26 #include "media_log.h"
27 #include "message_parcel.h"
28 #include "user_define_ipc_client.h"
29 #include "media_req_vo.h"
30 #include "media_resp_vo.h"
31 #include "medialibrary_errno.h"
32 #include "update_dirty_vo.h"
33 #include "update_position_vo.h"
34 #include "update_sync_status_vo.h"
35 #include "update_thm_status_vo.h"
36 #include "get_aging_file_vo.h"
37 #include "get_download_asset_vo.h"
38 #include "get_download_thm_vo.h"
39 #include "get_video_to_cache_vo.h"
40 #include "get_file_pos_stat_vo.h"
41 #include "get_cloud_thm_stat_vo.h"
42 #include "get_dirty_type_stat_vo.h"
43 #include "on_download_asset_vo.h"
44 #include "get_download_thm_num_vo.h"
45 #include "update_local_file_dirty_vo.h"
46 #include "get_download_thm_by_uri_vo.h"
47 #include "media_file_utils.h"
48 #include "media_operate_result_vo.h"
49 
50 namespace OHOS::Media::CloudSync {
51 // LCOV_EXCL_START
SetUserId(const int32_t & userId)52 void CloudMediaDataClientHandler::SetUserId(const int32_t &userId)
53 {
54     this->userId_ = userId;
55 }
56 
SetTraceId(const std::string & traceId)57 void CloudMediaDataClientHandler::SetTraceId(const std::string &traceId)
58 {
59     this->traceId_ = traceId;
60 }
61 
GetTraceId() const62 std::string CloudMediaDataClientHandler::GetTraceId() const
63 {
64     return this->traceId_;
65 }
66 
UpdateDirty(const std::string & cloudId,DirtyTypes dirtyType)67 int32_t CloudMediaDataClientHandler::UpdateDirty(const std::string &cloudId, DirtyTypes dirtyType)
68 {
69     MEDIA_INFO_LOG("CloudMediaDataClientHandler::UpdateDirty begin");
70     // request info.
71     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_UPDATE_DIRTY_FOR_CLOUD_CHECK);
72     UpdateDirtyReqBody reqBody;
73     reqBody.cloudId = cloudId;
74     reqBody.dirtyType = static_cast<int32_t>(dirtyType);
75     int32_t ret =
76         IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Post(operationCode, reqBody);
77     if (ret != E_OK) {
78         MEDIA_ERR_LOG("Failed to UpdateDirty, ret: %{public}d", ret);
79     }
80     return ret;
81 }
82 
UpdatePosition(const std::vector<std::string> & cloudIds,int32_t position)83 int32_t CloudMediaDataClientHandler::UpdatePosition(const std::vector<std::string> &cloudIds, int32_t position)
84 {
85     MEDIA_INFO_LOG("UpdatePosition, cloudIds: %{public}zu, position: %{public}d", cloudIds.size(), position);
86     CHECK_AND_RETURN_RET_LOG(!cloudIds.empty(), E_OK, "UpdatePosition: cloudIds is empty");
87     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_UPDATE_POSITION_FOR_CLOUD_CHECK);
88     UpdatePositionReqBody reqBody;
89     reqBody.cloudIds = cloudIds;
90     reqBody.position = position;
91     int32_t ret =
92         IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Post(operationCode, reqBody);
93     if (ret != E_OK) {
94         MEDIA_ERR_LOG("Failed to UpdatePosition, ret: %{public}d", ret);
95     }
96     return ret;
97 }
98 
UpdateSyncStatus(const std::string & cloudId,int32_t syncStatus)99 int32_t CloudMediaDataClientHandler::UpdateSyncStatus(const std::string &cloudId, int32_t syncStatus)
100 {
101     MEDIA_INFO_LOG(
102         "CloudMediaDataClientHandler::UpdateSyncStatus begin %{public}s, %{public}d", cloudId.c_str(), syncStatus);
103     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_UPDATE_SYNC_STATUS);
104     UpdateSyncStatusReqBody reqBody;
105     reqBody.cloudId = cloudId;
106     reqBody.syncStatus = syncStatus;
107     int32_t ret =
108         IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Post(operationCode, reqBody);
109     if (ret != E_OK) {
110         MEDIA_ERR_LOG("Failed to UpdateSyncStatus, ret: %{public}d", ret);
111     }
112     return ret;
113 }
114 
UpdateThmStatus(const std::string & cloudId,int32_t thmStatus)115 int32_t CloudMediaDataClientHandler::UpdateThmStatus(const std::string &cloudId, int32_t thmStatus)
116 {
117     MEDIA_INFO_LOG("CloudMediaDataClientHandler::UpdateThmStatus begin");
118     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_UPDATE_THM_STATUS_FOR_CLOUD_CHECK);
119     UpdateThmStatusReqBody reqBody;
120     reqBody.cloudId = cloudId;
121     reqBody.thmStatus = thmStatus;
122     int32_t ret = IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Post(operationCode, reqBody);
123     if (ret != E_OK) {
124         MEDIA_ERR_LOG("Failed to UpdateThmStatus, ret: %{public}d", ret);
125     }
126     return ret;
127 }
128 
GetAgingFile(const int64_t time,int32_t mediaType,int32_t sizeLimit,int32_t offset,std::vector<CloudMetaData> & metaData)129 int32_t CloudMediaDataClientHandler::GetAgingFile(
130     const int64_t time, int32_t mediaType, int32_t sizeLimit, int32_t offset, std::vector<CloudMetaData> &metaData)
131 {
132     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_GET_AGING_ASSET);
133     GetAgingFileReqBody reqBody;
134     reqBody.time = time;
135     reqBody.mediaType = mediaType;
136     reqBody.sizeLimit = sizeLimit;
137     reqBody.offset = offset;
138     int32_t ret = this->GetAgingFile(operationCode, reqBody, metaData);
139     if (ret != E_OK) {
140         MEDIA_ERR_LOG("Failed to GetAgingFile, ret: %{public}d", ret);
141     }
142     return ret;
143 }
144 
GetAgingFile(uint32_t operationCode,GetAgingFileReqBody & reqBody,std::vector<CloudMetaData> & metaData)145 int32_t CloudMediaDataClientHandler::GetAgingFile(
146     uint32_t operationCode, GetAgingFileReqBody &reqBody, std::vector<CloudMetaData> &metaData)
147 {
148     MEDIA_INFO_LOG("CloudMediaDataClientHandler::GetAgingFile begin, operationCode: %{public}d", operationCode);
149     GetAgingFileRespBody respBody;
150     int32_t ret =
151         IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Post(operationCode, reqBody, respBody);
152     if (ret != E_OK) {
153         MEDIA_ERR_LOG("Failed to GetAgingFile, ret: %{public}d", ret);
154         return ret;
155     }
156     for (auto &photosVo : respBody.photos) {
157         CloudMetaData cloudMetaData = CloudDataConvertToVo::ConvertPhotosVoToCloudMetaData(photosVo);
158         metaData.push_back(cloudMetaData);
159     }
160     MEDIA_INFO_LOG("CloudMediaDataClientHandler::GetAgingFile end, operationCode: %{public}d", operationCode);
161     return E_OK;
162 }
163 
GetActiveAgingFile(const int64_t time,int32_t mediaType,int32_t sizeLimit,int32_t offset,std::vector<CloudMetaData> & metaData)164 int32_t CloudMediaDataClientHandler::GetActiveAgingFile(
165     const int64_t time, int32_t mediaType, int32_t sizeLimit, int32_t offset, std::vector<CloudMetaData> &metaData)
166 {
167     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_GET_ACTIVE_AGING_ASSET);
168     GetAgingFileReqBody reqBody;
169     reqBody.time = time;
170     reqBody.mediaType = mediaType;
171     reqBody.sizeLimit = sizeLimit;
172     reqBody.offset = offset;
173     int32_t ret = this->GetAgingFile(operationCode, reqBody, metaData);
174     if (ret != E_OK) {
175         MEDIA_ERR_LOG("Failed to GetActiveAgingFile, ret: %{public}d", ret);
176     }
177     return ret;
178 }
179 
GetDownloadAsset(const std::vector<std::string> & uris,std::vector<CloudMetaData> & cloudMetaDataVec)180 int32_t CloudMediaDataClientHandler::GetDownloadAsset(
181     const std::vector<std::string> &uris, std::vector<CloudMetaData> &cloudMetaDataVec)
182 {
183     MEDIA_INFO_LOG("GetDownloadAsset, uris: %{public}zu", uris.size());
184     CHECK_AND_RETURN_RET_LOG(!uris.empty(), E_OK, "GetDownloadAsset: uris is empty");
185     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_GET_DOWNLOAD_ASSET);
186     GetDownloadAssetReqBody reqBody;
187     reqBody.pathList = uris;
188     // parcel data.
189     GetDownloadAssetRespBody respBody;
190     int32_t ret =
191         IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Post(operationCode, reqBody, respBody);
192     if (ret != E_OK) {
193         MEDIA_ERR_LOG("Failed to GetDownloadAsset, ret: %{public}d", ret);
194         return ret;
195     }
196     for (auto &photosVo : respBody.photos) {
197         CloudMetaData cloudMetaData = CloudDataConvertToVo::ConvertPhotosVoToCloudMetaData(photosVo);
198         MEDIA_INFO_LOG("GetDownloadAsset MetaData: %{public}s", cloudMetaData.ToString().c_str());
199         cloudMetaDataVec.push_back(cloudMetaData);
200     }
201     MEDIA_INFO_LOG("CloudMediaDataClientHandler::GetDownloadAsset end");
202     return E_OK;
203 }
204 
GetDownloadThmsByUri(const std::vector<std::string> & uri,int32_t type,std::vector<CloudMetaData> & metaData)205 int32_t CloudMediaDataClientHandler::GetDownloadThmsByUri(
206     const std::vector<std::string> &uri, int32_t type, std::vector<CloudMetaData> &metaData)
207 {
208     MEDIA_INFO_LOG("GetDownloadThmsByUri, uris: %{public}zu, type: %{public}d", uri.size(), type);
209     CHECK_AND_RETURN_RET_LOG(!uri.empty(), E_OK, "GetDownloadThmsByUri: uris is empty");
210     GetDownloadThmsByUriReqBody reqBody;
211     reqBody.pathList = uri;
212     reqBody.thmType = type;
213     GetDownloadThmsByUriRespBody respBody;
214     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_GET_DOWNLOAD_THM_BY_URI);
215     int32_t ret =
216         IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Post(operationCode, reqBody, respBody);
217     if (ret != E_OK) {
218         MEDIA_ERR_LOG("Failed to GetDownloadThmsByUri, ret: %{public}d", ret);
219         return ret;
220     }
221     for (auto &photosVo : respBody.photos) {
222         CloudMetaData cloudMetaData = CloudDataConvertToVo::ConvertPhotosVoToCloudMetaData(photosVo);
223         MEDIA_INFO_LOG("GetDownloadThmsByUri MetaData: %{public}s", cloudMetaData.ToString().c_str());
224         metaData.push_back(cloudMetaData);
225     }
226     return ret;
227 }
228 
OnDownloadAsset(const std::vector<std::string> & cloudIds,std::vector<MediaOperateResult> & result)229 int32_t CloudMediaDataClientHandler::OnDownloadAsset(
230     const std::vector<std::string> &cloudIds, std::vector<MediaOperateResult> &result)
231 {
232     MEDIA_INFO_LOG("OnDownloadAsset, cloudIds: %{public}zu", cloudIds.size());
233     CHECK_AND_RETURN_RET_LOG(!cloudIds.empty(), E_OK, "OnDownloadAsset: cloudIds is empty");
234     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_ON_DOWNLOAD_ASSET);
235     OnDownloadAssetReqBody reqBody;
236     reqBody.cloudIds = cloudIds;
237     MediaOperateResultRespBody respBody;
238     int32_t ret =
239         IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Post(operationCode, reqBody, respBody);
240     result.clear();
241     for (auto &resultVo : respBody.result) {
242         MEDIA_INFO_LOG(
243             "CloudMediaDataClientHandler::OnDownloadAsset, mediaResult: %{public}s", resultVo.ToString().c_str());
244         MediaOperateResult mediaResult;
245         mediaResult.cloudId = resultVo.cloudId;
246         mediaResult.errorCode = resultVo.errorCode;
247         mediaResult.errorMsg = resultVo.errorMsg;
248         result.emplace_back(mediaResult);
249     }
250     if (ret != E_OK) {
251         MEDIA_ERR_LOG("Failed to OnDownloadAsset, ret: %{public}d", ret);
252     }
253     return ret;
254 }
255 
GetDownloadThms(std::vector<CloudMetaData> & cloudMetaDataVec,const DownloadThumPara & param)256 int32_t CloudMediaDataClientHandler::GetDownloadThms(
257     std::vector<CloudMetaData> &cloudMetaDataVec, const DownloadThumPara &param)
258 {
259     MEDIA_INFO_LOG("enter GetDownloadThms");
260     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_GET_DOWNLOAD_THM);
261     GetDownloadThmReqBody reqBody;
262     reqBody.size = param.size;
263     reqBody.type = param.type;
264     reqBody.offset = param.offset;
265     reqBody.isDownloadDisplayFirst = param.isDownloadDisplayFirst;
266     GetDownloadThmRespBody respBody;
267     int32_t ret =
268         IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Post(operationCode, reqBody, respBody);
269     if (ret != E_OK) {
270         MEDIA_ERR_LOG("GetDownloadThms IPC Err, ret: %{public}d", ret);
271         return ret;
272     }
273     for (auto &photosVo : respBody.photos) {
274         MEDIA_INFO_LOG("GetDownloadThm %{public}s.", photosVo.ToString().c_str());
275         CloudMetaData cloudMetaData = CloudDataConvertToVo::ConvertPhotosVoToCloudMetaData(photosVo);
276         cloudMetaDataVec.push_back(cloudMetaData);
277         MEDIA_INFO_LOG("GetDownloadThms MetaData: %{public}s", cloudMetaData.ToString().c_str());
278     }
279     MEDIA_INFO_LOG("GetDownloadThms end");
280     return E_OK;
281 }
282 
OnDownloadThmsInner(std::vector<OnDownloadThmsReqBody::DownloadThmsData> & downloadThmsDataList,int32_t & failSize)283 int32_t CloudMediaDataClientHandler::OnDownloadThmsInner(
284     std::vector<OnDownloadThmsReqBody::DownloadThmsData> &downloadThmsDataList, int32_t &failSize)
285 {
286     MEDIA_INFO_LOG("enter CloudMediaDataClientHandler::OnDownloadThmsInner");
287     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_ON_DOWNLOAD_THMS);
288     OnDownloadThmsReqBody reqBody;
289     reqBody.downloadThmsDataList = downloadThmsDataList;
290     MEDIA_INFO_LOG("OnDownloadThmsReqBody: %{public}zu", reqBody.downloadThmsDataList.size());
291     MediaOperateResultRespBody respBody;
292     int32_t ret =
293         IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Post(operationCode, reqBody, respBody);
294     failSize = respBody.GetFailSize();
295     CHECK_AND_PRINT_LOG(ret == E_OK, "Failed to OnDownloadThms, ret: %{public}d", ret);
296     return ret;
297 }
298 
OnDownloadThms(const std::unordered_map<std::string,int32_t> & resMap,int32_t & failSize)299 int32_t CloudMediaDataClientHandler::OnDownloadThms(
300     const std::unordered_map<std::string, int32_t> &resMap, int32_t &failSize)
301 {
302     MEDIA_INFO_LOG("OnDownloadThms, resMap: %{public}zu", resMap.size());
303     CHECK_AND_RETURN_RET_LOG(!resMap.empty(), E_OK, "OnDownloadThms: resMap is empty");
304     std::vector<OnDownloadThmsReqBody::DownloadThmsData> downloadThmsDataList;
305     for (const auto &res : resMap) {
306         OnDownloadThmsReqBody::DownloadThmsData downloadThmsData;
307         downloadThmsData.cloudId = res.first;
308         downloadThmsData.thumbStatus = res.second;
309         downloadThmsDataList.emplace_back(downloadThmsData);
310     }
311     std::vector<std::vector<OnDownloadThmsReqBody::DownloadThmsData>> splitedDataList;
312     this->processor_.SplitVector(
313         downloadThmsDataList, static_cast<size_t>(this->MAX_DOWNLOAD_THMS_SIZE), splitedDataList);
314     MEDIA_INFO_LOG("OnDownloadThms, total size: %{public}zu, split size: %{public}zu",
315         downloadThmsDataList.size(),
316         splitedDataList.size());
317     int32_t ret = E_OK;
318     int32_t subFailSize = 0;
319     for (auto &dataSubList : splitedDataList) {
320         ret = this->OnDownloadThmsInner(dataSubList, subFailSize);
321         failSize += subFailSize;
322         CHECK_AND_BREAK_ERR_LOG(ret == E_OK, "OnDownloadThmsInner failed, ret: %{public}d", ret);
323     }
324     return ret;
325 }
326 
GetVideoToCache(std::vector<CloudMetaData> & cloudMetaDataVec,int32_t size)327 int32_t CloudMediaDataClientHandler::GetVideoToCache(std::vector<CloudMetaData> &cloudMetaDataVec, int32_t size)
328 {
329     MEDIA_INFO_LOG("CloudMediaDataClientHandler::GetVideoToCache begin");
330     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_GET_VIDEO_TO_CACHE);
331     GetVideoToCacheRespBody respBody;
332     int32_t ret =
333         IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Get(operationCode, respBody);
334     if (ret != E_OK) {
335         MEDIA_ERR_LOG("Failed to GetAgingFile, ret: %{public}d", ret);
336         return ret;
337     }
338     for (auto &photosVo : respBody.photos) {
339         CloudMetaData cloudMetaData = CloudDataConvertToVo::ConvertPhotosVoToCloudMetaData(photosVo);
340         cloudMetaDataVec.push_back(cloudMetaData);
341     }
342     MEDIA_INFO_LOG("CloudMediaDataClientHandler::GetVideoToCache end");
343     return E_OK;
344 }
345 
GetFilePosStat(std::vector<uint64_t> & filePosStat)346 int32_t CloudMediaDataClientHandler::GetFilePosStat(std::vector<uint64_t> &filePosStat)
347 {
348     MEDIA_INFO_LOG("CloudMediaDataClientHandler::GetFilePosStat begin");
349     if (filePosStat.size() != SIZE_FILE_POSITION_LEN) {
350         MEDIA_ERR_LOG("GetFilePosStat file position stat size is wrong with %{public}zu", filePosStat.size());
351         return E_DATA;
352     }
353     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_GET_FILE_POS_STAT);
354     GetFilePosStatRespBody respBody;
355     int32_t ret =
356         IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Get(operationCode, respBody);
357     if (ret != E_OK) {
358         MEDIA_ERR_LOG("GetFilePosStat Failed to GetAgingFile, ret: %{public}d", ret);
359         return ret;
360     }
361     filePosStat = respBody.statList;
362     return E_OK;
363 }
364 
GetCloudThmStat(std::vector<uint64_t> & cloudThmStat)365 int32_t CloudMediaDataClientHandler::GetCloudThmStat(std::vector<uint64_t> &cloudThmStat)
366 {
367     MEDIA_INFO_LOG("CloudMediaDataClientHandler::GetCloudThmStat begin");
368     if (cloudThmStat.size() != SIZE_CLOUD_THM_STAT_LEN) {
369         MEDIA_ERR_LOG("cloud thm stat size is wrong with %{public}zu", cloudThmStat.size());
370         return E_DATA;
371     }
372     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_GET_CLOUD_THM_STAT);
373     GetCloudThmStatRespBody respBody;
374     int32_t ret =
375         IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Get(operationCode, respBody);
376     if (ret != E_OK) {
377         MEDIA_ERR_LOG("Failed to GetCloudThmStat, ret: %{public}d", ret);
378         return ret;
379     }
380     cloudThmStat = respBody.statList;
381     return E_OK;
382 }
383 
GetDirtyTypeStat(std::vector<uint64_t> & dirtyTypeStat)384 int32_t CloudMediaDataClientHandler::GetDirtyTypeStat(std::vector<uint64_t> &dirtyTypeStat)
385 {
386     MEDIA_INFO_LOG("CloudMediaDataClientHandler::GetDirtyTypeStat begin");
387     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_GET_DIRTY_TYPE_STAT);
388     GetDirtyTypeStatRespBody respBody;
389     int32_t ret = IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Get(operationCode, respBody);
390     CHECK_AND_RETURN_RET_LOG(ret == E_OK, ret, "Failed to GetDirtyTypeStat, ret: %{public}d", ret);
391     dirtyTypeStat = respBody.statList;
392     return E_OK;
393 }
394 
GetDownloadThmNum(int32_t & totalNum,int32_t type)395 int32_t CloudMediaDataClientHandler::GetDownloadThmNum(int32_t &totalNum, int32_t type)
396 {
397     MEDIA_INFO_LOG("CloudMediaDataClientHandler::GetDownloadThmNum begin");
398     GetDownloadThmNumReqBody req;
399     req.type = type;
400     GetDownloadThmNumRespBody respBody;
401     respBody.totalNum = 0;
402     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_GET_DOWNLOAD_THM_NUM);
403     int32_t ret =
404         IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Post(operationCode, req, respBody);
405     totalNum = respBody.totalNum;
406     if (ret != E_OK) {
407         MEDIA_ERR_LOG("Failed to GetDownloadThmNum, ret: %{public}d", ret);
408     }
409     return ret;
410 }
411 
UpdateLocalFileDirty(std::vector<MDKRecord> & records)412 int32_t CloudMediaDataClientHandler::UpdateLocalFileDirty(std::vector<MDKRecord> &records)
413 {
414     MEDIA_INFO_LOG("CloudMediaDataClientHandler::UpdateLocalFileDirty begin");
415     std::vector<std::string> cloudIds;
416     for (auto &record : records) {
417         if (!record.GetRecordId().empty()) {
418             MEDIA_INFO_LOG("UpdateLocalFileDirty CloudId: %{public}s", record.GetRecordId().c_str());
419             cloudIds.emplace_back(record.GetRecordId());
420         }
421     }
422     CHECK_AND_RETURN_RET_LOG(!cloudIds.empty(), E_OK, "UpdateLocalFileDirty: cloudIds is empty");
423     UpdateLocalFileDirtyReqBody req;
424     req.cloudIds = cloudIds;
425     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_UPDATE_LOCAL_FILE_DIRTY);
426     int32_t ret = IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Post(operationCode, req);
427     if (ret != E_OK) {
428         MEDIA_ERR_LOG("Failed to UpdateLocalFileDirty, ret: %{public}d", ret);
429     }
430     return ret;
431 }
432 
GetCloudSyncUnPreparedData(int32_t & result)433 int32_t CloudMediaDataClientHandler::GetCloudSyncUnPreparedData(int32_t &result)
434 {
435     MEDIA_INFO_LOG("CloudMediaDataClientHandler::GetCloudSyncUnPreparedData begin");
436     // request info.
437     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_GET_CLOUD_SYNC_UNPREPARED_DATA);
438     CloudSyncUnPreparedDataRespBody respBody;
439     respBody.count = 0;
440     int32_t ret = IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Get(operationCode, respBody);
441     if (ret != E_OK) {
442         MEDIA_ERR_LOG("Failed to GetCloudSyncUnPreparedData, ret: %{public}d", ret);
443     }
444     result = respBody.count;
445     return ret;
446 }
447 
SubmitCloudSyncPreparedDataTask()448 int32_t CloudMediaDataClientHandler::SubmitCloudSyncPreparedDataTask()
449 {
450     MEDIA_INFO_LOG("CloudMediaDataClientHandler::SubmitCloudSyncPreparedDataTask begin");
451     // request info.
452     uint32_t operationCode = static_cast<uint32_t>(CloudMediaOperationCode::CMD_SUBMIT_CLOUD_SYNC_UNPREPARED_DATA_TASK);
453     int32_t ret = IPC::UserDefineIPCClient().SetUserId(userId_).SetTraceId(this->traceId_).Post(operationCode);
454     if (ret != E_OK) {
455         MEDIA_ERR_LOG("Failed to SubmitCloudSyncPreparedDataTask, ret: %{public}d", ret);
456     }
457     return ret;
458 }
459 // LCOV_EXCL_STOP
460 }  // namespace OHOS::Media::CloudSync