• 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_KITS_IMPL_H
17 #define SYS_INSTALLER_KITS_IMPL_H
18 
19 #include "singleton.h"
20 #include "isys_installer.h"
21 #include "isys_installer_callback.h"
22 #include "isys_installer_callback_func.h"
23 
24 namespace OHOS {
25 namespace SysInstaller {
26 class SysInstallerKitsImpl {
27 public:
28     DISALLOW_COPY_AND_MOVE(SysInstallerKitsImpl);
29     static SysInstallerKitsImpl &GetInstance();
30     virtual int32_t SysInstallerInit(const std::string &taskId, bool bStreamUpgrade = false);
31     virtual int32_t StartUpdatePackageZip(const std::string &taskId, const std::string &pkgPath);
32     virtual int32_t StartStreamUpdate();
33     virtual int32_t StopStreamUpdate();
34     virtual int32_t ProcessStreamData(const uint8_t *buffer, uint32_t size);
35     virtual int32_t SetUpdateCallback(const std::string &taskId, sptr<ISysInstallerCallbackFunc> callback);
36     virtual int32_t GetUpdateStatus(const std::string &taskId);
37     virtual int32_t StartUpdateParaZip(const std::string &taskId, const std::string &pkgPath,
38         const std::string &location, const std::string &cfgDir);
39     virtual int32_t StartDeleteParaZip(const std::string &taskId, const std::string &location,
40         const std::string &cfgDir);
41     virtual int32_t AccDecompressAndVerifyPkg(const std::string &taskId, const std::string &srcPath,
42         const std::string &dstPath, const uint32_t type);
43     virtual int32_t AccDeleteDir(const std::string &taskId, const std::string &dstPath);
44     virtual int32_t CancelUpdateVabPackageZip(const std::string &taskId);
45     virtual int32_t StartUpdateVabPackageZip(const std::string &taskId, const std::vector<std::string> &pkgPath);
46     virtual int32_t CreateVabSnapshotCowImg(const std::unordered_map<std::string, uint64_t> &partitionInfo);
47     virtual int32_t StartVabMerge(const std::string &taskId);
48     virtual int32_t ClearVabMetadataAndCow();
49     virtual std::string GetUpdateResult(const std::string &taskId, const std::string &taskType,
50         const std::string &resultType);
51     virtual int32_t VabUpdateActive();
52     virtual int32_t GetMetadataResult(const std::string &action, bool &result);
53     virtual int32_t InstallCloudRom(const std::string &taskId, InstallMode installMode,
54         const std::vector<FeatureInfo> &featureInfos, RebootStatus rebootStatus);
55     virtual int32_t UninstallCloudRom(const std::string &taskId,
56         const std::vector<FeatureInfo> &featureInfos, RebootStatus rebootStatus);
57     virtual int32_t GetFeatureStatus(const std::vector<FeatureInfo> &featureInfos,
58         std::vector<FeatureStatus> &statusInfos);
59     virtual int32_t GetAllFeatureStatus(const std::string &baseVersion, std::vector<FeatureStatus> &statusInfos);
60     virtual int32_t ClearCloudRom(const std::string &baseVersion, const std::string &featureName);
61     virtual void ResetService(const wptr<IRemoteObject> &remote);
62     sptr<ISysInstaller> GetService();
63     virtual int32_t ExitSysInstaller();
64     virtual int32_t StartAbSync();
65     virtual int32_t SetCpuAffinity(const std::string &taskId, unsigned int reservedCores);
66 
67     void LoadServiceSuccess();
68     void LoadServiceFail();
69 
70 private:
71     int32_t Init();
72     SysInstallerKitsImpl() = default;
73     virtual ~SysInstallerKitsImpl() = default;
74 
75 #ifndef UPDATER_UT
76 private:
77 #else
78 public:
79 #endif
80     // For death event procession
81     class DeathRecipient final : public IRemoteObject::DeathRecipient {
82     public:
83         DeathRecipient() = default;
84         ~DeathRecipient() final = default;
85         DISALLOW_COPY_AND_MOVE(DeathRecipient);
86         virtual void OnRemoteDied(const wptr<IRemoteObject> &remote);
87     };
88     std::mutex sysInstallerLock_;
89     sptr<ISysInstaller> sysInstaller_ {};
90     sptr<IRemoteObject::DeathRecipient> deathRecipient_ {};
91 
92     std::mutex serviceMutex_;
93     std::condition_variable serviceCv_;
94 };
95 } // namespace SysInstaller
96 } // namespace OHOS
97 #endif // SYS_INSTALLER_KITS_IMPL_H
98