• 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 
23 namespace OHOS {
24 namespace SysInstaller {
25 class SysInstallerKitsImpl {
26 public:
27     DISALLOW_COPY_AND_MOVE(SysInstallerKitsImpl);
28     static SysInstallerKitsImpl &GetInstance();
29     virtual int32_t SysInstallerInit();
30     virtual int32_t StartUpdatePackageZip(const std::string &pkgPath);
31     virtual int32_t SetUpdateCallback(const sptr<ISysInstallerCallback> &cb);
32     virtual int32_t GetUpdateStatus();
33     virtual int32_t StartUpdateParaZip(const std::string &pkgPath,
34         const std::string &location, const std::string &cfgDir);
35     virtual void ResetService(const wptr<IRemoteObject> &remote);
36     sptr<ISysInstaller> GetService();
37 
38     void LoadServiceSuccess();
39     void LoadServiceFail();
40 
41 private:
42     int32_t Init();
43     SysInstallerKitsImpl() = default;
44     virtual ~SysInstallerKitsImpl() = default;
45 
46 #ifndef UPDATER_UT
47 private:
48 #else
49 public:
50 #endif
51     // For death event procession
52     class DeathRecipient final : public IRemoteObject::DeathRecipient {
53     public:
54         DeathRecipient() = default;
55         ~DeathRecipient() final = default;
56         DISALLOW_COPY_AND_MOVE(DeathRecipient);
57         virtual void OnRemoteDied(const wptr<IRemoteObject> &remote);
58     };
59     std::mutex sysInstallerLock_;
60     sptr<ISysInstaller> sysInstaller_ {};
61     sptr<IRemoteObject::DeathRecipient> deathRecipient_ {};
62     sptr<ISysInstallerCallback> updateCallBack_ {};
63 
64     std::mutex getServiceMutex_;
65     std::condition_variable getServiceCv_;
66 };
67 } // namespace SysInstaller
68 } // namespace OHOS
69 #endif // SYS_INSTALLER_KITS_IMPL_H
70