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