1 /*
2 * Copyright (c) 2023 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 #include "ipc/download_asset_callback_proxy.h"
17
18 #include "dfs_error.h"
19 #include "utils_log.h"
20
21 namespace OHOS::FileManagement::CloudSync {
22 using namespace std;
23
OnFinished(const TaskId taskId,const std::string & uri,const int32_t result)24 void DownloadAssetCallbackProxy::OnFinished(const TaskId taskId, const std::string &uri, const int32_t result)
25 {
26 LOGI("Start");
27 MessageParcel data;
28 MessageParcel reply;
29 MessageOption option;
30
31 if (!data.WriteInterfaceToken(GetDescriptor())) {
32 LOGE("Failed to write interface token");
33 return;
34 }
35
36 if (!data.WriteUint64(taskId)) {
37 LOGE("Failed to send the uri");
38 return;
39 }
40
41 if (!data.WriteString(uri)) {
42 LOGE("Failed to send the uri");
43 return;
44 }
45
46 if (!data.WriteInt32(result)) {
47 LOGE("Failed to send the state");
48 return;
49 }
50
51 auto remote = Remote();
52 if (!remote) {
53 LOGE("remote is nullptr");
54 return;
55 }
56 int32_t ret = remote->SendRequest(IDownloadAssetCallback::SERVICE_CMD_ON_DOWNLOAD_FINSHED, data, reply, option);
57 if (ret != E_OK) {
58 LOGE("Failed to send out the requeset, ret:%{public}d", ret);
59 return;
60 }
61 LOGI("End");
62 return;
63 }
64 } // namespace OHOS::FileManagement::CloudSync