• 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_MANAGER_HELPER_H
17 #define SYS_INSTALLER_MANAGER_HELPER_H
18 
19 #include <map>
20 #include <mutex>
21 
22 #include "action_processer.h"
23 #include "status_manager.h"
24 
25 namespace OHOS {
26 namespace SysInstaller {
27 class SysInstallerManagerHelper {
28 public:
29     SysInstallerManagerHelper() = default;
30     virtual ~SysInstallerManagerHelper() = default;
31 
32     virtual int32_t SysInstallerInit(const std::string &taskId);
33     virtual int32_t StartUpdatePackageZip(const std::string &taskId, const std::string &pkgPath);
34     virtual int32_t SetUpdateCallback(const std::string &taskId, const sptr<ISysInstallerCallback> &updateCallback);
35     virtual int32_t GetUpdateStatus(const std::string &taskId);
36     virtual int32_t StartUpdateParaZip(const std::string &taskId, const std::string &pkgPath,
37         const std::string &location, const std::string &cfgDir);
38     virtual int32_t StartDeleteParaZip(const std::string &taskId, const std::string &location,
39         const std::string &cfgDir);
40     virtual int32_t AccDecompressAndVerifyPkg(const std::string &taskId, const std::string &srcPath,
41         const std::string &dstPath, const uint32_t type);
42     virtual int32_t AccDeleteDir(const std::string &taskId, const std::string &dstPath);
43     virtual int32_t CancelUpdateVabPackageZip(const std::string &taskId);
44     virtual int32_t StartUpdateVabPackageZip(const std::string &taskId, const std::vector<std::string> &pkgPath);
45     virtual int32_t CreateVabSnapshotCowImg(const std::unordered_map<std::string, uint64_t> &partitionInfo);
46     virtual int32_t StartVabMerge(const std::string &taskId);
47     virtual int32_t ClearVabMetadataAndCow();
48     virtual std::string GetUpdateResult(const std::string &taskId, const std::string &taskType,
49         const std::string &resultType);
50     virtual int32_t VabUpdateActive();
51     virtual int32_t GetMetadataResult(const std::string &action, bool &result);
52     virtual int32_t StartAbSync();
53     virtual int32_t SetCpuAffinity(const std::string &taskId, unsigned int reservedCores);
54 
55     virtual int32_t InstallCloudRom(const std::string &taskId, InstallMode installMode,
56         const std::vector<FeatureInfo> &featureInfos, RebootStatus rebootStatus);
57     virtual int32_t UninstallCloudRom(const std::string &taskId,
58         const std::vector<FeatureInfo> &featureInfos, RebootStatus rebootStatus);
59     virtual int32_t GetFeatureStatus(const std::vector<FeatureInfo> &featureInfos,
60         std::vector<FeatureStatus> &statusInfos);
61     virtual int32_t GetAllFeatureStatus(const std::string &baseVersion, std::vector<FeatureStatus> &statusInfos);
62     virtual int32_t ClearCloudRom(const std::string &baseVersion, const std::string &featureName);
63 
64 protected:
65     std::map<std::string, std::shared_ptr<StatusManager>> statusManagerMap_;
66     std::map<std::string, std::shared_ptr<ActionProcesser>> actionProcesserMap_;
67     std::recursive_mutex statusLock_;
68     std::recursive_mutex processerLock_;
69 
70 protected:
71     std::shared_ptr<StatusManager> GetStatusManager(const std::string &taskId);
72     std::shared_ptr<ActionProcesser> GetActionProcesser(const std::string &taskId);
73 };
74 } // SysInstaller
75 } // namespace OHOS
76 #endif // SYS_INSTALLER_MANAGER_HELPER_H
77