• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-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/**
17 * @file
18 * @kit FormKit
19 */
20
21/*** if arkts 1.1 */
22import { AsyncCallback } from '../@ohos.base';
23import type { ConnectOptions } from '../ability/connectOptions';
24import Want from '../@ohos.app.ability.Want';
25/*** endif */
26import ExtensionContext from './ExtensionContext';
27
28/**
29 * The context of form extension. It allows access to
30 * formExtension-specific resources.
31 *
32 * @extends ExtensionContext
33 * @syscap SystemCapability.Ability.Form
34 * @stagemodelonly
35 * @since 9
36 */
37/**
38 * The context of form extension. It allows access to
39 * formExtension-specific resources.
40 *
41 * @extends ExtensionContext
42 * @syscap SystemCapability.Ability.Form
43 * @stagemodelonly
44 * @atomicservice
45 * @since arkts {'1.1':'11', '1.2':'20'}
46 * @arkts 1.1&1.2
47 */
48declare class FormExtensionContext extends ExtensionContext {
49  /**
50   * Start an ability within the same bundle.
51   *
52   * @param { Want } want - includes ability name, parameters and relative info sending to an ability.
53   * @param { AsyncCallback<void> } callback - The callback of startAbility.
54   * @throws { BusinessError } 202 - The application is not a system application.
55   * @throws { BusinessError } 401 - Parameter error. Possible causes:
56   *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
57   * @throws { BusinessError } 16500050 - An IPC connection error happened.
58   * @throws { BusinessError } 16500100 - Failed to obtain the configuration information.
59   * @throws { BusinessError } 16500101 - The application is not a system application.
60   * @throws { BusinessError } 16501000 - An internal functional error occurred.
61   * @syscap SystemCapability.Ability.Form
62   * @systemapi
63   * @stagemodelonly
64   * @since 9
65   */
66  /**
67   * Start an ability.
68   *
69   * @param { Want } want - includes ability name, parameters and relative info sending to an ability.
70   * @param { AsyncCallback<void> } callback - The callback of startAbility.
71   * @throws { BusinessError } 202 - The application is not a system application.
72   * @throws { BusinessError } 401 - Parameter error. Possible causes:
73   *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
74   * @throws { BusinessError } 16500050 - An IPC connection error happened.
75   * @throws { BusinessError } 16500100 - Failed to obtain the configuration information.
76   * @throws { BusinessError } 16501000 - An internal functional error occurred.
77   * @syscap SystemCapability.Ability.Form
78   * @systemapi
79   * @stagemodelonly
80   * @since 12
81   */
82  startAbility(want: Want, callback: AsyncCallback<void>): void;
83
84  /**
85   * Start an ability within the same bundle.
86   *
87   * @param { Want } want - includes ability name, parameters and relative info sending to an ability.
88   * @returns { Promise<void> } The promise returned by the function.
89   * @throws { BusinessError } 202 - The application is not a system application.
90   * @throws { BusinessError } 401 - Parameter error. Possible causes:
91   *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
92   * @throws { BusinessError } 16500050 - An IPC connection error happened.
93   * @throws { BusinessError } 16500100 - Failed to obtain the configuration information.
94   * @throws { BusinessError } 16500101 - The application is not a system application.
95   * @throws { BusinessError } 16501000 - An internal functional error occurred.
96   * @syscap SystemCapability.Ability.Form
97   * @systemapi
98   * @stagemodelonly
99   * @since 9
100   */
101  /**
102   * Start an ability.
103   *
104   * @param { Want } want - includes ability name, parameters and relative info sending to an ability.
105   * @returns { Promise<void> } The promise returned by the function.
106   * @throws { BusinessError } 202 - The application is not a system application.
107   * @throws { BusinessError } 401 - Parameter error. Possible causes:
108   *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
109   * @throws { BusinessError } 16500050 - An IPC connection error happened.
110   * @throws { BusinessError } 16500100 - Failed to obtain the configuration information.
111   * @throws { BusinessError } 16501000 - An internal functional error occurred.
112   * @syscap SystemCapability.Ability.Form
113   * @systemapi
114   * @stagemodelonly
115   * @since 12
116   */
117  startAbility(want: Want): Promise<void>;
118
119  /**
120   * Connect a service extension ability.
121   * If the target service extension ability is visible, you can connect the target service extension ability;
122   * If the target service extension ability is invisible,
123   * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to connect target invisible service extension ability.
124   * If the target service extension ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
125   * <p>This method can be called by an ability or service extension, but the destination of the connection must be a
126   * service extension. You must implement the {@link ConnectOptions} interface to obtain the proxy of the target
127   * service extension when the Service extension is connected.</p>
128   *
129   * @param { Want } want - Indicates the service extension to connect.
130   * @param { ConnectOptions } options - Indicates the callback of connection.
131   * @returns { number } Returns the connection id.
132   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
133   * @throws { BusinessError } 401 - Parameter error. Possible causes:
134   *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
135   * @throws { BusinessError } 16000001 - The specified ability does not exist.
136   * @throws { BusinessError } 16000002 - Incorrect ability type.
137   * @throws { BusinessError } 16000004 - Can not start invisible component.
138   * @throws { BusinessError } 16000005 - The specified process does not have the permission.
139   * @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
140   * @throws { BusinessError } 16000008 - The crowdtesting application expires.
141   * @throws { BusinessError } 16000011 - The context does not exist.
142   * @throws { BusinessError } 16000050 - Internal error.
143   * @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
144   * @throws { BusinessError } 16000055 - Installation-free timed out.
145   * @syscap SystemCapability.Ability.Form
146   * @systemapi
147   * @stagemodelonly
148   * @since 10
149   */
150  connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
151
152  /**
153   * Disconnect an ability to a service extension, in contrast to {@link connectServiceExtensionAbility}.
154   *
155   * @param { number } connection - the connection id returned from connectServiceExtensionAbility api.
156   * @param { AsyncCallback<void> } callback - The callback of disconnectServiceExtensionAbility.
157   * @throws { BusinessError } 401 - Parameter error. Possible causes:
158   *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
159   * @throws { BusinessError } 16000011 - The context does not exist.
160   * @throws { BusinessError } 16000050 - Internal error.
161   * @syscap SystemCapability.Ability.Form
162   * @systemapi
163   * @stagemodelonly
164   * @since 10
165   */
166  disconnectServiceExtensionAbility(connection: number, callback: AsyncCallback<void>): void;
167
168  /**
169   * Disconnect an ability to a service extension, in contrast to {@link connectServiceExtensionAbility}.
170   *
171   * @param { number } connection - the connection id returned from connectServiceExtensionAbility api.
172   * @returns { Promise<void> } The promise returned by the function.
173   * @throws { BusinessError } 401 - Parameter error. Possible causes:
174   *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
175   * @throws { BusinessError } 16000011 - The context does not exist.
176   * @throws { BusinessError } 16000050 - Internal error.
177   * @syscap SystemCapability.Ability.Form
178   * @systemapi
179   * @stagemodelonly
180   * @since 10
181   */
182  disconnectServiceExtensionAbility(connection: number): Promise<void>;
183}
184export default FormExtensionContext;
185