mirror of
https://gitee.com/openharmony/interface_sdk-js
synced 2024-11-27 01:11:35 +00:00
childProcessManager新增startArkChildProcess接口
Signed-off-by: zhangyuhang72 <zhangyuhang72@huawei.com> Change-Id: Ic3cfdabf55d89cb15a96b99b1cd631718a04cc22
This commit is contained in:
parent
51ab067767
commit
16aaba2450
18
api/@ohos.app.ability.ChildProcess.d.ts
vendored
18
api/@ohos.app.ability.ChildProcess.d.ts
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"),
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -18,12 +18,14 @@
|
||||
* @kit AbilityKit
|
||||
*/
|
||||
|
||||
import type { ChildProcessArgs } from './@ohos.app.ability.ChildProcessArgs';
|
||||
|
||||
/**
|
||||
* The class of child process.
|
||||
* Child process to be started can inherit this class.
|
||||
*
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @stagemodelonly
|
||||
* @since 11
|
||||
*/
|
||||
export default class ChildProcess {
|
||||
@ -32,8 +34,16 @@ export default class ChildProcess {
|
||||
* Called when the child process is started.
|
||||
*
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @stagemodelonly
|
||||
* @since 11
|
||||
*/
|
||||
onStart(): void;
|
||||
/**
|
||||
* Called when the child process is started.
|
||||
*
|
||||
* @param { ChildProcessArgs } [args] - Indicates args passed to child process.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @stagemodelonly
|
||||
* @since 12
|
||||
*/
|
||||
onStart(args?: ChildProcessArgs): void;
|
||||
}
|
50
api/@ohos.app.ability.ChildProcessArgs.d.ts
vendored
Normal file
50
api/@ohos.app.ability.ChildProcessArgs.d.ts
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"),
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @kit AbilityKit
|
||||
*/
|
||||
|
||||
/**
|
||||
* Define args to pass to child process.
|
||||
*
|
||||
* @interface ChildProcessArgs
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @stagemodelonly
|
||||
* @since 12
|
||||
*/
|
||||
export interface ChildProcessArgs {
|
||||
/**
|
||||
* Custom parameters define by developer.
|
||||
* The parameters will be passed to child process entry function onStart(args).
|
||||
*
|
||||
* @type { ?string }
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @stagemodelonly
|
||||
* @since 12
|
||||
*/
|
||||
entryParams?: string;
|
||||
|
||||
/**
|
||||
* Indicates file descriptors that use to communicate between two processes.
|
||||
*
|
||||
* @type { ?Record<string, number> }
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @stagemodelonly
|
||||
* @since 12
|
||||
*/
|
||||
fds?: Record<string, number>;
|
||||
}
|
39
api/@ohos.app.ability.ChildProcessOptions.d.ts
vendored
Normal file
39
api/@ohos.app.ability.ChildProcessOptions.d.ts
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"),
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @kit AbilityKit
|
||||
*/
|
||||
|
||||
/**
|
||||
* Define options for starting child process.
|
||||
*
|
||||
* @interface ChildProcessOptions
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @stagemodelonly
|
||||
* @since 12
|
||||
*/
|
||||
export interface ChildProcessOptions {
|
||||
/**
|
||||
* Whether the child process runs in an isolated environment.
|
||||
*
|
||||
* @type { ?boolean }
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @stagemodelonly
|
||||
* @since 12
|
||||
*/
|
||||
isolationMode?: boolean;
|
||||
}
|
31
api/@ohos.app.ability.childProcessManager.d.ts
vendored
31
api/@ohos.app.ability.childProcessManager.d.ts
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"),
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -19,6 +19,8 @@
|
||||
*/
|
||||
|
||||
import type { AsyncCallback } from './@ohos.base';
|
||||
import type { ChildProcessArgs } from './@ohos.app.ability.ChildProcessArgs';
|
||||
import type { ChildProcessOptions } from './@ohos.app.ability.ChildProcessOptions';
|
||||
|
||||
/**
|
||||
* This module provides the capability to start and manage child process.
|
||||
@ -34,7 +36,7 @@ declare namespace childProcessManager {
|
||||
*
|
||||
* @enum { number }
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @stagemodelonly
|
||||
* @since 11
|
||||
*/
|
||||
export const enum StartMode {
|
||||
@ -44,7 +46,7 @@ declare namespace childProcessManager {
|
||||
* Binder IPC can not be used in child process in this mode, may cause crash.
|
||||
*
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @stagemodelonly
|
||||
* @since 11
|
||||
*/
|
||||
SELF_FORK = 0,
|
||||
@ -53,7 +55,7 @@ declare namespace childProcessManager {
|
||||
* Fork child process by app spawn.
|
||||
*
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @stagemodelonly
|
||||
* @since 11
|
||||
*/
|
||||
APP_SPAWN_FORK = 1,
|
||||
@ -71,7 +73,7 @@ declare namespace childProcessManager {
|
||||
* @throws { BusinessError } 16000061 - Operation not supported.
|
||||
* @throws { BusinessError } 16000062 - The number of child process exceeds upper bound.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @stagemodelonly
|
||||
* @since 11
|
||||
*/
|
||||
function startChildProcess(srcEntry: string, startMode: StartMode): Promise<number>;
|
||||
@ -88,11 +90,28 @@ declare namespace childProcessManager {
|
||||
* @throws { BusinessError } 16000061 - Operation not supported.
|
||||
* @throws { BusinessError } 16000062 - The number of child process exceeds upper bound.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @stagemodelonly
|
||||
* @since 11
|
||||
*/
|
||||
function startChildProcess(srcEntry: string, startMode: StartMode, callback: AsyncCallback<number>): void;
|
||||
|
||||
/**
|
||||
* Start child process with the given args and options.
|
||||
*
|
||||
* @param { string } srcEntry - Indicates child process source file entrance to be started.
|
||||
* @param { ChildProcessArgs } args - Indicates args to pass to child process.
|
||||
* @param { ChildProcessOptions } [options] - Indicates options for starting child process.
|
||||
* @returns { Promise<number> } Returns the started child process pid.
|
||||
* @throws { BusinessError } 401 - Parameter error. Possible causes:
|
||||
* 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
|
||||
* @throws { BusinessError } 801 - Capability not supported.
|
||||
* @throws { BusinessError } 16000050 - Internal error.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @stagemodelonly
|
||||
* @since 12
|
||||
*/
|
||||
function startArkChildProcess(srcEntry: string, args: ChildProcessArgs, options?: ChildProcessOptions): Promise<number>;
|
||||
|
||||
}
|
||||
|
||||
export default childProcessManager;
|
4
kits/@kit.AbilityKit.d.ts
vendored
4
kits/@kit.AbilityKit.d.ts
vendored
@ -39,6 +39,8 @@ import autoFillManager from '@ohos.app.ability.autoFillManager';
|
||||
import autoStartupManager from '@ohos.app.ability.autoStartupManager';
|
||||
import ChildProcess from '@ohos.app.ability.ChildProcess';
|
||||
import childProcessManager from '@ohos.app.ability.childProcessManager';
|
||||
import { ChildProcessArgs } from '@ohos.app.ability.ChildProcessArgs';
|
||||
import { ChildProcessOptions } from '@ohos.app.ability.ChildProcessOptions';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import { Configuration } from '@ohos.app.ability.Configuration';
|
||||
import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
|
||||
@ -112,5 +114,5 @@ export {
|
||||
innerBundleManager, insightIntent, insightIntentDriver, installer, launcherBundleManager, missionManager,
|
||||
overlay, particleAbility, quickFixManager, uriPermissionManager, wantAgent, wantConstant, privacyManager,
|
||||
EmbeddedUIExtensionAbility, StartupConfig, StartupConfigEntry, StartupListener, StartupTask, startupManager,
|
||||
screenLockFileManager, AtomicServiceOptions
|
||||
screenLockFileManager, AtomicServiceOptions, ChildProcessArgs, ChildProcessOptions
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user