• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_IEXECUTE_MODE_H
17 #define FIRMWARE_IEXECUTE_MODE_H
18 
19 #include "firmware_common.h"
20 #include "firmware_component.h"
21 #include "firmware_iexecutor.h"
22 #include "update_helper.h"
23 
24 namespace OHOS {
25 namespace UpdateEngine {
26 using OnCheckComplete = std::function<void(BusinessError &businessError, CheckResult &checkResult)>;
27 using OnExecuteFinishCallback = std::function<void()>;
28 
29 class FirmwareIExecuteMode {
30 public:
31     virtual ~FirmwareIExecuteMode() = default;
GetNextStep(FirmwareStep step)32     virtual FirmwareStep GetNextStep(FirmwareStep step)
33     {
34         return FirmwareStep::COMPLETE;
35     };
36 
SetCheckResult(CheckStatus status,const Duration & duration,const std::vector<FirmwareComponent> & componentList,const CheckAndAuthInfo & checkAndAuthInfo)37     virtual void SetCheckResult(CheckStatus status, const Duration &duration,
38         const std::vector<FirmwareComponent> &componentList, const CheckAndAuthInfo &checkAndAuthInfo) {};
SetDownloadProgress(const Progress & progress)39     virtual void SetDownloadProgress(const Progress &progress) {};
SetInstallResult(const InstallCallbackInfo & installCallbackInfo)40     virtual void SetInstallResult(const InstallCallbackInfo &installCallbackInfo) {};
SetApplyResult(bool isSuccess)41     virtual void SetApplyResult(bool isSuccess) {};
42 
43     // HandleComplete 往FirmwareManager回调之后,当前mode会被析构掉,因此后续不应该再调用任何逻辑
HandleComplete()44     virtual void HandleComplete() {};
45 
GetDownloadOptions()46     virtual DownloadOptions GetDownloadOptions()
47     {
48         DownloadOptions downloadOptions;
49         return downloadOptions;
50     };
51 
GetUpgradeOptions()52     virtual UpgradeOptions GetUpgradeOptions()
53     {
54         UpgradeOptions upgradeOptions;
55         return upgradeOptions;
56     };
57 
GetInstallType()58     virtual InstallType GetInstallType()
59     {
60         return InstallType::UPDATER;
61     }
62 };
63 } // namespace UpdateEngine
64 } // namespace OHOS
65 #endif // FIRMWARE_IEXECUTE_MODE_H