• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 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 AbilityKit
19 */
20
21import type { AbilityResult } from './ability/abilityResult';
22import type AbilityStartCallback from './application/AbilityStartCallback';
23import type { AsyncCallback } from './@ohos.base';
24import type Want from './@ohos.app.ability.Want';
25import type StartOptions from './@ohos.app.ability.StartOptions';
26import type uiExtensionHost from './@ohos.uiExtensionHost';
27import type uiExtension from './@ohos.arkui.uiExtension';
28
29/**
30 * class of ui extension content session.
31 *
32 * @syscap SystemCapability.Ability.AbilityRuntime.Core
33 * @stagemodelonly
34 * @since 10
35 */
36export default class UIExtensionContentSession {
37  /**
38   * Send data from an ui extension to an ui extension component.
39   *
40   * @param { object } data - Indicates the data send to ui extension component.
41   * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app.
42   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
43   * 2. Incorrect parameter types.
44   * @throws { BusinessError } 16000050 - Internal error.
45   * @syscap SystemCapability.Ability.AbilityRuntime.Core
46   * @systemapi
47   * @stagemodelonly
48   * @since 10
49   */
50  /**
51   * Send data from an ui extension to an ui extension component.
52   *
53   * @param { Record<string, Object> } data - Indicates the data send to ui extension component.
54   * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app.
55   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
56   * 2. Incorrect parameter types.
57   * @throws { BusinessError } 16000050 - Internal error.
58   * @syscap SystemCapability.Ability.AbilityRuntime.Core
59   * @systemapi
60   * @stagemodelonly
61   * @since 11
62   */
63  sendData(data: Record<string, Object>): void;
64
65  /**
66   * Sets the callback for the ui extension to receive data from an ui extension component.
67   *
68   * @param { function } callback - Indicates the receive data callback to set.
69   * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app.
70   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
71   * 2. Incorrect parameter types.
72   * @throws { BusinessError } 16000050 - Internal error.
73   * @syscap SystemCapability.Ability.AbilityRuntime.Core
74   * @systemapi
75   * @stagemodelonly
76   * @since 10
77   */
78  setReceiveDataCallback(callback: (data: Record<string, Object>) => void): void;
79
80  /**
81   * Sets the callback with return value for the ui extension to receive data from an ui extension component.
82   *
83   * @param { function } callback - Indicates the receive data callback to set.
84   * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app.
85   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
86   * 2. Incorrect parameter types.
87   * @throws { BusinessError } 16000050 - Internal error.
88   * @syscap SystemCapability.Ability.AbilityRuntime.Core
89   * @systemapi
90   * @stagemodelonly
91   * @since 11
92   */
93  setReceiveDataForResultCallback(callback: (data: Record<string, Object>) => Record<string, Object>): void;
94
95  /**
96   * Loads an UI extension content.
97   *
98   * @param { string } path - Path of the page to which the content will be loaded
99   * @param { LocalStorage } [storage] - The data object shared within the content instance loaded by the page
100   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
101   * 2. Incorrect parameter types.
102   * @throws { BusinessError } 16000050 - Internal error.
103   * @syscap SystemCapability.Ability.AbilityRuntime.Core
104   * @stagemodelonly
105   * @since 10
106   */
107  loadContent(path: string, storage?: LocalStorage): void;
108
109  /**
110   * Loads content by named router.
111   *
112   * @param { string } name - name of the page to which the content will be loaded.
113   * @param { LocalStorage } [storage] - The data object shared within the content instance loaded by the page.
114   * @throws { BusinessError } 16000050 - Internal error.
115   * @syscap SystemCapability.Ability.AbilityRuntime.Core
116   * @stagemodelonly
117   * @since 18
118   */
119  loadContentByName(name: string, storage?: LocalStorage): void;
120
121  /**
122   * UI extension uses this method to start a specific ability.If the caller application is in foreground,
123   * you can use this method to start ability; If the caller application is in the background,
124   * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
125   * If the target ability is visible, you can start the target ability; If the target ability is invisible,
126   * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
127   * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
128   *
129   * @param { Want } want - Indicates the ability to start.
130   * @param { AsyncCallback<void> } callback - The callback of startAbility.
131   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
132   * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app.
133   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
134   * 2. Incorrect parameter types.
135   * @throws { BusinessError } 16000001 - The specified ability does not exist.
136   * @throws { BusinessError } 16000002 - Incorrect ability type.
137   * @throws { BusinessError } 16000004 - Failed to start the invisible ability.
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 } 16000009 - An ability cannot be started or stopped in Wukong mode.
142   * @throws { BusinessError } 16000010 - The call with the continuation and prepare continuation flag is forbidden.
143   * @throws { BusinessError } 16000011 - The context does not exist.
144   * @throws { BusinessError } 16000012 - The application is controlled.
145   * @throws { BusinessError } 16000013 - The application is controlled by EDM.
146   * @throws { BusinessError } 16000050 - Internal error.
147   * @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
148   * @throws { BusinessError } 16000055 - Installation-free timed out.
149   * @throws { BusinessError } 16200001 - The caller has been released.
150   * @syscap SystemCapability.Ability.AbilityRuntime.Core
151   * @systemapi
152   * @stagemodelonly
153   * @since 10
154   */
155  startAbility(want: Want, callback: AsyncCallback<void>): void;
156
157  /**
158   * UI extension uses this method to start a specific ability.If the caller application is in foreground,
159   * you can use this method to start ability; If the caller application is in the background,
160   * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
161   * If the target ability is visible, you can start the target ability; If the target ability is invisible,
162   * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
163   * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
164   *
165   * @param { Want } want - Indicates the ability to start.
166   * @param { StartOptions } options - Indicates the start options.
167   * @param { AsyncCallback<void> } callback - The callback of startAbility.
168   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
169   * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app.
170   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
171   * 2. Incorrect parameter types.
172   * @throws { BusinessError } 16000001 - The specified ability does not exist.
173   * @throws { BusinessError } 16000004 - Failed to start the invisible ability.
174   * @throws { BusinessError } 16000005 - The specified process does not have the permission.
175   * @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
176   * @throws { BusinessError } 16000008 - The crowdtesting application expires.
177   * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
178   * @throws { BusinessError } 16000011 - The context does not exist.
179   * @throws { BusinessError } 16000012 - The application is controlled.
180   * @throws { BusinessError } 16000013 - The application is controlled by EDM.
181   * @throws { BusinessError } 16000050 - Internal error.
182   * @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
183   * @throws { BusinessError } 16000055 - Installation-free timed out.
184   * @throws { BusinessError } 16200001 - The caller has been released.
185   * @syscap SystemCapability.Ability.AbilityRuntime.Core
186   * @systemapi
187   * @stagemodelonly
188   * @since 10
189   */
190  startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void;
191
192  /**
193   * UI extension uses this method to start a specific ability.If the caller application is in foreground,
194   * you can use this method to start ability; If the caller application is in the background,
195   * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
196   * If the target ability is visible, you can start the target ability; If the target ability is invisible,
197   * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
198   * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
199   *
200   * @param { Want } want - Indicates the ability to start.
201   * @param { StartOptions } [options] - Indicates the start options.
202   * @returns { Promise<void> } The promise returned by the function.
203   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
204   * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app.
205   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
206   * 2. Incorrect parameter types.
207   * @throws { BusinessError } 16000001 - The specified ability does not exist.
208   * @throws { BusinessError } 16000002 - Incorrect ability type.
209   * @throws { BusinessError } 16000004 - Failed to start the invisible ability.
210   * @throws { BusinessError } 16000005 - The specified process does not have the permission.
211   * @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
212   * @throws { BusinessError } 16000008 - The crowdtesting application expires.
213   * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
214   * @throws { BusinessError } 16000010 - The call with the continuation and prepare continuation flag is forbidden.
215   * @throws { BusinessError } 16000011 - The context does not exist.
216   * @throws { BusinessError } 16000012 - The application is controlled.
217   * @throws { BusinessError } 16000013 - The application is controlled by EDM.
218   * @throws { BusinessError } 16000050 - Internal error.
219   * @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
220   * @throws { BusinessError } 16000055 - Installation-free timed out.
221   * @throws { BusinessError } 16200001 - The caller has been released.
222   * @syscap SystemCapability.Ability.AbilityRuntime.Core
223   * @systemapi
224   * @stagemodelonly
225   * @since 10
226   */
227  startAbility(want: Want, options?: StartOptions): Promise<void>;
228
229  /**
230   * Starts a new ability using the original caller information. If the caller application is in foreground,
231   * you can use this method to start ability; If the caller application is in the background,
232   * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
233   * If the target ability is visible, you can start the target ability; If the target ability is invisible,
234   * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
235   * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
236   *
237   * @param { Want } want - Indicates the ability to start.
238   * @param { AsyncCallback<void> } callback - The callback of startAbility.
239   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
240   * @throws { BusinessError } 202 - The application is not system-app, can not use system-api.
241   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
242   * 2. Incorrect parameter types.
243   * @throws { BusinessError } 16000001 - The specified ability does not exist.
244   * @throws { BusinessError } 16000002 - Incorrect ability type.
245   * @throws { BusinessError } 16000004 - Failed to start the invisible ability.
246   * @throws { BusinessError } 16000005 - The specified process does not have the permission.
247   * @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
248   * @throws { BusinessError } 16000008 - The crowdtesting application expires.
249   * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
250   * @throws { BusinessError } 16000010 - The call with the continuation and prepare continuation flag is forbidden.
251   * @throws { BusinessError } 16000011 - The context does not exist.
252   * @throws { BusinessError } 16000012 - The application is controlled.
253   * @throws { BusinessError } 16000013 - The application is controlled by EDM.
254   * @throws { BusinessError } 16000050 - Internal error.
255   * @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
256   * @throws { BusinessError } 16000055 - Installation-free timed out.
257   * @throws { BusinessError } 16200001 - The caller has been released.
258   * @syscap SystemCapability.Ability.AbilityRuntime.Core
259   * @systemapi
260   * @stagemodelonly
261   * @since 11
262   */
263  startAbilityAsCaller(want: Want, callback: AsyncCallback<void>): void;
264
265  /**
266   * Starts a new ability using the original caller information. If the caller application is in foreground,
267   * you can use this method to start ability; If the caller application is in the background,
268   * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
269   * If the target ability is visible, you can start the target ability; If the target ability is invisible,
270   * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
271   * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
272   *
273   * @param { Want } want - Indicates the ability to start.
274   * @param { StartOptions } options - Indicates the start options.
275   * @param { AsyncCallback<void> } callback - The callback of startAbility.
276   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
277   * @throws { BusinessError } 202 - The application is not system-app, can not use system-api.
278   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
279   * 2. Incorrect parameter types.
280   * @throws { BusinessError } 16000001 - The specified ability does not exist.
281   * @throws { BusinessError } 16000004 - Failed to start the invisible ability.
282   * @throws { BusinessError } 16000005 - The specified process does not have the permission.
283   * @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
284   * @throws { BusinessError } 16000008 - The crowdtesting application expires.
285   * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
286   * @throws { BusinessError } 16000011 - The context does not exist.
287   * @throws { BusinessError } 16000012 - The application is controlled.
288   * @throws { BusinessError } 16000013 - The application is controlled by EDM.
289   * @throws { BusinessError } 16000050 - Internal error.
290   * @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
291   * @throws { BusinessError } 16000055 - Installation-free timed out.
292   * @throws { BusinessError } 16200001 - The caller has been released.
293   * @syscap SystemCapability.Ability.AbilityRuntime.Core
294   * @systemapi
295   * @stagemodelonly
296   * @since 11
297   */
298  startAbilityAsCaller(want: Want, options: StartOptions, callback: AsyncCallback<void>): void;
299
300  /**
301   * Starts a new ability using the original caller information. If the caller application is in foreground,
302   * you can use this method to start ability; If the caller application is in the background,
303   * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
304   * If the target ability is visible, you can start the target ability; If the target ability is invisible,
305   * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
306   * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
307   *
308   * @param { Want } want - Indicates the ability to start.
309   * @param { StartOptions } [options] - Indicates the start options.
310   * @returns { Promise<void> } The promise returned by the function.
311   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
312   * @throws { BusinessError } 202 - The application is not system-app, can not use system-api.
313   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
314   * 2. Incorrect parameter types.
315   * @throws { BusinessError } 16000001 - The specified ability does not exist.
316   * @throws { BusinessError } 16000002 - Incorrect ability type.
317   * @throws { BusinessError } 16000004 - Failed to start the invisible ability.
318   * @throws { BusinessError } 16000005 - The specified process does not have the permission.
319   * @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
320   * @throws { BusinessError } 16000008 - The crowdtesting application expires.
321   * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
322   * @throws { BusinessError } 16000010 - The call with the continuation and prepare continuation flag is forbidden.
323   * @throws { BusinessError } 16000011 - The context does not exist.
324   * @throws { BusinessError } 16000012 - The application is controlled.
325   * @throws { BusinessError } 16000013 - The application is controlled by EDM.
326   * @throws { BusinessError } 16000050 - Internal error.
327   * @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
328   * @throws { BusinessError } 16000055 - Installation-free timed out.
329   * @throws { BusinessError } 16200001 - The caller has been released.
330   * @syscap SystemCapability.Ability.AbilityRuntime.Core
331   * @systemapi
332   * @stagemodelonly
333   * @since 11
334   */
335  startAbilityAsCaller(want: Want, options?: StartOptions): Promise<void>;
336
337  /**
338   * Starts an ability and returns the execution result when the ability is destroyed.
339   * If the caller application is in foreground, you can use this method to start ability; If the caller application
340   * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
341   * If the target ability is visible, you can start the target ability; If the target ability is invisible,
342   * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
343   * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
344   *
345   * @param { Want } want - Indicates the ability to start.
346   * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility.
347   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
348   * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app.
349   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
350   * 2. Incorrect parameter types.
351   * @throws { BusinessError } 16000001 - The specified ability does not exist.
352   * @throws { BusinessError } 16000002 - Incorrect ability type.
353   * @throws { BusinessError } 16000004 - Failed to start the invisible ability.
354   * @throws { BusinessError } 16000005 - The specified process does not have the permission.
355   * @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
356   * @throws { BusinessError } 16000008 - The crowdtesting application expires.
357   * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
358   * @throws { BusinessError } 16000010 - The call with the continuation and prepare continuation flag is forbidden.
359   * @throws { BusinessError } 16000011 - The context does not exist.
360   * @throws { BusinessError } 16000012 - The application is controlled.
361   * @throws { BusinessError } 16000013 - The application is controlled by EDM.
362   * @throws { BusinessError } 16000050 - Internal error.
363   * @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
364   * @throws { BusinessError } 16000055 - Installation-free timed out.
365   * @throws { BusinessError } 16200001 - The caller has been released.
366   * @syscap SystemCapability.Ability.AbilityRuntime.Core
367   * @systemapi
368   * @stagemodelonly
369   * @since 10
370   */
371  startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): void;
372
373  /**
374   * Starts an ability and returns the execution result when the ability is destroyed.
375   * If the caller application is in foreground, you can use this method to start ability; If the caller application
376   * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
377   * If the target ability is visible, you can start the target ability; If the target ability is invisible,
378   * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
379   * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
380   *
381   * @param { Want } want - Indicates the ability to start.
382   * @param { StartOptions } options - Indicates the start options.
383   * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility.
384   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
385   * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app.
386   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
387   * 2. Incorrect parameter types.
388   * @throws { BusinessError } 16000001 - The specified ability does not exist.
389   * @throws { BusinessError } 16000004 - Failed to start the invisible ability.
390   * @throws { BusinessError } 16000005 - The specified process does not have the permission.
391   * @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
392   * @throws { BusinessError } 16000008 - The crowdtesting application expires.
393   * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
394   * @throws { BusinessError } 16000011 - The context does not exist.
395   * @throws { BusinessError } 16000012 - The application is controlled.
396   * @throws { BusinessError } 16000013 - The application is controlled by EDM.
397   * @throws { BusinessError } 16000050 - Internal error.
398   * @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
399   * @throws { BusinessError } 16000055 - Installation-free timed out.
400   * @throws { BusinessError } 16200001 - The caller has been released.
401   * @syscap SystemCapability.Ability.AbilityRuntime.Core
402   * @systemapi
403   * @stagemodelonly
404   * @since 10
405   */
406  startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>): void;
407
408  /**
409   * Starts an ability and returns the execution result when the ability is destroyed.
410   * If the caller application is in foreground, you can use this method to start ability; If the caller application
411   * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
412   * If the target ability is visible, you can start the target ability; If the target ability is invisible,
413   * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
414   * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
415   *
416   * @param { Want } want - Indicates the ability to start.
417   * @param { StartOptions } [options] - Indicates the start options.
418   * @returns { Promise<AbilityResult> } Returns the result of startAbility.
419   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
420   * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app.
421   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
422   * 2. Incorrect parameter types.
423   * @throws { BusinessError } 16000001 - The specified ability does not exist.
424   * @throws { BusinessError } 16000002 - Incorrect ability type.
425   * @throws { BusinessError } 16000004 - Failed to start the invisible ability.
426   * @throws { BusinessError } 16000005 - The specified process does not have the permission.
427   * @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
428   * @throws { BusinessError } 16000008 - The crowdtesting application expires.
429   * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
430   * @throws { BusinessError } 16000010 - The call with the continuation and prepare continuation flag is forbidden.
431   * @throws { BusinessError } 16000011 - The context does not exist.
432   * @throws { BusinessError } 16000012 - The application is controlled.
433   * @throws { BusinessError } 16000013 - The application is controlled by EDM.
434   * @throws { BusinessError } 16000050 - Internal error.
435   * @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
436   * @throws { BusinessError } 16000055 - Installation-free timed out.
437   * @throws { BusinessError } 16200001 - The caller has been released.
438   * @syscap SystemCapability.Ability.AbilityRuntime.Core
439   * @systemapi
440   * @stagemodelonly
441   * @since 10
442   */
443  startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityResult>;
444
445  /**
446   * Destroys the UI extension.
447   *
448   * @param { AsyncCallback<void> } callback - The callback of terminateSelf.
449   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
450   * 2. Incorrect parameter types.
451   * @syscap SystemCapability.Ability.AbilityRuntime.Core
452   * @stagemodelonly
453   * @since 10
454   */
455  terminateSelf(callback: AsyncCallback<void>): void;
456
457  /**
458   * Destroys the UI extension.
459   *
460   * @returns { Promise<void> } The promise returned by the function.
461   * @syscap SystemCapability.Ability.AbilityRuntime.Core
462   * @stagemodelonly
463   * @since 10
464   */
465  terminateSelf(): Promise<void>;
466
467  /**
468   * Destroys the UI extension while returning the specified result code and data to the caller.
469   *
470   * @param { AbilityResult } parameter - Indicates the result to return.
471   * @param { AsyncCallback<void> } callback - The callback of terminateSelfWithResult.
472   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
473   * 2. Incorrect parameter types.
474   * @syscap SystemCapability.Ability.AbilityRuntime.Core
475   * @stagemodelonly
476   * @since 10
477   */
478  terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>): void;
479
480  /**
481   * Destroys the UI extension while returning the specified result code and data to the caller.
482   *
483   * @param { AbilityResult } parameter - Indicates the result to return.
484   * @returns { Promise<void> } The promise returned by the function.
485   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
486   * 2. Incorrect parameter types.
487   * @syscap SystemCapability.Ability.AbilityRuntime.Core
488   * @stagemodelonly
489   * @since 10
490   */
491  terminateSelfWithResult(parameter: AbilityResult): Promise<void>;
492
493  /**
494   * Sets the background color of the UI extension.
495   *
496   * @param { string } color - the specified color.
497   * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app.
498   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
499   * 2. Incorrect parameter types.
500   * @throws { BusinessError } 16000050 - Internal error.
501   * @syscap SystemCapability.Ability.AbilityRuntime.Core
502   * @systemapi
503   * @stagemodelonly
504   * @since 10
505   */
506  setWindowBackgroundColor(color: string): void;
507
508  /**
509   * Sets whether this window is in privacy mode.
510   *
511   * @permission ohos.permission.PRIVACY_WINDOW
512   * @param { boolean } isPrivacyMode - Whether the window is in privacy mode. The value true means that
513   *                                    the window is in privacy mode, and false means the opposite.
514   * @returns { Promise<void> } Promise that returns no value.
515   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
516   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
517   * 2. Incorrect parameter types.
518   * @syscap SystemCapability.Ability.AbilityRuntime.Core
519   * @stagemodelonly
520   * @since 10
521   */
522  setWindowPrivacyMode(isPrivacyMode: boolean): Promise<void>;
523
524  /**
525   * Sets whether this window is in privacy mode.
526   *
527   * @permission ohos.permission.PRIVACY_WINDOW
528   * @param { boolean } isPrivacyMode - Whether the window is in privacy mode. The value true means that
529   *                                    the window is in privacy mode, and false means the opposite.
530   * @param { AsyncCallback<void> } callback - Callback used to return the result.
531   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
532   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
533   * 2. Incorrect parameter types.
534   * @syscap SystemCapability.Ability.AbilityRuntime.Core
535   * @stagemodelonly
536   * @since 10
537   */
538  setWindowPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void;
539
540  /**
541   * Starts the UIAbility or UIExtensionAbility by type.
542   * If the target ability is visible, you can start the target ability; If the target ability is invisible,
543   * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
544   *
545   * @param { string } type - The type of target ability.
546   * @param { Record<string, Object> } wantParam - Indicates the want parameter.
547   * @param { AbilityStartCallback } abilityStartCallback - Indicates the abilityStartCallback.
548   * @param { AsyncCallback<void> } callback - The callback of startAbility.
549   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
550   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
551   * 2. Incorrect parameter types.
552   * @throws { BusinessError } 16000001 - The specified ability does not exist.
553   * @throws { BusinessError } 16000002 - Incorrect ability type.
554   * @throws { BusinessError } 16000004 - Can not start invisible component.
555   * @throws { BusinessError } 16000050 - Internal error.
556   * @throws { BusinessError } 16200001 - The caller has been released.
557   * @syscap SystemCapability.Ability.AbilityRuntime.Core
558   * @stagemodelonly
559   * @since 11
560   */
561  /**
562   * Starts the UIAbility or UIExtensionAbility by type.
563   * If the caller application is in the background, it is not allowed to call this interface.
564   *
565   * @param { string } type - The type of target ability.
566   * @param { Record<string, Object> } wantParam - Indicates the want parameter.
567   * @param { AbilityStartCallback } abilityStartCallback - Indicates the abilityStartCallback.
568   * @param { AsyncCallback<void> } callback - The callback of startAbility.
569   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
570   * <br>2. Incorrect parameter types.
571   * @throws { BusinessError } 16000050 - Internal error.
572   * @syscap SystemCapability.Ability.AbilityRuntime.Core
573   * @stagemodelonly
574   * @since 12
575   */
576  startAbilityByType(type: string, wantParam: Record<string, Object>,
577    abilityStartCallback: AbilityStartCallback, callback: AsyncCallback<void>): void;
578
579  /**
580   * Starts the UIAbility or UIExtensionAbility by type.
581   * If the target ability is visible, you can start the target ability; If the target ability is invisible,
582   * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
583   *
584   * @param { string } type - The type of target ability.
585   * @param { Record<string, Object> } wantParam - Indicates the want parameter.
586   * @param { AbilityStartCallback } abilityStartCallback - Indicates the abilityStartCallback.
587   * @returns { Promise<void> } The promise returned by the function.
588   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
589   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
590   * 2. Incorrect parameter types.
591   * @throws { BusinessError } 16000001 - The specified ability does not exist.
592   * @throws { BusinessError } 16000002 - Incorrect ability type.
593   * @throws { BusinessError } 16000004 - Can not start invisible component.
594   * @throws { BusinessError } 16000050 - Internal error.
595   * @throws { BusinessError } 16200001 - The caller has been released.
596   * @syscap SystemCapability.Ability.AbilityRuntime.Core
597   * @stagemodelonly
598   * @since 11
599   */
600  /**
601   * Starts the UIAbility or UIExtensionAbility by type.
602   * If the caller application is in the background, it is not allowed to call this interface.
603   *
604   * @param { string } type - The type of target ability.
605   * @param { Record<string, Object> } wantParam - Indicates the want parameter.
606   * @param { AbilityStartCallback } abilityStartCallback - Indicates the abilityStartCallback.
607   * @returns { Promise<void> } The promise returned by the function.
608   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
609   * <br>2. Incorrect parameter types.
610   * @throws { BusinessError } 16000050 - Internal error.
611   * @syscap SystemCapability.Ability.AbilityRuntime.Core
612   * @stagemodelonly
613   * @since 12
614   */
615  startAbilityByType(type: string, wantParam: Record<string, Object>,
616    abilityStartCallback: AbilityStartCallback): Promise<void>;
617
618  /**
619   * Get the UIExtension Host Window proxy.
620   *
621   * @returns { uiExtensionHost.UIExtensionHostWindowProxy } Returns the UIExtension Host Window proxy.
622   * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app.
623   * @throws { BusinessError } 16000050 - Internal error.
624   * @syscap SystemCapability.Ability.AbilityRuntime.Core
625   * @systemapi
626   * @stagemodelonly
627   * @since 11
628   */
629  getUIExtensionHostWindowProxy(): uiExtensionHost.UIExtensionHostWindowProxy;
630
631  /**
632   * Get the UIExtension Window proxy.
633   *
634   * @returns { uiExtension.WindowProxy } Returns the UIExtension Window proxy.
635   * @throws { BusinessError } 16000050 - Internal error.
636   * @syscap SystemCapability.Ability.AbilityRuntime.Core
637   * @stagemodelonly
638   * @since 12
639   */
640  getUIExtensionWindowProxy(): uiExtension.WindowProxy;
641}
642