1 /*
2 * Copyright (c) 2022 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 "sys_installer_callback_proxy.h"
17
18 #include "log/log.h"
19 #include "securec.h"
20
21 namespace OHOS {
22 namespace SysInstaller {
23 using namespace Updater;
24
OnUpgradeProgress(int updateStatus,int percent)25 void SysInstallerCallbackProxy::OnUpgradeProgress(int updateStatus, int percent)
26 {
27 LOG(INFO) << "OnUpgradeProgress";
28 MessageParcel data;
29 MessageParcel reply;
30 MessageOption option { MessageOption::TF_SYNC };
31
32 if (!data.WriteInterfaceToken(GetDescriptor())) {
33 LOG(INFO) << "UpdateCallbackProxy WriteInterfaceToken fail";
34 return;
35 }
36
37 auto remote = Remote();
38 if (remote == nullptr) {
39 LOG(ERROR) << "Can not get remote";
40 return;
41 }
42
43 data.WriteInt32(updateStatus);
44 data.WriteInt32(percent);
45 int32_t result = remote->SendRequest(UPDATE_RESULT, data, reply, option);
46 if (result != ERR_OK) {
47 LOG(ERROR) << "Can not SendRequest " << result;
48 }
49 }
50 }
51 } // namespace OHOS
52