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 #ifndef FIRMWARE_INSTALL_APPLY_MODE_H 17 #define FIRMWARE_INSTALL_APPLY_MODE_H 18 19 #include "firmware_common.h" 20 #include "firmware_download_data_processor.h" 21 #include "firmware_iexecute_mode.h" 22 #include "firmware_install_data_processor.h" 23 #include "firmware_preferences_utils.h" 24 #include "firmware_task.h" 25 #include "device_adapter.h" 26 #include "update_helper.h" 27 28 namespace OHOS { 29 namespace UpdateEngine { 30 class FirmwareInstallApplyMode final : public FirmwareIExecuteMode { 31 public: FirmwareInstallApplyMode(const UpgradeOptions & upgradeOptions,BusinessError & businessError,InstallType installType,OnExecuteFinishCallback onExecuteFinishCallback)32 FirmwareInstallApplyMode(const UpgradeOptions &upgradeOptions, BusinessError &businessError, 33 InstallType installType, OnExecuteFinishCallback onExecuteFinishCallback) 34 : upgradeOptions_(upgradeOptions), 35 businessError_(businessError), 36 installType_(installType), 37 onExecuteFinishCallback_(onExecuteFinishCallback) {} 38 39 ~FirmwareInstallApplyMode() = default; 40 FirmwareStep GetNextStep(FirmwareStep step) final; 41 void SetInstallResult(const InstallCallbackInfo &installCallbackInfo) final; 42 UpgradeOptions GetUpgradeOptions() final; 43 InstallType GetInstallType(); 44 void HandleComplete() final; 45 46 private: 47 FirmwareStep GetStepAfterInit(); 48 FirmwareStep GetStepAfterInstall(); 49 FirmwareStep GetStepAfterApply(); 50 FirmwareStep GetStepForInstallAndApplyOrder(); 51 bool IsAllowInstall(); 52 bool IsUpgradeFilesReady(); 53 54 void GetTask(); 55 void SetApplyResult(bool isSuccess); 56 57 private: 58 FirmwareInstallDataProcessor installStepDataProcessor_; 59 UpgradeOptions upgradeOptions_; 60 BusinessError &businessError_; 61 InstallType installType_; 62 OnExecuteFinishCallback onExecuteFinishCallback_; 63 FirmwareTask tasks_; 64 std::shared_ptr<FirmwarePreferencesUtil> preferencesUtil_ = 65 DelayedSingleton<FirmwarePreferencesUtil>::GetInstance(); 66 }; 67 } // namespace UpdateEngine 68 } // namespace OHOS 69 #endif // FIRMWARE_INSTALL_APPLY_MODE_H