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 #ifndef SYS_INSTALLER_MODULE_UPDATE_MAIN_H 16 #define SYS_INSTALLER_MODULE_UPDATE_MAIN_H 17 18 #include "crash_sys_event_listener.h" 19 #include "iservice_registry.h" 20 #include "module_update_service.h" 21 #include "singleton.h" 22 23 namespace OHOS { 24 namespace SysInstaller { 25 using namespace HiviewDFX; 26 27 class ModuleUpdateMain final : public Singleton<ModuleUpdateMain> { 28 DECLARE_SINGLETON(ModuleUpdateMain); 29 30 public: 31 bool RegisterModuleUpdateService(); 32 bool WaitForSysEventService(); 33 bool CheckBootComplete() const; 34 void WatchBootComplete() const; 35 bool RegisterSysEventListener(); 36 void OnSysEventServiceDied(); 37 void OnProcessCrash(const std::string &processName); 38 39 private: 40 static void BootCompleteCallback(const char *key, const char *value, void *context); 41 void OnBootCompleted(); 42 sptr<ISystemAbilityManager> &GetSystemAbilityManager(); 43 44 sptr<ISystemAbilityManager> samgr_ = nullptr; 45 sptr<ModuleUpdateService> moduleUpdate_ = nullptr; 46 std::shared_ptr<CrashSysEventListener> crashListener_ = nullptr; 47 }; 48 } // namespace SysInstaller 49 } // namespace OHOS 50 #endif // SYS_INSTALLER_MODULE_UPDATE_MAIN_H