ohos_abilitykit_sys/childprocess/childprocess_ffi.rs
1// automatically generated by rust-bindgen 0.71.1
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6use ohos_sys_opaque_types::OHIPCRemoteProxy;
7
8pub type Ability_NativeChildProcessResult = Result<(), Ability_NativeChildProcessErrorCode>;
9#[cfg(feature = "api-12")]
10#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
11impl Ability_NativeChildProcessErrorCode {
12 /// Invalid parameter.
13 pub const INVALID_PARAM: Ability_NativeChildProcessErrorCode =
14 Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(401).unwrap() });
15 /// Creating a native child process is not supported.
16 pub const NOT_SUPPORTED: Ability_NativeChildProcessErrorCode =
17 Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(801).unwrap() });
18 /// Internal error.
19 pub const INTERNAL: Ability_NativeChildProcessErrorCode =
20 Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16000050).unwrap() });
21 /// A new child process cannot be created during the startup of another native child process.
22 /// You can try again after the child process is started.
23 pub const BUSY: Ability_NativeChildProcessErrorCode =
24 Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010001).unwrap() });
25 /// Starting the native child process times out.
26 pub const TIMEOUT: Ability_NativeChildProcessErrorCode =
27 Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010002).unwrap() });
28 /// Server error.
29 pub const SERVICE_ERROR: Ability_NativeChildProcessErrorCode =
30 Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010003).unwrap() });
31 /// The multi-process mode is disabled. A child process cannot be started.
32 pub const MULTI_PROCESS_DISABLED: Ability_NativeChildProcessErrorCode =
33 Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010004).unwrap() });
34 /// A process cannot be created in a child process.
35 pub const ALREADY_IN_CHILD: Ability_NativeChildProcessErrorCode =
36 Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010005).unwrap() });
37 /// The number of native child processes reaches the maximum.
38 pub const MAX_CHILD_PROCESSES_REACHED: Ability_NativeChildProcessErrorCode =
39 Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010006).unwrap() });
40 /// The child process fails to load the dynamic library because the file does not exist
41 /// or the corresponding method is not implemented or exported.
42 pub const LIB_LOADING_FAILED: Ability_NativeChildProcessErrorCode =
43 Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010007).unwrap() });
44 /// The child process fails to call the OnConnect method of the dynamic library.
45 /// An invalid IPC object pointer may be returned.
46 pub const CONNECTION_FAILED: Ability_NativeChildProcessErrorCode =
47 Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010008).unwrap() });
48 /// The callback does not exist; it may not have been registered or has already been unregistered.
49 ///
50 /// Available since API-level: 20
51 #[cfg(feature = "api-20")]
52 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
53 pub const CALLBACK_NOT_EXIST: Ability_NativeChildProcessErrorCode =
54 Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010009).unwrap() });
55}
56#[repr(transparent)]
57/// Enumerates the error codes used by the native child process module.
58///
59/// Available since API-level: 12
60#[cfg(feature = "api-12")]
61#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
62#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
63pub struct Ability_NativeChildProcessErrorCode(pub core::num::NonZero<::core::ffi::c_uint>);
64#[cfg(feature = "api-13")]
65#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
66impl NativeChildProcess_IsolationMode {
67 /// Normal isolation mode, parent process shares the same sandbox or internet with the child process.
68 pub const NCP_ISOLATION_MODE_NORMAL: NativeChildProcess_IsolationMode =
69 NativeChildProcess_IsolationMode(0);
70 /// Isolated mode, parent process does not share the same sandbox or internet with the child process.
71 pub const NCP_ISOLATION_MODE_ISOLATED: NativeChildProcess_IsolationMode =
72 NativeChildProcess_IsolationMode(1);
73}
74#[repr(transparent)]
75/// Enumerates the isolation modes used by the native child process module.
76///
77/// Available since API-level: 13
78#[cfg(feature = "api-13")]
79#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
80#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
81pub struct NativeChildProcess_IsolationMode(pub ::core::ffi::c_uint);
82/// Defines a struct for the child process configs.
83///
84/// Available since API-level: 20
85#[cfg(feature = "api-20")]
86#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
87#[repr(C)]
88pub struct Ability_ChildProcessConfigs {
89 _unused: [u8; 0],
90}
91/// Defines a callback function for notifying the child process startup result.
92///
93/// # Arguments
94///
95/// * `errCode` - Error code corresponding to the callback function. The following values are available:
96/// [`NCP_NO_ERROR`] if the child process is created successfully.
97///
98/// [`NCP_ERR_LIB_LOADING_FAILED`] if loading the dynamic library file fails or the necessary export function
99/// is not implemented in the dynamic library.
100///
101/// [`NCP_ERR_CONNECTION_FAILED`] if the OnConnect method implemented in the dynamic library does not return
102/// a valid IPC stub pointer.
103///
104/// For details, see [`Ability_NativeChildProcess_ErrCode`].
105///
106/// * `remoteProxy` - Pointer to the IPC object of the child process. If an exception occurs, the value may be nullptr.
107/// The object must be released by calling [`OH_IPCRemoteProxy_Destory`] when it is no longer needed.
108/// [`OH_Ability_CreateNativeChildProcess`] [`OH_IPCRemoteProxy_Destory`]
109/// Available since API-level: 12
110#[cfg(feature = "api-12")]
111#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
112pub type OH_Ability_OnNativeChildProcessStarted = ::core::option::Option<
113 unsafe extern "C" fn(errCode: ::core::ffi::c_int, remoteProxy: *mut OHIPCRemoteProxy),
114>;
115/// The info of the file descriptors passed to child process.
116///
117/// Available since API-level: 13
118#[cfg(feature = "api-13")]
119#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
120#[repr(C)]
121#[derive(Debug, Copy, Clone)]
122pub struct NativeChildProcess_Fd {
123 /// the key of the file descriptor.
124 pub fdName: *mut ::core::ffi::c_char,
125 /// the value of the file descriptor.
126 pub fd: i32,
127 /// the next pointer of the linked list.
128 pub next: *mut NativeChildProcess_Fd,
129}
130/// The list of the info of the file descriptors passed to child process.
131///
132/// Available since API-level: 13
133#[cfg(feature = "api-13")]
134#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
135#[repr(C)]
136#[derive(Debug, Copy, Clone)]
137pub struct NativeChildProcess_FdList {
138 /// the head of the list.
139 /// For details, see [`NativeChildProcess_Fd`].
140 pub head: *mut NativeChildProcess_Fd,
141}
142/// The options used by the child process.
143///
144/// Available since API-level: 13
145#[cfg(feature = "api-13")]
146#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
147#[repr(C)]
148#[derive(Debug, Copy, Clone)]
149pub struct NativeChildProcess_Options {
150 /// the isolation mode used by the child process.
151 /// For details, see [`NativeChildProcess_IsolationMode`].
152 pub isolationMode: NativeChildProcess_IsolationMode,
153 /// reserved field for future extension purposes
154 pub reserved: i64,
155}
156/// The arguments passed to the child process.
157///
158/// Available since API-level: 13
159#[cfg(feature = "api-13")]
160#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
161#[repr(C)]
162#[derive(Debug, Copy, Clone)]
163pub struct NativeChildProcess_Args {
164 /// the entry parameter.
165 pub entryParams: *mut ::core::ffi::c_char,
166 /// the list of the info of the file descriptors passed to child process.
167 /// For details, see [`NativeChildProcess_FdList`].
168 pub fdList: NativeChildProcess_FdList,
169}
170/// Defines a callback function to handle the exit of a native child process.
171///
172/// # Arguments
173///
174/// * `pid` - The pid of the exited native child process.
175///
176/// * `signal` - The signal of the exited native child process.
177///
178/// Available since API-level: 20
179#[cfg(feature = "api-20")]
180#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
181pub type OH_Ability_OnNativeChildProcessExit =
182 ::core::option::Option<unsafe extern "C" fn(pid: i32, signal: i32)>;
183extern "C" {
184 /// Creates a new child process configs object.
185 /// The caller is responsible for destroying the returned object by calling
186 /// [`OH_Ability_DestroyChildProcessConfigs`] to avoid memory leaks.
187 ///
188 /// # Returns
189 ///
190 /// * Returns a pointer to the newly created [`Ability_ChildProcessConfigs`] object if successful.
191 /// Returns nullptr if an internal error occurs or memory allocation fails.
192 ///
193 /// Available since API-level: 20
194 #[cfg(feature = "api-20")]
195 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
196 pub fn OH_Ability_CreateChildProcessConfigs() -> *mut Ability_ChildProcessConfigs;
197 /// Destroys a child process configs object and releases associated resources.
198 ///
199 /// # Arguments
200 ///
201 /// * `configs` - Pointer to the child process configs object to be destroyed.
202 /// After this call, the pointer becomes invalid and must not be used.
203 /// Passing nullptr is allowed and will be ignored.
204 ///
205 /// # Returns
206 ///
207 /// * Returns [`NCP_NO_ERROR`] if the operation is successful or if the input is nullptr.
208 /// Returns [`NCP_ERR_INVALID_PARAM`] if the input parameters are invalid.
209 ///
210 /// Available since API-level: 20
211 #[cfg(feature = "api-20")]
212 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
213 pub fn OH_Ability_DestroyChildProcessConfigs(
214 configs: *mut Ability_ChildProcessConfigs,
215 ) -> Ability_NativeChildProcessResult;
216 /// Sets the isolation mode for the specified child process configs.
217 ///
218 /// # Arguments
219 ///
220 /// * `configs` - Pointer to the child process configs object. Must not be nullptr.
221 ///
222 /// * `isolationMode` - The isolation mode to set. See [`NativeChildProcess_IsolationMode`] for details.
223 ///
224 /// # Returns
225 ///
226 /// * Returns [`NCP_NO_ERROR`] if the isolation mode is set successfully.
227 /// Returns [`NCP_ERR_INVALID_PARAM`] if the input parameters are invalid.
228 ///
229 /// Available since API-level: 20
230 #[cfg(feature = "api-20")]
231 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
232 pub fn OH_Ability_ChildProcessConfigs_SetIsolationMode(
233 configs: *mut Ability_ChildProcessConfigs,
234 isolationMode: NativeChildProcess_IsolationMode,
235 ) -> Ability_NativeChildProcessResult;
236 /// Sets the UID isolation flag for the specified child process configs.
237 /// The isolationUid only takes effect when [`OH_Ability_ChildProcessConfigs_SetIsolationMode`]
238 /// is set to [`NCP_ISOLATION_MODE_ISOLATED`].
239 ///
240 /// # Arguments
241 ///
242 /// * `configs` - Pointer to the child process configs object. Must not be nullptr.
243 ///
244 /// * `isolationUid` - The UID isolation setting to apply.
245 /// - true: uses independent UID
246 /// - false: uses parent process's UID
247 ///
248 /// # Returns
249 ///
250 /// * Returns [`NCP_NO_ERROR`] if the UID isolation flag is set successfully.
251 /// Returns [`NCP_ERR_INVALID_PARAM`] if the input parameters are invalid.
252 ///
253 /// Available since API-level: 21
254 #[cfg(feature = "api-21")]
255 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
256 pub fn OH_Ability_ChildProcessConfigs_SetIsolationUid(
257 configs: *mut Ability_ChildProcessConfigs,
258 isolationUid: bool,
259 ) -> Ability_NativeChildProcessResult;
260 /// Sets the process name for the specified child process configs.
261 ///
262 /// # Arguments
263 ///
264 /// * `configs` - Pointer to the child process configs object. Must not be nullptr.
265 ///
266 /// * `processName` - The process name to set.
267 /// Must be a non-empty string containing only letters, digits, or underscores.
268 /// Maximum length is 64 characters.
269 /// The name ultimately assigned to the process is {bundleName}:{processName}.
270 ///
271 /// # Returns
272 ///
273 /// * Returns [`NCP_NO_ERROR`] if the process name is set successfully.
274 /// Returns [`NCP_ERR_INVALID_PARAM`] if the input parameters are invalid.
275 ///
276 /// Available since API-level: 20
277 #[cfg(feature = "api-20")]
278 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
279 pub fn OH_Ability_ChildProcessConfigs_SetProcessName(
280 configs: *mut Ability_ChildProcessConfigs,
281 processName: *const ::core::ffi::c_char,
282 ) -> Ability_NativeChildProcessResult;
283 /// Creates a child process, loads the specified dynamic library file, and returns the startup result
284 /// asynchronously through a callback parameter.
285 /// The callback notification is an independent thread. When implementing the callback function,
286 /// pay attention to thread synchronization and do not perform time-consuming operations to avoid long-time blocking.
287 ///
288 /// The dynamic library specified must implement and export the following functions:
289 ///
290 /// 1. OHIPCRemoteStub* NativeChildProcess_OnConnect()
291 ///
292 /// 2. void NativeChildProcess_MainProc()
293 ///
294 ///
295 /// The processing logic sequence is shown in the following pseudocode:
296 ///
297 /// Main process:
298 ///
299 /// 1. OH_Ability_CreateNativeChildProcess(libName, onProcessStartedCallback)
300 ///
301 /// Child process:
302 ///
303 /// 2. dlopen(libName)
304 ///
305 /// 3. dlsym("NativeChildProcess_OnConnect")
306 ///
307 /// 4. dlsym("NativeChildProcess_MainProc")
308 ///
309 /// 5. ipcRemote = NativeChildProcess_OnConnect()
310 ///
311 /// 6. NativeChildProcess_MainProc()
312 ///
313 /// Main process:
314 ///
315 /// 7. onProcessStartedCallback(ipcRemote, errCode)
316 ///
317 /// Child process:
318 ///
319 /// 8. The child process exits after the NativeChildProcess_MainProc() function is returned.
320 ///
321 ///
322 /// # Arguments
323 ///
324 /// * `libName` - Name of the dynamic library file loaded in the child process. The value cannot be nullptr.
325 ///
326 /// * `onProcessStarted` - Pointer to the callback function for notifying the child process startup result.
327 /// The value cannot be nullptr. For details, see [`OH_Ability_OnNativeChildProcessStarted`].
328 ///
329 /// # Returns
330 ///
331 /// * Returns [`NCP_NO_ERROR`] if the call is successful, but the actual startup result is notified by the
332 /// callback function.
333 ///
334 /// Returns [`NCP_ERR_INVALID_PARAM`] if the dynamic library name or callback function pointer is invalid.
335 ///
336 /// Returns [`NCP_ERR_NOT_SUPPORTED`] if the device does not support the creation of native child processes.
337 ///
338 /// Returns [`NCP_ERR_MULTI_PROCESS_DISABLED`] if the multi-process mode is disabled on the device.
339 ///
340 /// Returns [`NCP_ERR_ALREADY_IN_CHILD`] if it is not allowed to create another child process in the child process.
341 ///
342 /// Returns [`NCP_ERR_MAX_CHILD_PROCESSES_REACHED`] if the maximum number of native child processes is reached.
343 ///
344 /// For details, see [`Ability_NativeChildProcess_ErrCode`].
345 /// [`OH_Ability_OnNativeChildProcessStarted`]
346 /// Available since API-level: 12
347 #[cfg(feature = "api-12")]
348 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
349 pub fn OH_Ability_CreateNativeChildProcess(
350 libName: *const ::core::ffi::c_char,
351 onProcessStarted: OH_Ability_OnNativeChildProcessStarted,
352 ) -> ::core::ffi::c_int;
353 /// Creates a child process, loads the specified dynamic library file, and returns the startup result
354 /// asynchronously through a callback parameter.
355 /// The callback notification is an independent thread. When implementing the callback function,
356 /// pay attention to thread synchronization and do not perform time-consuming operations to avoid long-time blocking.
357 ///
358 /// The dynamic library specified must implement and export the following functions:
359 /// 1. OHIPCRemoteStub* NativeChildProcess_OnConnect()
360 /// 2. void NativeChildProcess_MainProc()
361 ///
362 /// The processing logic sequence is shown in the following pseudocode:
363 /// Main process:
364 /// 1. OH_Ability_CreateNativeChildProcessWithConfigs(libName, configs, onProcessStartedCallback)
365 /// Child process:
366 /// 2. dlopen(libName)
367 /// 3. dlsym("NativeChildProcess_OnConnect")
368 /// 4. dlsym("NativeChildProcess_MainProc")
369 /// 5. ipcRemote = NativeChildProcess_OnConnect()
370 /// 6. NativeChildProcess_MainProc()
371 /// Main process:
372 /// 7. onProcessStartedCallback(ipcRemote, errCode)
373 /// Child process:
374 /// 8. The child process exits after the NativeChildProcess_MainProc() function is returned.
375 ///
376 /// # Arguments
377 ///
378 /// * `libName` - Name of the dynamic library file loaded in the child process. The value cannot be nullptr.
379 ///
380 /// * `configs` - Pointer to the child process configs object. The value cannot be nullptr.
381 ///
382 /// * `onProcessStarted` - Pointer to the callback function for notifying the child process startup result.
383 /// The value cannot be nullptr. For details, see [`OH_Ability_OnNativeChildProcessStarted`].
384 ///
385 /// # Returns
386 ///
387 /// * Returns [`NCP_NO_ERROR`] if the call is successful, but the actual startup result is notified by the
388 /// callback function.
389 /// Returns [`NCP_ERR_INVALID_PARAM`] if the dynamic library name or callback function pointer is invalid.
390 /// Returns [`NCP_ERR_NOT_SUPPORTED`] if the device does not support the creation of native child processes.
391 /// Returns [`NCP_ERR_MULTI_PROCESS_DISABLED`] if the multi-process mode is disabled on the device.
392 /// Returns [`NCP_ERR_ALREADY_IN_CHILD`] if it is not allowed to create another child process in the child process.
393 /// Returns [`NCP_ERR_MAX_CHILD_PROCESSES_REACHED`] if the maximum number of native child processes is reached.
394 /// For details, see [`Ability_NativeChildProcess_ErrCode`].
395 /// [`OH_Ability_OnNativeChildProcessStarted`]
396 /// Available since API-level: 20
397 #[cfg(feature = "api-20")]
398 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
399 pub fn OH_Ability_CreateNativeChildProcessWithConfigs(
400 libName: *const ::core::ffi::c_char,
401 configs: *mut Ability_ChildProcessConfigs,
402 onProcessStarted: OH_Ability_OnNativeChildProcessStarted,
403 ) -> Ability_NativeChildProcessResult;
404 /// Starts a child process, loads the specified dynamic library file.
405 ///
406 /// The dynamic library specified must implement a function with NativeChildProcess_Args as a
407 /// pamameter(function name can be customized), and export the function, such as:
408 ///
409 /// 1. void Main(NativeChildProcess_Args args);
410 ///
411 /// The processing logic sequence is shown in the following pseudocode:
412 ///
413 /// Main process:
414 ///
415 /// 1. OH_Ability_StartNativeChildProcess(entryPoint, args, options)
416 ///
417 /// Child process:
418 ///
419 /// 2. dlopen(libName)
420 ///
421 /// 3. dlsym("Main")
422 ///
423 /// 4. Main(args)
424 ///
425 /// 5. The child process exits after the Main(args) function is returned
426 ///
427 ///
428 /// # Arguments
429 ///
430 /// * `entry` - Dynamic library and entry function loaded in child process, such as "libEntry.so:Main".
431 /// The value cannot be nullptr.
432 ///
433 /// * `args` - The arguments passed to the child process.
434 /// For details, see [`NativeChildProcess_Args`].
435 ///
436 /// * `options` - The child process options.
437 /// For details, see [`NativeChildProcess_Options`].
438 ///
439 /// * `pid` - The started child process id.
440 ///
441 /// # Returns
442 ///
443 /// * Returns [`NCP_NO_ERROR`] if the call is successful.
444 ///
445 /// Returns [`NCP_ERR_INVALID_PARAM`] if the dynamic library name or callback function pointer is invalid.
446 ///
447 /// Returns [`NCP_ERR_NOT_SUPPORTED`] if the device does not support the creation of native child processes.
448 ///
449 /// Returns [`NCP_ERR_ALREADY_IN_CHILD`] if it is not allowed to create another child process in the child process.
450 ///
451 /// Returns [`NCP_ERR_MAX_CHILD_PROCESSES_REACHED`] if the maximum number of native child processes is reached.
452 ///
453 /// For details, see [`Ability_NativeChildProcess_ErrCode`].
454 /// [`OH_Ability_OnNativeChildProcessStarted`]
455 /// Available since API-level: 13
456 #[cfg(feature = "api-13")]
457 #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
458 pub fn OH_Ability_StartNativeChildProcess(
459 entry: *const ::core::ffi::c_char,
460 args: NativeChildProcess_Args,
461 options: NativeChildProcess_Options,
462 pid: *mut i32,
463 ) -> Ability_NativeChildProcessResult;
464 /// Starts a child process, loads the specified dynamic library file.
465 ///
466 /// The dynamic library specified must implement a function with NativeChildProcess_Args as a
467 /// pamameter(function name can be customized), and export the function, such as:
468 /// 1. void Main(NativeChildProcess_Args args);
469 ///
470 /// The processing logic sequence is shown in the following pseudocode:
471 /// Main process:
472 /// 1. OH_Ability_StartNativeChildProcessWithConfigs(entryPoint, args, configs, &pid)
473 /// Child process:
474 /// 2. dlopen(libName)
475 /// 3. dlsym("Main")
476 /// 4. Main(args)
477 /// 5. The child process exits after the Main(args) function is returned
478 ///
479 /// # Arguments
480 ///
481 /// * `entry` - Dynamic library and entry function loaded in child process, such as "libEntry.so:Main".
482 /// The value cannot be nullptr.
483 ///
484 /// * `args` - The arguments passed to the child process.
485 /// For details, see [`NativeChildProcess_Args`].
486 ///
487 /// * `configs` - Pointer to the child process configs object. The value cannot be null.
488 /// For details, see [`Ability_ChildProcessConfigs`].
489 ///
490 /// * `pid` - The started child process id.
491 ///
492 /// # Returns
493 ///
494 /// * Returns [`NCP_NO_ERROR`] if the call is successful.
495 /// Returns [`NCP_ERR_INVALID_PARAM`] if the dynamic library name or callback function pointer is invalid.
496 /// Returns [`NCP_ERR_NOT_SUPPORTED`] if the device does not support the creation of native child processes.
497 /// Returns [`NCP_ERR_ALREADY_IN_CHILD`] if it is not allowed to create another child process in the child process.
498 /// Returns [`NCP_ERR_MAX_CHILD_PROCESSES_REACHED`] if the maximum number of native child processes is reached.
499 /// For details, see [`Ability_NativeChildProcess_ErrCode`].
500 ///
501 /// Available since API-level: 20
502 #[cfg(feature = "api-20")]
503 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
504 pub fn OH_Ability_StartNativeChildProcessWithConfigs(
505 entry: *const ::core::ffi::c_char,
506 args: NativeChildProcess_Args,
507 configs: *mut Ability_ChildProcessConfigs,
508 pid: *mut i32,
509 ) -> Ability_NativeChildProcessResult;
510 /// Child process get self NativeChildProcess_Args.
511 ///
512 ///
513 /// # Returns
514 ///
515 /// * Returns a pointer to the arguments passed to current child process.
516 ///
517 /// For details, see [`NativeChildProcess_Args`].
518 ///
519 /// Available since API-level: 17
520 #[cfg(feature = "api-17")]
521 #[cfg_attr(docsrs, doc(cfg(feature = "api-17")))]
522 pub fn OH_Ability_GetCurrentChildProcessArgs() -> *mut NativeChildProcess_Args;
523 /// Register a native child process exit callback.
524 /// Registering the same callback repeatedly will only keep one.
525 ///
526 /// # Arguments
527 ///
528 /// * `onProcessExit` - Pointer to the callback function to handle the exit of a native child process.
529 /// For details, see [`OH_Ability_OnNativeChildProcessExit`].
530 ///
531 /// # Returns
532 ///
533 /// * Returns [`NCP_NO_ERROR`] if the call is successful.
534 /// Returns [`NCP_ERR_INTERNAL`] if internal error occurs.
535 /// For details, see [`Ability_NativeChildProcess_ErrCode`].
536 ///
537 /// Available since API-level: 20
538 #[cfg(feature = "api-20")]
539 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
540 pub fn OH_Ability_RegisterNativeChildProcessExitCallback(
541 onProcessExit: OH_Ability_OnNativeChildProcessExit,
542 ) -> Ability_NativeChildProcessResult;
543 /// Unregister a native child process exit callback.
544 ///
545 /// # Arguments
546 ///
547 /// * `onProcessExit` - Pointer to the callback function to handle the exit of a native child process.
548 /// For details, see [`OH_Ability_OnNativeChildProcessExit`].
549 ///
550 /// # Returns
551 ///
552 /// * Returns [`NCP_NO_ERROR`] if the call is successful.
553 /// Returns [`NCP_ERR_INTERNAL`] if internal error occurs.
554 /// Returns [`NCP_ERR_CALLBACK_NOT_EXIST`] if the callback is not exist.
555 /// For details, see [`Ability_NativeChildProcess_ErrCode`].
556 ///
557 /// Available since API-level: 20
558 #[cfg(feature = "api-20")]
559 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
560 pub fn OH_Ability_UnregisterNativeChildProcessExitCallback(
561 onProcessExit: OH_Ability_OnNativeChildProcessExit,
562 ) -> Ability_NativeChildProcessResult;
563}