• 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_INSTALL_EXECUTOR_H
17 #define FIRMWARE_INSTALL_EXECUTOR_H
18 
19 #include "firmware_component.h"
20 #include "firmware_common.h"
21 #include "firmware_iexecutor.h"
22 #include "firmware_task.h"
23 #include "firmware_preferences_utils.h"
24 #include "firmware_install.h"
25 
26 namespace OHOS {
27 namespace UpdateService {
28 class FirmwareInstallExecutor : public FirmwareIExecutor {
29 public:
FirmwareInstallExecutor(InstallType installType,FirmwareInstallExecutorCallback firmwareInstallCallback)30     FirmwareInstallExecutor(InstallType installType, FirmwareInstallExecutorCallback firmwareInstallCallback)
31         : installType_(installType), installCallback_(firmwareInstallCallback) {}
32     ~FirmwareInstallExecutor() = default;
33     void Execute() final;
34 
35 private:
36     void DoInstall();
37     void GetTask();
38     void HandleInstallProgress(const FirmwareComponent &component);
39     void HandleInstallResult(const bool result, const ErrorMessage &errMsg, const UpgradeStatus &status);
40     void StartInstall();
41 
42 private:
43     InstallType installType_;
44     FirmwareInstallExecutorCallback installCallback_;
45     InstallCallbackInfo installCallbackInfo_;
46     std::vector<FirmwareComponent> components_;
47     FirmwareTask tasks_;
48     Progress taskProgress_;
49     std::shared_ptr<FirmwarePreferencesUtil> preferencesUtil_ =
50         DelayedSingleton<FirmwarePreferencesUtil>::GetInstance();
51 };
52 } // namespace UpdateService
53 } // namespace OHOS
54 #endif // FIRMWARE_INSTALL_EXECUTOR_H