• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef SYS_INSTALLER_ACTION_PROCESSER_H
17 #define SYS_INSTALLER_ACTION_PROCESSER_H
18 
19 #include <deque>
20 #include <map>
21 #include "iaction.h"
22 #include "macros_updater.h"
23 #include "status_manager.h"
24 
25 namespace OHOS {
26 namespace SysInstaller {
27 class ActionProcesser {
28 public:
ActionProcesser(std::shared_ptr<StatusManager> statusManager)29     ActionProcesser(std::shared_ptr<StatusManager> statusManager) : statusManager_(statusManager) {}
30     ~ActionProcesser() = default;
31 
32     bool IsRunning();
33     void AddAction(std::unique_ptr<IAction> action);
34     void Start();
35     bool Stop();
36     void Suspend();
37     void Resume();
38     void CompletedAction(InstallerErrCode errCode, const std::string &errStr);
39     bool SetCpuAffinity(unsigned int reservedCores);
40 
41 private:
42     bool WaitActionExit();
43     void StartNextAction();
44 
45     std::shared_ptr<StatusManager> statusManager_ {};
46     std::deque<std::unique_ptr<IAction>> actionQue_ {};
47     std::unique_ptr<IAction> curAction_ {};
48     bool isRunning_ = false;
49     bool isSuspend_ = false;
50 };
51 } // SysInstaller
52 } // namespace OHOS
53 #endif // SYS_INSTALLER_ACTION_PROCESSER_H
54