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 "quick_fix_deploy_state.h" 17 18 #include "app_log_wrapper.h" 19 #include "quick_fix_boot_scanner.h" 20 #include "quick_fix_deployer.h" 21 #include "quick_fix_switch_state.h" 22 23 namespace OHOS { 24 namespace AppExecFwk { QuickFixDeployState(const InnerAppQuickFix & innerQuickFixInfo)25QuickFixDeployState::QuickFixDeployState(const InnerAppQuickFix &innerQuickFixInfo) 26 : innerQuickFixInfo_(innerQuickFixInfo) 27 { 28 APP_LOGI("create QuickFixDeployState"); 29 } 30 Process()31ErrCode QuickFixDeployState::Process() 32 { 33 const std::string bundleName = innerQuickFixInfo_.GetAppQuickFix().bundleName; 34 APP_LOGD("start to process deploy-status bundle %{public}s", bundleName.c_str()); 35 std::vector<std::string> bundlePaths; 36 std::unique_ptr<QuickFixDeployer> deployer = std::make_unique<QuickFixDeployer>(bundlePaths); 37 InnerAppQuickFix oldInnerAppQuickFix; 38 auto res = deployer->ToDeployEndStatus(innerQuickFixInfo_, oldInnerAppQuickFix); 39 if (res != ERR_OK) { 40 APP_LOGE("deploy quick fix failed due to %{public}d", res); 41 return res; 42 } 43 44 std::shared_ptr<QuickFixSwitchState> switchState = std::make_shared<QuickFixSwitchState>(bundleName, true); 45 46 auto scanner = DelayedSingleton<QuickFixBootScanner>::GetInstance(); 47 if (scanner == nullptr) { 48 APP_LOGE("scanner is nullptr"); 49 return ERR_BUNDLEMANAGER_QUICK_FIX_INTERNAL_ERROR; 50 } 51 scanner->SetQuickFixState(switchState); 52 return scanner->ProcessState(); 53 } 54 } // AppExecFwk 55 } // OHOS