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_FLOW_MANAGER_H 17 #define FIRMWARE_FLOW_MANAGER_H 18 19 #include "update_helper.h" 20 #include "firmware_common.h" 21 #include "firmware_component.h" 22 #include "firmware_iexecute_mode.h" 23 #include "firmware_iexecutor.h" 24 25 namespace OHOS { 26 namespace UpdateEngine { 27 class FirmwareFlowManager { 28 public: 29 FirmwareFlowManager(); 30 ~FirmwareFlowManager(); 31 32 void SetExecuteMode(std::shared_ptr<FirmwareIExecuteMode> executeMode); 33 void Start(); 34 35 private: 36 void Execute(); 37 std::shared_ptr<FirmwareIExecutor> CreateInstance(FirmwareStep step); 38 void Complete(); 39 40 void OnCheckCallback(CheckStatus status, const Duration &duration, 41 const std::vector<FirmwareComponent> &componentList, const CheckAndAuthInfo &checkAndAuthInfo); 42 43 void OnDownloadCallback(const Progress &progress); 44 void OnInstallCallback(const InstallCallbackInfo &installCallbackInfo); 45 void OnApplyCallback(bool isSuccess); 46 47 private: 48 std::shared_ptr<FirmwareIExecuteMode> executeMode_; 49 std::shared_ptr<FirmwareIExecutor> executor_; 50 FirmwareStep nextStep_ = FirmwareStep::INIT; 51 }; 52 } // namespace UpdateEngine 53 } // namespace OHOS 54 #endif // FIRMWARE_FLOW_MANAGER_H