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