1 /*
2 * Copyright (c) 2025 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 #include "mock_child_process_manager.h"
17
18 namespace OHOS {
19 namespace AbilityRuntime {
20 namespace {
21 bool g_jitEnabled = false;
22 AbilityRuntime::Runtime::DebugOption g_debugOption;
23 const std::string LARGE_SCREEN = "large_screen";
24 }
25 bool ChildProcessManager::signalRegistered_ = false;
26
GetInstance()27 ChildProcessManager &ChildProcessManager::GetInstance()
28 {
29 static ChildProcessManager instance;
30 return instance;
31 }
32
ChildProcessManager()33 ChildProcessManager::ChildProcessManager()
34 {
35 }
36
~ChildProcessManager()37 ChildProcessManager::~ChildProcessManager()
38 {
39 }
40
StartChildProcessBySelfFork(const std::string & srcEntry,pid_t & pid)41 ChildProcessManagerErrorCode ChildProcessManager::StartChildProcessBySelfFork(const std::string &srcEntry, pid_t &pid)
42 {
43 return ChildProcessManagerErrorCode::ERR_OK;
44 }
45
IsMultiProcessFeatureApp(const AppExecFwk::BundleInfo & bundleInfo)46 bool ChildProcessManager::IsMultiProcessFeatureApp(const AppExecFwk::BundleInfo &bundleInfo)
47 {
48 return false;
49 }
50
StartChildProcessByAppSpawnFork(const std::string & srcEntry,pid_t & pid)51 ChildProcessManagerErrorCode ChildProcessManager::StartChildProcessByAppSpawnFork(
52 const std::string &srcEntry, pid_t &pid)
53 {
54 return ChildProcessManagerErrorCode::ERR_ALREADY_IN_CHILD_PROCESS;
55 }
56
StartChildProcessWithArgs(const std::string & srcEntry,pid_t & pid,int32_t childProcessType,const AppExecFwk::ChildProcessArgs & args,const AppExecFwk::ChildProcessOptions & options)57 ChildProcessManagerErrorCode ChildProcessManager::StartChildProcessWithArgs(
58 const std::string &srcEntry, pid_t &pid, int32_t childProcessType, const AppExecFwk::ChildProcessArgs &args,
59 const AppExecFwk::ChildProcessOptions &options)
60 {
61 return startErrorCode_;
62 }
63
StartNativeChildProcessByAppSpawnFork(const std::string & libName,const sptr<IRemoteObject> & callbackStub,const std::string & customProcessName)64 ChildProcessManagerErrorCode ChildProcessManager::StartNativeChildProcessByAppSpawnFork(
65 const std::string &libName, const sptr<IRemoteObject> &callbackStub, const std::string &customProcessName)
66 {
67 return ChildProcessManagerErrorCode::ERR_OK;
68 }
69
RegisterSignal()70 void ChildProcessManager::RegisterSignal()
71 {
72 }
73
HandleSigChild(int32_t signo)74 void ChildProcessManager::HandleSigChild(int32_t signo)
75 {
76 }
77
AllowChildProcessOnDevice()78 bool ChildProcessManager::AllowChildProcessOnDevice()
79 {
80 return false;
81 }
82
PreCheckSelfFork()83 ChildProcessManagerErrorCode ChildProcessManager::PreCheckSelfFork()
84 {
85 return ChildProcessManagerErrorCode::ERR_OK;
86 }
87
PreCheck(int32_t childProcessType)88 ChildProcessManagerErrorCode ChildProcessManager::PreCheck(int32_t childProcessType)
89 {
90 return ChildProcessManagerErrorCode::ERR_OK;
91 }
92
IsChildProcess()93 bool ChildProcessManager::IsChildProcess()
94 {
95 return false;
96 }
97
IsChildProcessBySelfFork()98 bool ChildProcessManager::IsChildProcessBySelfFork()
99 {
100 return isChildProcessBySelfFork_;
101 }
102
HandleChildProcessBySelfFork(const std::string & srcEntry,const AppExecFwk::BundleInfo & bundleInfo)103 void ChildProcessManager::HandleChildProcessBySelfFork(const std::string &srcEntry,
104 const AppExecFwk::BundleInfo &bundleInfo)
105 {
106 }
107
LoadJsFile(const std::string & srcEntry,const AppExecFwk::HapModuleInfo & hapModuleInfo,std::unique_ptr<AbilityRuntime::Runtime> & runtime,std::shared_ptr<AppExecFwk::ChildProcessArgs> args)108 bool ChildProcessManager::LoadJsFile(const std::string &srcEntry, const AppExecFwk::HapModuleInfo &hapModuleInfo,
109 std::unique_ptr<AbilityRuntime::Runtime> &runtime, std::shared_ptr<AppExecFwk::ChildProcessArgs> args)
110 {
111 return true;
112 }
113
LoadNativeLib(const std::string & moduleName,const std::string & libPath,const sptr<IRemoteObject> & mainProcessCb)114 bool ChildProcessManager::LoadNativeLib(const std::string &moduleName,
115 const std::string &libPath, const sptr<IRemoteObject> &mainProcessCb)
116 {
117 return true;
118 }
119
LoadNativeLibWithArgs(const std::string & moduleName,const std::string & srcEntry,const std::string & entryFunc,std::shared_ptr<AppExecFwk::ChildProcessArgs> args)120 bool ChildProcessManager::LoadNativeLibWithArgs(const std::string &moduleName, const std::string &srcEntry,
121 const std::string &entryFunc, std::shared_ptr<AppExecFwk::ChildProcessArgs> args)
122 {
123 return true;
124 }
125
CreateRuntime(const AppExecFwk::BundleInfo & bundleInfo,const AppExecFwk::HapModuleInfo & hapModuleInfo,const bool fromAppSpawn,const bool jitEnabled)126 std::unique_ptr<AbilityRuntime::Runtime> ChildProcessManager::CreateRuntime(const AppExecFwk::BundleInfo &bundleInfo,
127 const AppExecFwk::HapModuleInfo &hapModuleInfo, const bool fromAppSpawn, const bool jitEnabled)
128 {
129 return nullptr;
130 }
131
GetBundleInfo(AppExecFwk::BundleInfo & bundleInfo)132 bool ChildProcessManager::GetBundleInfo(AppExecFwk::BundleInfo &bundleInfo)
133 {
134 return false;
135 }
136
GetEntryHapModuleInfo(const AppExecFwk::BundleInfo & bundleInfo,AppExecFwk::HapModuleInfo & hapModuleInfo)137 bool ChildProcessManager::GetEntryHapModuleInfo(const AppExecFwk::BundleInfo &bundleInfo,
138 AppExecFwk::HapModuleInfo &hapModuleInfo)
139 {
140 return false;
141 }
142
GetHapModuleInfo(const AppExecFwk::BundleInfo & bundleInfo,const std::string & moduleName,AppExecFwk::HapModuleInfo & hapModuleInfo)143 bool ChildProcessManager::GetHapModuleInfo(const AppExecFwk::BundleInfo &bundleInfo, const std::string &moduleName,
144 AppExecFwk::HapModuleInfo &hapModuleInfo)
145 {
146 return false;
147 }
148
HasChildProcessRecord()149 bool ChildProcessManager::HasChildProcessRecord()
150 {
151 return false;
152 }
153
GetAppMgr()154 sptr<AppExecFwk::IAppMgr> ChildProcessManager::GetAppMgr()
155 {
156 return nullptr;
157 }
158
SetForkProcessJITEnabled(bool jitEnabled)159 void ChildProcessManager::SetForkProcessJITEnabled(bool jitEnabled)
160 {
161 g_jitEnabled = jitEnabled;
162 }
163
SetForkProcessDebugOption(const std::string bundleName,const bool isStartWithDebug,const bool isDebugApp,const bool isStartWithNative)164 void ChildProcessManager::SetForkProcessDebugOption(const std::string bundleName, const bool isStartWithDebug,
165 const bool isDebugApp, const bool isStartWithNative)
166 {
167 }
168
SetAppSpawnForkDebugOption(Runtime::DebugOption & debugOption,std::shared_ptr<AppExecFwk::ChildProcessInfo> processInfo)169 void ChildProcessManager::SetAppSpawnForkDebugOption(Runtime::DebugOption &debugOption,
170 std::shared_ptr<AppExecFwk::ChildProcessInfo> processInfo)
171 {
172 }
173
MakeProcessName(const std::string & srcEntry)174 void ChildProcessManager::MakeProcessName(const std::string &srcEntry)
175 {
176 }
177
GetModuleNameFromSrcEntry(const std::string & srcEntry)178 std::string ChildProcessManager::GetModuleNameFromSrcEntry(const std::string &srcEntry)
179 {
180 return "";
181 }
182 } // namespace AbilityRuntime
183 } // namespace OHOS