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.h"
17
18 #include "if_system_ability_manager.h"
19 #include "iservice_registry.h"
20 #include "log/log.h"
21 #include "securec.h"
22 #include "utils.h"
23
24 #include "isys_installer_callback.h"
25 #include "sys_installer_common.h"
26 #include "sys_installer_sa_ipc_interface_code.h"
27
28 namespace OHOS {
29 namespace SysInstaller {
30 using namespace Updater;
SysInstallerCallback(sptr<ISysInstallerCallbackFunc> callback)31 SysInstallerCallback::SysInstallerCallback(sptr<ISysInstallerCallbackFunc> callback)
32 {
33 callback_ = callback;
34 }
35
OnUpgradeProgress(UpdateStatus updateStatus,int percent,const std::string & resultMsg)36 ErrCode SysInstallerCallback::OnUpgradeProgress(UpdateStatus updateStatus, int percent,
37 const std::string &resultMsg)
38 {
39 LOG(INFO) << "updateStatus:" << static_cast<int>(updateStatus) << " percent:" << percent << " msg:" << resultMsg;
40 if (callback_ != nullptr) {
41 callback_->OnUpgradeProgress(updateStatus, percent, resultMsg);
42 }
43 return 0;
44 }
45
OnUpgradeDealLen(UpdateStatus updateStatus,int dealLen,const std::string & resultMsg)46 ErrCode SysInstallerCallback::OnUpgradeDealLen(UpdateStatus updateStatus, int dealLen,
47 const std::string &resultMsg)
48 {
49 LOG(INFO) << "updateStatus: " << static_cast<int>(updateStatus) << " dealLen:" << dealLen << " msg:" << resultMsg;
50 if (callback_ != nullptr) {
51 callback_->OnUpgradeDealLen(updateStatus, dealLen, resultMsg);
52 }
53 return 0;
54 }
55
OnUpgradeFeatureStatus(const FeatureStatus & statusInfo)56 ErrCode SysInstallerCallback::OnUpgradeFeatureStatus(const FeatureStatus &statusInfo)
57 {
58 LOG(INFO) << "updateFeatureStatus:" << statusInfo.featureName << " status:" << static_cast<int>(statusInfo.status)
59 << " errCode:" << statusInfo.errorInfo.errorCode << " errMsg:" << statusInfo.errorInfo.errorMsg;
60 if (callback_ != nullptr) {
61 callback_->OnUpgradeFeatureStatus(statusInfo);
62 }
63 return 0;
64 }
65 }
66 } // namespace OHOS
67