• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/cloud_download_callback_proxy.h"
17 
18 #include <sstream>
19 
20 #include "dfs_error.h"
21 #include "iservice_registry.h"
22 #include "system_ability_definition.h"
23 #include "utils_log.h"
24 
25 namespace OHOS::FileManagement::CloudSync {
26 using namespace std;
27 
OnDownloadProcess(const DownloadProgressObj & progress)28 void CloudDownloadCallbackProxy::OnDownloadProcess(const DownloadProgressObj& progress)
29 {
30     LOGI("Start");
31     MessageParcel data;
32     MessageParcel reply;
33     MessageOption option;
34 
35     if (!data.WriteInterfaceToken(GetDescriptor())) {
36         LOGE("Failed to write interface token");
37         return;
38     }
39 
40     if (!data.WriteParcelable(&progress)) {
41         LOGE("Failed to write progress");
42         return;
43     }
44 
45     auto remote = Remote();
46     if (!remote) {
47         LOGE("remote is nullptr");
48         return;
49     }
50     int32_t ret = remote->SendRequest(ICloudDownloadCallback::SERVICE_CMD_ON_PROCESS, data, reply, option);
51     if (ret != E_OK) {
52         stringstream ss;
53         ss << "Failed to send out the requeset, errno:" << ret;
54         LOGE("%{public}s", ss.str().c_str());
55         return;
56     }
57     LOGI("End");
58     return;
59 }
60 
61 } // namespace OHOS::FileManagement::CloudSync
62