161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"),
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit FormKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport { AsyncCallback } from '../@ohos.base';
2261847f8eSopenharmony_ciimport type { ConnectOptions } from '../ability/connectOptions';
2361847f8eSopenharmony_ciimport ExtensionContext from './ExtensionContext';
2461847f8eSopenharmony_ciimport Want from '../@ohos.app.ability.Want';
2561847f8eSopenharmony_ci
2661847f8eSopenharmony_ci/**
2761847f8eSopenharmony_ci * The context of form extension. It allows access to
2861847f8eSopenharmony_ci * formExtension-specific resources.
2961847f8eSopenharmony_ci *
3061847f8eSopenharmony_ci * @extends ExtensionContext
3161847f8eSopenharmony_ci * @syscap SystemCapability.Ability.Form
3261847f8eSopenharmony_ci * @stagemodelonly
3361847f8eSopenharmony_ci * @since 9
3461847f8eSopenharmony_ci */
3561847f8eSopenharmony_ci/**
3661847f8eSopenharmony_ci * The context of form extension. It allows access to
3761847f8eSopenharmony_ci * formExtension-specific resources.
3861847f8eSopenharmony_ci *
3961847f8eSopenharmony_ci * @extends ExtensionContext
4061847f8eSopenharmony_ci * @syscap SystemCapability.Ability.Form
4161847f8eSopenharmony_ci * @stagemodelonly
4261847f8eSopenharmony_ci * @atomicservice
4361847f8eSopenharmony_ci * @since 11
4461847f8eSopenharmony_ci */
4561847f8eSopenharmony_ciexport default class FormExtensionContext extends ExtensionContext {
4661847f8eSopenharmony_ci  /**
4761847f8eSopenharmony_ci   * Start an ability within the same bundle.
4861847f8eSopenharmony_ci   *
4961847f8eSopenharmony_ci   * @param { Want } want - includes ability name, parameters and relative info sending to an ability.
5061847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - The callback of startAbility.
5161847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The application is not a system application.
5261847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes:
5361847f8eSopenharmony_ci   *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
5461847f8eSopenharmony_ci   * @throws { BusinessError } 16500050 - An IPC connection error happened.
5561847f8eSopenharmony_ci   * @throws { BusinessError } 16500100 - Failed to obtain the configuration information.
5661847f8eSopenharmony_ci   * @throws { BusinessError } 16500101 - The application is not a system application.
5761847f8eSopenharmony_ci   * @throws { BusinessError } 16501000 - An internal functional error occurred.
5861847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
5961847f8eSopenharmony_ci   * @systemapi
6061847f8eSopenharmony_ci   * @stagemodelonly
6161847f8eSopenharmony_ci   * @since 9
6261847f8eSopenharmony_ci   */
6361847f8eSopenharmony_ci  /**
6461847f8eSopenharmony_ci   * Start an ability.
6561847f8eSopenharmony_ci   *
6661847f8eSopenharmony_ci   * @param { Want } want - includes ability name, parameters and relative info sending to an ability.
6761847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - The callback of startAbility.
6861847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The application is not a system application.
6961847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes:
7061847f8eSopenharmony_ci   *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
7161847f8eSopenharmony_ci   * @throws { BusinessError } 16500050 - An IPC connection error happened.
7261847f8eSopenharmony_ci   * @throws { BusinessError } 16500100 - Failed to obtain the configuration information.
7361847f8eSopenharmony_ci   * @throws { BusinessError } 16501000 - An internal functional error occurred.
7461847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
7561847f8eSopenharmony_ci   * @systemapi
7661847f8eSopenharmony_ci   * @stagemodelonly
7761847f8eSopenharmony_ci   * @since 12
7861847f8eSopenharmony_ci   */
7961847f8eSopenharmony_ci  startAbility(want: Want, callback: AsyncCallback<void>): void;
8061847f8eSopenharmony_ci
8161847f8eSopenharmony_ci  /**
8261847f8eSopenharmony_ci   * Start an ability within the same bundle.
8361847f8eSopenharmony_ci   *
8461847f8eSopenharmony_ci   * @param { Want } want - includes ability name, parameters and relative info sending to an ability.
8561847f8eSopenharmony_ci   * @returns { Promise<void> } The promise returned by the function.
8661847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The application is not a system application.
8761847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes:
8861847f8eSopenharmony_ci   *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
8961847f8eSopenharmony_ci   * @throws { BusinessError } 16500050 - An IPC connection error happened.
9061847f8eSopenharmony_ci   * @throws { BusinessError } 16500100 - Failed to obtain the configuration information.
9161847f8eSopenharmony_ci   * @throws { BusinessError } 16500101 - The application is not a system application.
9261847f8eSopenharmony_ci   * @throws { BusinessError } 16501000 - An internal functional error occurred.
9361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
9461847f8eSopenharmony_ci   * @systemapi
9561847f8eSopenharmony_ci   * @stagemodelonly
9661847f8eSopenharmony_ci   * @since 9
9761847f8eSopenharmony_ci   */
9861847f8eSopenharmony_ci  /**
9961847f8eSopenharmony_ci   * Start an ability.
10061847f8eSopenharmony_ci   *
10161847f8eSopenharmony_ci   * @param { Want } want - includes ability name, parameters and relative info sending to an ability.
10261847f8eSopenharmony_ci   * @returns { Promise<void> } The promise returned by the function.
10361847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The application is not a system application.
10461847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes:
10561847f8eSopenharmony_ci   *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
10661847f8eSopenharmony_ci   * @throws { BusinessError } 16500050 - An IPC connection error happened.
10761847f8eSopenharmony_ci   * @throws { BusinessError } 16500100 - Failed to obtain the configuration information.
10861847f8eSopenharmony_ci   * @throws { BusinessError } 16501000 - An internal functional error occurred.
10961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
11061847f8eSopenharmony_ci   * @systemapi
11161847f8eSopenharmony_ci   * @stagemodelonly
11261847f8eSopenharmony_ci   * @since 12
11361847f8eSopenharmony_ci   */
11461847f8eSopenharmony_ci  startAbility(want: Want): Promise<void>;
11561847f8eSopenharmony_ci
11661847f8eSopenharmony_ci  /**
11761847f8eSopenharmony_ci   * Connect a service extension ability.
11861847f8eSopenharmony_ci   * If the target service extension ability is visible, you can connect the target service extension ability;
11961847f8eSopenharmony_ci   * If the target service extension ability is invisible,
12061847f8eSopenharmony_ci   * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to connect target invisible service extension ability.
12161847f8eSopenharmony_ci   * If the target service extension ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
12261847f8eSopenharmony_ci   * <p>This method can be called by an ability or service extension, but the destination of the connection must be a
12361847f8eSopenharmony_ci   * service extension. You must implement the {@link ConnectOptions} interface to obtain the proxy of the target
12461847f8eSopenharmony_ci   * service extension when the Service extension is connected.</p>
12561847f8eSopenharmony_ci   *
12661847f8eSopenharmony_ci   * @param { Want } want - Indicates the service extension to connect.
12761847f8eSopenharmony_ci   * @param { ConnectOptions } options - Indicates the callback of connection.
12861847f8eSopenharmony_ci   * @returns { number } Returns the connection id.
12961847f8eSopenharmony_ci   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
13061847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes:
13161847f8eSopenharmony_ci   *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
13261847f8eSopenharmony_ci   * @throws { BusinessError } 16000001 - The specified ability does not exist.
13361847f8eSopenharmony_ci   * @throws { BusinessError } 16000002 - Incorrect ability type.
13461847f8eSopenharmony_ci   * @throws { BusinessError } 16000004 - Can not start invisible component.
13561847f8eSopenharmony_ci   * @throws { BusinessError } 16000005 - The specified process does not have the permission.
13661847f8eSopenharmony_ci   * @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
13761847f8eSopenharmony_ci   * @throws { BusinessError } 16000008 - The crowdtesting application expires.
13861847f8eSopenharmony_ci   * @throws { BusinessError } 16000011 - The context does not exist.
13961847f8eSopenharmony_ci   * @throws { BusinessError } 16000050 - Internal error.
14061847f8eSopenharmony_ci   * @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
14161847f8eSopenharmony_ci   * @throws { BusinessError } 16000055 - Installation-free timed out.
14261847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
14361847f8eSopenharmony_ci   * @systemapi
14461847f8eSopenharmony_ci   * @stagemodelonly
14561847f8eSopenharmony_ci   * @since 10
14661847f8eSopenharmony_ci   */
14761847f8eSopenharmony_ci  connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
14861847f8eSopenharmony_ci
14961847f8eSopenharmony_ci  /**
15061847f8eSopenharmony_ci   * Disconnect an ability to a service extension, in contrast to {@link connectServiceExtensionAbility}.
15161847f8eSopenharmony_ci   *
15261847f8eSopenharmony_ci   * @param { number } connection - the connection id returned from connectServiceExtensionAbility api.
15361847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - The callback of disconnectServiceExtensionAbility.
15461847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes:
15561847f8eSopenharmony_ci   *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
15661847f8eSopenharmony_ci   * @throws { BusinessError } 16000011 - The context does not exist.
15761847f8eSopenharmony_ci   * @throws { BusinessError } 16000050 - Internal error.
15861847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
15961847f8eSopenharmony_ci   * @systemapi
16061847f8eSopenharmony_ci   * @stagemodelonly
16161847f8eSopenharmony_ci   * @since 10
16261847f8eSopenharmony_ci   */
16361847f8eSopenharmony_ci  disconnectServiceExtensionAbility(connection: number, callback: AsyncCallback<void>): void;
16461847f8eSopenharmony_ci
16561847f8eSopenharmony_ci  /**
16661847f8eSopenharmony_ci   * Disconnect an ability to a service extension, in contrast to {@link connectServiceExtensionAbility}.
16761847f8eSopenharmony_ci   *
16861847f8eSopenharmony_ci   * @param { number } connection - the connection id returned from connectServiceExtensionAbility api.
16961847f8eSopenharmony_ci   * @returns { Promise<void> } The promise returned by the function.
17061847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes:
17161847f8eSopenharmony_ci   *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
17261847f8eSopenharmony_ci   * @throws { BusinessError } 16000011 - The context does not exist.
17361847f8eSopenharmony_ci   * @throws { BusinessError } 16000050 - Internal error.
17461847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
17561847f8eSopenharmony_ci   * @systemapi
17661847f8eSopenharmony_ci   * @stagemodelonly
17761847f8eSopenharmony_ci   * @since 10
17861847f8eSopenharmony_ci   */
17961847f8eSopenharmony_ci  disconnectServiceExtensionAbility(connection: number): Promise<void>;
18061847f8eSopenharmony_ci}
181