• 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 UPDATE_SERVICE_MODULE_MANAGER_H
17 #define UPDATE_SERVICE_MODULE_MANAGER_H
18 
19 #include <map>
20 #include <set>
21 #include <string>
22 #include <vector>
23 
24 #include "ipc_skeleton.h"
25 #include "refbase.h"
26 #include "system_ability_ondemand_reason.h"
27 
28 #include "update_service_module.h"
29 
30 namespace OHOS {
31 namespace UpdateEngine {
32 class ModuleManager {
33 public:
34     ModuleManager();
35     ~ModuleManager() = default;
36 
37     static ModuleManager& GetInstance();
38 
39     void LoadModule(std::string libPath);
40     bool IsModuleLoaded();
41     void HookFunc(std::vector<uint32_t>, RequestFuncType handleRemoteRequest);
42     int32_t HandleFunc(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption &option);
43     void HookOnStartOnStopFunc(std::string phase, LifeCycleFuncType handleSAOnStartOnStop);
44     void HandleOnStartOnStopFunc(std::string phase, const OHOS::SystemAbilityOnDemandReason &reason);
45     void HookOnIdleFunc(std::string phase, LifeCycleFuncReturnType handleSAOnIdle);
46     int32_t HandleOnIdleFunc(std::string phase, const OHOS::SystemAbilityOnDemandReason &reason);
47 
48     static std::map<uint32_t, RequestFuncType> onRemoteRequestFuncMap_;
49 
50 private:
51     int32_t retryInterval_ = 0;
52     void *dueModuleHandler = nullptr;
53     static std::map<std::string, LifeCycleFuncType> onStartOnStopFuncMap_;
54     static std::map<std::string, LifeCycleFuncReturnType> onIdleFuncMap_;
55     static bool isLoaded;
56 };
57 } // namespace UpdateEngine
58 } // namespace OHOS
59 #endif // UPDATE_SERVICE_MODULE_MANAGER_H
60