• 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 SYS_INSTALLER_MODULE_UPDATE_KITS_IMPL_H
17 #define SYS_INSTALLER_MODULE_UPDATE_KITS_IMPL_H
18 
19 #include "imodule_update.h"
20 #include "module_update_kits.h"
21 #include "singleton.h"
22 
23 namespace OHOS {
24 namespace SysInstaller {
25 class ModuleUpdateKitsImpl final : public ModuleUpdateKits,
26     public DelayedRefSingleton<ModuleUpdateKitsImpl> {
27     DECLARE_DELAYED_REF_SINGLETON(ModuleUpdateKitsImpl);
28 public:
29     DISALLOW_COPY_AND_MOVE(ModuleUpdateKitsImpl);
30 
31     int32_t InitModuleUpdate() final;
32     int32_t InstallModulePackage(const std::string &pkgPath) final;
33     int32_t UninstallModulePackage(const std::string &hmpName) final;
34     int32_t GetModulePackageInfo(const std::string &hmpName,
35         std::list<ModulePackageInfo> &modulePackageInfos) final;
36     int32_t ReportModuleUpdateStatus(const ModuleUpdateStatus &status) final;
37     int32_t ExitModuleUpdate() final;
38 
39     std::vector<HmpVersionInfo> GetHmpVersionInfo() final;
40     int32_t StartUpdateHmpPackage(const std::string &path,
41         sptr<ISysInstallerCallbackFunc> callback) final;
42     std::vector<HmpUpdateInfo> GetHmpUpdateResult() final;
43 
44 #ifndef UPDATER_UT
45 private:
46 #endif
47     // For death event procession
48     class DeathRecipient final : public IRemoteObject::DeathRecipient {
49     public:
50         DeathRecipient() = default;
51         ~DeathRecipient() final = default;
52         DISALLOW_COPY_AND_MOVE(DeathRecipient);
53         void OnRemoteDied(const wptr<IRemoteObject> &remote) final;
54     };
55 
56     void ResetService(const wptr<IRemoteObject> &remote);
57     sptr<IModuleUpdate> GetService();
58 
59     std::mutex moduleUpdateLock_;
60     sptr<IModuleUpdate> moduleUpdate_ {};
61     sptr<IRemoteObject::DeathRecipient> deathRecipient_ {};
62     sptr<ISysInstallerCallback> updateCallBack_ {};
63 };
64 } // namespace SysInstaller
65 } // namespace OHOS
66 #endif // SYS_INSTALLER_MODULE_UPDATE_KITS_IMPL_H
67