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