• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-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 { AsyncCallback, Callback } from './@ohos.base';
22import Want from './@ohos.app.ability.Want';
23import { WantAgentInfo as _WantAgentInfo } from './wantAgent/wantAgentInfo';
24import { TriggerInfo as _TriggerInfo } from './wantAgent/triggerInfo';
25import Context from './application/Context';
26/*** if arkts 1.1 */
27import { LocalWantAgentInfo as _LocalWantAgentInfo } from './wantAgent/wantAgentInfo';
28/*** endif */
29
30/**
31 * Provide the method obtain trigger, cancel, and compare and to obtain
32 * the bundle name, UID of an WantAgent object.
33 *
34 * @namespace wantAgent
35 * @syscap SystemCapability.Ability.AbilityRuntime.Core
36 * @since 9
37 */
38/**
39 * app.ability.WantAgent is a class that encapsulates a {@link Want} object and allows the application to execute the
40 * Want at a future time point. The module provides APIs for creating and comparing WantAgent objects, and obtaining
41 * the user ID and bundle name of a WantAgent object.
42 *
43 * A typical use scenario of WantAgent is notification processing. For example, when a user touches a notification,
44 * the {@link trigger} API of WantAgent is triggered and the target application is started. For details, see
45 * {@link Notification}. You are advised to use this module, since it will replace the @ohos.wantAgent module
46 * in the near future.
47 *
48 * @namespace wantAgent
49 * @syscap SystemCapability.Ability.AbilityRuntime.Core
50 * @atomicservice
51 * @since arkts {'1.1':'12', '1.2':'20'}
52 * @arkts 1.1&1.2
53 */
54declare namespace wantAgent {
55  /**
56   * Obtains the bundle name of a WantAgent.
57   *
58   * @param { WantAgent } agent - Indicates the WantAgent.
59   * @param { AsyncCallback<string> } callback - The callback is used to return the bundle name.
60   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
61   * 2. Incorrect parameter types.
62   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
63   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
64   * @syscap SystemCapability.Ability.AbilityRuntime.Core
65   * @since 9
66   */
67  /**
68   * Obtains the bundle name of a WantAgent object.
69   * This API uses an asynchronous callback to return the result.
70   *
71   * @param { WantAgent } agent - Target WantAgent object.
72   * @param { AsyncCallback<string> } callback - Callback used to return the bundle name.
73   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
74   * 2. Incorrect parameter types.
75   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
76   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
77   * @syscap SystemCapability.Ability.AbilityRuntime.Core
78   * @atomicservice
79   * @since arkts {'1.1':'12', '1.2':'20'}
80   * @arkts 1.1&1.2
81   */
82  function getBundleName(agent: WantAgent, callback: AsyncCallback<string>): void;
83
84  /**
85   * Obtains the bundle name of a WantAgent.
86   *
87   * @param { WantAgent } agent - Indicates the WantAgent.
88   * @returns { Promise<string> } Returns the bundle name.
89   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
90   * 2. Incorrect parameter types.
91   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
92   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
93   * @syscap SystemCapability.Ability.AbilityRuntime.Core
94   * @since 9
95   */
96  /**
97   * Obtains the bundle name of a WantAgent object.
98   * This API uses a promise to return the result.
99   *
100   * @param { WantAgent } agent - Target WantAgent object.
101   * @returns { Promise<string> } Promise used to return the bundle name.
102   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
103   * 2. Incorrect parameter types.
104   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
105   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
106   * @syscap SystemCapability.Ability.AbilityRuntime.Core
107   * @atomicservice
108   * @since arkts {'1.1':'12', '1.2':'20'}
109   * @arkts 1.1&1.2
110   */
111  function getBundleName(agent: WantAgent): Promise<string>;
112
113  /**
114   * Obtains the UID of a WantAgent.
115   *
116   * @param { WantAgent } agent - Indicates the WantAgent.
117   * @param { AsyncCallback<number> } callback - The callback is used to return the UID.
118   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
119   * 2. Incorrect parameter types.
120   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
121   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
122   * @syscap SystemCapability.Ability.AbilityRuntime.Core
123   * @since 9
124   */
125  /**
126   * Obtains the user ID of a WantAgent object.
127   * This API uses an asynchronous callback to return the result.
128   *
129   * @param { WantAgent } agent - Target WantAgent object.
130   * @param { AsyncCallback<number> } callback - Callback used to return the user ID.
131   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
132   * 2. Incorrect parameter types.
133   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
134   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
135   * @syscap SystemCapability.Ability.AbilityRuntime.Core
136   * @atomicservice
137   * @since 12
138   */
139  function getUid(agent: WantAgent, callback: AsyncCallback<number>): void;
140
141  /**
142   * Obtains the UID of a WantAgent.
143   *
144   * @param { WantAgent } agent - Indicates the WantAgent.
145   * @returns { Promise<number> } Returns the UID.
146   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
147   * 2. Incorrect parameter types.
148   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
149   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
150   * @syscap SystemCapability.Ability.AbilityRuntime.Core
151   * @since 9
152   */
153  /**
154   * Obtains the user ID of a WantAgent object.
155   * This API uses a promise to return the result.
156   *
157   * @param { WantAgent } agent - Target WantAgent object.
158   * @returns { Promise<number> } Promise used to return the user ID.
159   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
160   * 2. Incorrect parameter types.
161   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
162   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
163   * @syscap SystemCapability.Ability.AbilityRuntime.Core
164   * @atomicservice
165   * @since 12
166   */
167  function getUid(agent: WantAgent): Promise<number>;
168
169  /**
170   * Obtains the Want in a WantAgent object.
171   * This API uses an asynchronous callback to return the result.
172   *
173   * @param { WantAgent } agent - Target WantAgent object.
174   * @param { AsyncCallback<Want> } callback - Callback used to return the Want.
175   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
176   * 2. Incorrect parameter types.
177   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
178   * @throws { BusinessError } 16000015 - Service timeout.
179   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
180   * @syscap SystemCapability.Ability.AbilityRuntime.Core
181   * @systemapi
182   * @since arkts {'1.1':'9', '1.2':'20'}
183   * @arkts 1.1&1.2
184   */
185  function getWant(agent: WantAgent, callback: AsyncCallback<Want>): void;
186
187  /**
188   * Obtains the Want in a WantAgent object.
189   * This API uses a promise to return the result.
190   *
191   * @param { WantAgent } agent - Target WantAgent object.
192   * @returns { Promise<Want> } Promise used to return the Want.
193   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
194   * 2. Incorrect parameter types.
195   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
196   * @throws { BusinessError } 16000015 - Service timeout.
197   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
198   * @syscap SystemCapability.Ability.AbilityRuntime.Core
199   * @systemapi
200   * @since arkts {'1.1':'9', '1.2':'20'}
201   * @arkts 1.1&1.2
202   */
203  function getWant(agent: WantAgent): Promise<Want>;
204
205  /**
206   * Cancel a WantAgent. Only the application that creates the WantAgent can cancel it.
207   *
208   * @param { WantAgent } agent - Indicates the WantAgent.
209   * @param { AsyncCallback<void> } callback - The callback of cancel.
210   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
211   * 2. Incorrect parameter types.
212   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
213   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
214   * @syscap SystemCapability.Ability.AbilityRuntime.Core
215   * @since 9
216   */
217  /**
218   * Cancels a WantAgent object.
219   * This API uses an asynchronous callback to return the result.
220   *
221   * @param { WantAgent } agent - Target WantAgent object.
222   * @param { AsyncCallback<void> } callback - Callback used to return the result.
223   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
224   * 2. Incorrect parameter types.
225   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
226   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
227   * @syscap SystemCapability.Ability.AbilityRuntime.Core
228   * @atomicservice
229   * @since arkts {'1.1':'12', '1.2':'20'}
230   * @arkts 1.1&1.2
231   */
232  function cancel(agent: WantAgent, callback: AsyncCallback<void>): void;
233
234  /**
235   * Cancel a WantAgent. Only the application that creates the WantAgent can cancel it.
236   *
237   * @param { WantAgent } agent - Indicates the WantAgent.
238   * @returns { Promise<void> } The promise returned by the function.
239   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
240   * 2. Incorrect parameter types.
241   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
242   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
243   * @syscap SystemCapability.Ability.AbilityRuntime.Core
244   * @since 9
245   */
246  /**
247   * Cancels a WantAgent object.
248   * This API uses a promise to return the result.
249   *
250   * @param { WantAgent } agent - Target WantAgent object.
251   * @returns { Promise<void> } Promise used to return the result.
252   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
253   * 2. Incorrect parameter types.
254   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
255   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
256   * @syscap SystemCapability.Ability.AbilityRuntime.Core
257   * @atomicservice
258   * @since arkts {'1.1':'12', '1.2':'20'}
259   * @arkts 1.1&1.2
260   */
261  function cancel(agent: WantAgent): Promise<void>;
262
263  /**
264   * Triggers a WantAgent.
265   *
266   * @param { WantAgent } agent - Indicates the WantAgent.
267   * @param { TriggerInfo } triggerInfo - Indicates the information required for triggering a WantAgent.
268   * @param { AsyncCallback<CompleteData> } [callback] - The callback is used to return the CompleteData.
269   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
270   * 2. Incorrect parameter types.
271   * @syscap SystemCapability.Ability.AbilityRuntime.Core
272   * @since 9
273   */
274  /**
275   * Proactively triggers a WantAgent object.
276   * This API uses an asynchronous callback to return the result.
277   *
278   * @param { WantAgent } agent - Target WantAgent object.
279   * @param { TriggerInfo } triggerInfo - {@link TriggerInfo} object.
280   * @param { AsyncCallback<CompleteData> } [callback] - Callback used to return the result.
281   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
282   * 2. Incorrect parameter types.
283   * @syscap SystemCapability.Ability.AbilityRuntime.Core
284   * @atomicservice
285   * @since arkts {'1.1':'12', '1.2':'20'}
286   * @arkts 1.1&1.2
287   */
288  function trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback<CompleteData>): void;
289
290  /**
291   * Asynchronously triggers a predefined operation encration encapsulated in a Wantagent with specified trigger information.
292   * If the specified wantAgent is local, you need to apply for permission:
293   * ohos.permission.TRIGGER_LOCAL_WANTAGENT permission.
294   *
295   * @param { WantAgent } agent - Indicates the WantAgent.
296   * @param { TriggerInfo } triggerInfo - Indicates the information required for triggering a WantAgent.
297   * @param { Context } context - Indicates current context.
298   * @returns { Promise<CompleteData> } Returns the CompleteData.
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 } 16000020 - The context is not ability context.
302   * @throws { BusinessError } 16000151 - Invalid wantagent object.
303   * @throws { BusinessError } 16000153 - The Wantagent has been canceled.
304   * @syscap SystemCapability.Ability.AbilityRuntime.Core
305   * @systemapi
306   * @stagemodelonly
307   * @since 20
308   * @arkts 1.1&1.2
309   */
310  function triggerAsync(agent: WantAgent, triggerInfo: TriggerInfo, context: Context): Promise<CompleteData>;
311
312  /**
313   * Checks whether two WantAgent objects are equal.
314   *
315   * @param { WantAgent } agent - Indicates the WantAgent.
316   * @param { WantAgent } otherAgent - Indicates the other WantAgent.
317   * @param { AsyncCallback<boolean> } callback - Returns true if the two WantAgents are the same.
318   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
319   * 2. Incorrect parameter types.
320   * @syscap SystemCapability.Ability.AbilityRuntime.Core
321   * @since 9
322   */
323  /**
324   * Checks whether two WantAgent objects are equal, so as to determine whether the same operation is from the
325   * same application.
326   * This API uses an asynchronous callback to return the result.
327   *
328   * @param { WantAgent } agent - The first WantAgent object.
329   * @param { WantAgent } otherAgent - The second WantAgent object.
330   * @param { AsyncCallback<boolean> } callback - Callback used to return the result. The value <code>true</code> means
331   * that the two WantAgent objects are equal, and <code>false</code> means the opposite.
332   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
333   * 2. Incorrect parameter types.
334   * @syscap SystemCapability.Ability.AbilityRuntime.Core
335   * @atomicservice
336   * @since arkts {'1.1':'12', '1.2':'20'}
337   * @arkts 1.1&1.2
338   */
339  function equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback<boolean>): void;
340
341  /**
342   * Checks whether two WantAgent objects are equal.
343   *
344   * @param { WantAgent } agent - Indicates the WantAgent.
345   * @param { WantAgent } otherAgent - Indicates the other WantAgent.
346   * @returns { Promise<boolean> } Returns true if the two WantAgents are the same.
347   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
348   * 2. Incorrect parameter types.
349   * @syscap SystemCapability.Ability.AbilityRuntime.Core
350   * @since 9
351   */
352  /**
353   * Checks whether two WantAgent objects are equal, so as to determine whether the same operation is from the
354   * same application.
355   * This API uses a promise to return the result.
356   *
357   * @param { WantAgent } agent - The first WantAgent object.
358   * @param { WantAgent } otherAgent - The second WantAgent object.
359   * @returns { Promise<boolean> } Promise used to return the result. The value <code>true</code> means that the two
360   * WantAgent objects are equal, and <code>false</code> means the opposite.
361   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
362   * 2. Incorrect parameter types.
363   * @syscap SystemCapability.Ability.AbilityRuntime.Core
364   * @atomicservice
365   * @since arkts {'1.1':'12', '1.2':'20'}
366   * @arkts 1.1&1.2
367   */
368  function equal(agent: WantAgent, otherAgent: WantAgent): Promise<boolean>;
369
370  /**
371   * Obtains a WantAgent object.
372   *
373   * @param { WantAgentInfo } info - Information about the WantAgent object to obtain.
374   * @param { AsyncCallback<WantAgent> } callback - The callback is used to return the created WantAgent.
375   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
376   * 2. Incorrect parameter types.
377   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
378   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
379   * @syscap SystemCapability.Ability.AbilityRuntime.Core
380   * @since 9
381   */
382  /**
383   * Obtains a WantAgent object.
384   * This API uses an asynchronous callback to return the result.
385   * If the creation fails, a null WantAgent object is returned.
386   *
387   * <p>**NOTE**:
388   * <br>Third-party applications can set only their own abilities.
389   * </p>
390   *
391   * @param { WantAgentInfo } info - Information about the WantAgent object to obtain.
392   * @param { AsyncCallback<WantAgent> } callback - Callback used to return the WantAgent object.
393   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
394   * 2. Incorrect parameter types.
395   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
396   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
397   * @syscap SystemCapability.Ability.AbilityRuntime.Core
398   * @atomicservice
399   * @since arkts {'1.1':'12', '1.2':'20'}
400   * @arkts 1.1&1.2
401   */
402  function getWantAgent(info: WantAgentInfo, callback: AsyncCallback<WantAgent>): void;
403
404  /**
405   * Obtains a WantAgent object.
406   *
407   * @param { WantAgentInfo } info - Information about the WantAgent object to obtain.
408   * @returns { Promise<WantAgent> } Returns the created WantAgent.
409   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
410   * 2. Incorrect parameter types.
411   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
412   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
413   * @syscap SystemCapability.Ability.AbilityRuntime.Core
414   * @since 9
415   */
416  /**
417   * Obtains a WantAgent object.
418   * This API uses a promise to return the result.
419   * If the creation fails, a null WantAgent object is returned.
420   *
421   * <p>**NOTE**:
422   * <br>Third-party applications can set only their own abilities.
423   * </p>
424   *
425   * @param { WantAgentInfo } info - Information about the WantAgent object to obtain.
426   * @returns { Promise<WantAgent> } Promise used to return the WantAgent object.
427   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
428   * 2. Incorrect parameter types.
429   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
430   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
431   * @syscap SystemCapability.Ability.AbilityRuntime.Core
432   * @atomicservice
433   * @since arkts {'1.1':'12', '1.2':'20'}
434   * @arkts 1.1&1.2
435   */
436  function getWantAgent(info: WantAgentInfo): Promise<WantAgent>;
437
438  /**
439   * Obtains the {@link OperationType} of a WantAgent.
440   *
441   * @param { WantAgent } agent - Indicates the WantAgent.
442   * @param { AsyncCallback<number> } callback - The callback is used to return the OperationType of the WantAgent.
443   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
444   * 2. Incorrect parameter types.
445   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
446   * @throws { BusinessError } 16000015 - Service timeout.
447   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
448   * @syscap SystemCapability.Ability.AbilityRuntime.Core
449   * @since 9
450   */
451  /**
452   * Obtains the operation type of a WantAgent object.
453   * This API uses an asynchronous callback to return the result.
454   *
455   * @param { WantAgent } agent - Target WantAgent object.
456   * @param { AsyncCallback<number> } callback - Callback used to return the operation type.
457   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
458   * 2. Incorrect parameter types.
459   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
460   * @throws { BusinessError } 16000015 - Service timeout.
461   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
462   * @syscap SystemCapability.Ability.AbilityRuntime.Core
463   * @atomicservice
464   * @since arkts {'1.1':'12', '1.2':'20'}
465   * @arkts 1.1&1.2
466   */
467  function getOperationType(agent: WantAgent, callback: AsyncCallback<number>): void;
468
469  /**
470   * Obtains the {@link OperationType} of a WantAgent.
471   *
472   * @param { WantAgent } agent - Indicates the WantAgent.
473   * @returns { Promise<number> } Returns the OperationType of the WantAgent.
474   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
475   * 2. Incorrect parameter types.
476   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
477   * @throws { BusinessError } 16000015 - Service timeout.
478   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
479   * @syscap SystemCapability.Ability.AbilityRuntime.Core
480   * @since 9
481   */
482  /**
483   * Obtains the operation type of a WantAgent object.
484   * This API uses a promise to return the result.
485   *
486   * @param { WantAgent } agent - Indicates the WantAgent.
487   * @returns { Promise<number> } Returns the OperationType of the WantAgent.
488   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
489   * 2. Incorrect parameter types.
490   * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later.
491   * @throws { BusinessError } 16000015 - Service timeout.
492   * @throws { BusinessError } 16000151 - Invalid wantAgent object.
493   * @syscap SystemCapability.Ability.AbilityRuntime.Core
494   * @atomicservice
495   * @since arkts {'1.1':'12', '1.2':'20'}
496   * @arkts 1.1&1.2
497   */
498  function getOperationType(agent: WantAgent): Promise<number>;
499
500  /**
501   * Enables or disables the WantAgent multithreading feature.
502   *
503   * @param { boolean } isMultithreadingSupported - Whether to enable the multithreading feature. The value
504   * <code>true</code> means to enable multithreading, and <code>false</code> means the opposite.
505   * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app.
506   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
507   * 2. Incorrect parameter types.
508   * @syscap SystemCapability.Ability.AbilityRuntime.Core
509   * @systemapi
510   * @stagemodelonly
511   * @since 18
512   */
513  function setWantAgentMultithreading(isMultithreadingSupported: boolean) : void;
514
515  /**
516   * Create a local WantAgent object.
517   * The WantAgent created by this interface stores data on the client side
518   * and is not managed by the WantAgent servcer.
519   * If this WantAgent object is passed across processes,
520   * its contained data will be serialized and transmitted to the target process.
521   *
522   * @param { LocalWantAgentInfo } info - Information about the local WantAgent object to create.
523   * @returns { WantAgent } Returns the created WantAgent.
524   * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app.
525   * @syscap SystemCapability.Ability.AbilityRuntime.Core
526   * @systemapi
527   * @stagemodelonly
528   * @since 20
529   */
530  function createLocalWantAgent(info: LocalWantAgentInfo): WantAgent;
531
532  /**
533   * Checks whether the specified WantAgent is local.
534   *
535   * @param { WantAgent } agent - Indicates the WantAgent.
536   * @returns { boolean } Returns true if the WantAgent is local.
537   * @throws { BusinessError } 202 - Not System app. Interface caller is not a system app.
538   * @syscap SystemCapability.Ability.AbilityRuntime.Core
539   * @systemapi
540   * @stagemodelonly
541   * @since 20
542   * @arkts 1.1&1.2
543   */
544  function isLocalWantAgent(agent: WantAgent): boolean;
545
546  /**
547   * Enumerates flags for using a WantAgent.
548   *
549   * @enum { number }
550   * @syscap SystemCapability.Ability.AbilityRuntime.Core
551   * @since 9
552   */
553  /**
554   * Enumerates the flags used by the WantAgent objects.
555   *
556   * @enum { number }
557   * @syscap SystemCapability.Ability.AbilityRuntime.Core
558   * @atomicservice
559   * @since arkts {'1.1':'12', '1.2':'20'}
560   * @arkts 1.1&1.2
561   */
562  export enum WantAgentFlags {
563    /**
564     * Indicates that the WantAgent can be used only once.
565     * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT.
566     *
567     * @syscap SystemCapability.Ability.AbilityRuntime.Core
568     * @since 9
569     */
570    /**
571     * The WantAgent object can be used only once.
572     *
573     * @syscap SystemCapability.Ability.AbilityRuntime.Core
574     * @atomicservice
575     * @since arkts {'1.1':'12', '1.2':'20'}
576     * @arkts 1.1&1.2
577     */
578    ONE_TIME_FLAG = 0,
579
580    /**
581     * Indicates that null is returned if the WantAgent does not exist.
582     * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT.
583     *
584     * @syscap SystemCapability.Ability.AbilityRuntime.Core
585     * @since 9
586     */
587    /**
588     * The WantAgent object does not exist and hence it is not created. In this case, <code>null</code> is returned.
589     *
590     * @syscap SystemCapability.Ability.AbilityRuntime.Core
591     * @atomicservice
592     * @since arkts {'1.1':'12', '1.2':'20'}
593     * @arkts 1.1&1.2
594     */
595    NO_BUILD_FLAG,
596
597    /**
598     * Indicates that the existing WantAgent should be canceled before a new object is generated.
599     * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT.
600     *
601     * @syscap SystemCapability.Ability.AbilityRuntime.Core
602     * @since 9
603     */
604    /**
605     * The existing WantAgent object should be canceled before a new object is generated.
606     *
607     * @syscap SystemCapability.Ability.AbilityRuntime.Core
608     * @atomicservice
609     * @since arkts {'1.1':'12', '1.2':'20'}
610     * @arkts 1.1&1.2
611     */
612    CANCEL_PRESENT_FLAG,
613
614    /**
615     * Indicates that the system only replaces the extra data of the existing WantAgent with that of the new object.
616     * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT.
617     *
618     * @syscap SystemCapability.Ability.AbilityRuntime.Core
619     * @since 9
620     */
621    /**
622     * Extra information of the existing WantAgent object is replaced with that of the new object.
623     *
624     * @syscap SystemCapability.Ability.AbilityRuntime.Core
625     * @atomicservice
626     * @since arkts {'1.1':'12', '1.2':'20'}
627     * @arkts 1.1&1.2
628     */
629    UPDATE_PRESENT_FLAG,
630
631    /**
632     * Indicates that the created WantAgent should be immutable.
633     *
634     * @syscap SystemCapability.Ability.AbilityRuntime.Core
635     * @since 9
636     */
637    /**
638     * The WantAgent object is immutable.
639     *
640     * @syscap SystemCapability.Ability.AbilityRuntime.Core
641     * @atomicservice
642     * @since arkts {'1.1':'12', '1.2':'20'}
643     * @arkts 1.1&1.2
644     */
645    CONSTANT_FLAG,
646
647    /**
648     * Indicates that the current value of element can be replaced when the WantAgent is triggered.
649     *
650     * @syscap SystemCapability.Ability.AbilityRuntime.Core
651     * @since 9
652     */
653    /**
654     * The element property in the current Want can be replaced by the element property in the Want passed in
655     * WantAgent.trigger().
656     *
657     * <p>**NOTE**:
658     * <br>This processing is not supported yet.
659     * </p>
660     *
661     * @syscap SystemCapability.Ability.AbilityRuntime.Core
662     * @atomicservice
663     * @since arkts {'1.1':'12', '1.2':'20'}
664     * @arkts 1.1&1.2
665     */
666    REPLACE_ELEMENT,
667
668    /**
669     * Indicates that the current value of action can be replaced when the WantAgent is triggered.
670     *
671     * @syscap SystemCapability.Ability.AbilityRuntime.Core
672     * @since 9
673     */
674    /**
675     * The action property in the current Want can be replaced by the action property in the Want passed in
676     * WantAgent.trigger().
677     *
678     * <p>**NOTE**:
679     * <br>This processing is not supported yet.
680     * </p>
681     *
682     * @syscap SystemCapability.Ability.AbilityRuntime.Core
683     * @atomicservice
684     * @since arkts {'1.1':'12', '1.2':'20'}
685     * @arkts 1.1&1.2
686     */
687    REPLACE_ACTION,
688
689    /**
690     * Indicates that the current value of uri can be replaced when the WantAgent is triggered.
691     *
692     * @syscap SystemCapability.Ability.AbilityRuntime.Core
693     * @since 9
694     */
695    /**
696     * The uri property in the current Want can be replaced by the uri property in the Want passed in
697     * WantAgent.trigger().
698     *
699     * <p>**NOTE**:
700     * <br>This processing is not supported yet.
701     * </p>
702     *
703     * @syscap SystemCapability.Ability.AbilityRuntime.Core
704     * @atomicservice
705     * @since arkts {'1.1':'12', '1.2':'20'}
706     * @arkts 1.1&1.2
707     */
708    REPLACE_URI,
709
710    /**
711     * Indicates that the current value of entities can be replaced when the WantAgent is triggered.
712     *
713     * @syscap SystemCapability.Ability.AbilityRuntime.Core
714     * @since 9
715     */
716    /**
717     * The <code>entities</code> property in the current Want can be replaced by the <code>entities</code> property in
718     * the Want passed in WantAgent.trigger().
719     *
720     * <p>**NOTE**:
721     * <br>This processing is not supported yet.
722     * </p>
723     *
724     * @syscap SystemCapability.Ability.AbilityRuntime.Core
725     * @atomicservice
726     * @since arkts {'1.1':'12', '1.2':'20'}
727     * @arkts 1.1&1.2
728     */
729    REPLACE_ENTITIES,
730
731    /**
732     * Indicates that the current value of packageName can be replaced when the WantAgent is triggered.
733     *
734     * @syscap SystemCapability.Ability.AbilityRuntime.Core
735     * @since 9
736     */
737    /**
738     * The <code>bundleName</code> property in the current Want can be replaced by the <code>bundleName</code> property
739     * in the Want passed in WantAgent.trigger().
740     *
741     * <p>**NOTE**:
742     * <br>This processing is not supported yet.
743     * </p>
744     *
745     * @syscap SystemCapability.Ability.AbilityRuntime.Core
746     * @atomicservice
747     * @since arkts {'1.1':'12', '1.2':'20'}
748     * @arkts 1.1&1.2
749     */
750    REPLACE_BUNDLE
751  }
752
753  /**
754   * Identifies the operation for using a WantAgent, such as starting an ability or sending a common event.
755   *
756   * @enum { number }
757   * @syscap SystemCapability.Ability.AbilityRuntime.Core
758   * @since 9
759   */
760  /**
761   * Enumerates the operation types of the WantAgent objects.
762   *
763   * @enum { number }
764   * @syscap SystemCapability.Ability.AbilityRuntime.Core
765   * @atomicservice
766   * @since arkts {'1.1':'12', '1.2':'20'}
767   * @arkts 1.1&1.2
768   */
769  export enum OperationType {
770    /**
771     * Unknown operation.
772     *
773     * @syscap SystemCapability.Ability.AbilityRuntime.Core
774     * @since 9
775     */
776    /**
777     * Unknown operation type.
778     *
779     * @syscap SystemCapability.Ability.AbilityRuntime.Core
780     * @atomicservice
781     * @since arkts {'1.1':'12', '1.2':'20'}
782     * @arkts 1.1&1.2
783     */
784    UNKNOWN_TYPE = 0,
785
786    /**
787     * Starts an ability with a UI.
788     *
789     * @syscap SystemCapability.Ability.AbilityRuntime.Core
790     * @since 9
791     */
792    /**
793     * Starts an ability with a UI.
794     *
795     * @syscap SystemCapability.Ability.AbilityRuntime.Core
796     * @atomicservice
797     * @since arkts {'1.1':'12', '1.2':'20'}
798     * @arkts 1.1&1.2
799     */
800    START_ABILITY,
801
802    /**
803     * Starts multiple abilities with a UI.
804     *
805     * @syscap SystemCapability.Ability.AbilityRuntime.Core
806     * @since 9
807     */
808    /**
809     * Starts multiple abilities with a UI.
810     *
811     * @syscap SystemCapability.Ability.AbilityRuntime.Core
812     * @atomicservice
813     * @since arkts {'1.1':'12', '1.2':'20'}
814     * @arkts 1.1&1.2
815     */
816    START_ABILITIES,
817
818    /**
819     * Starts an ability without a UI.
820     *
821     * @syscap SystemCapability.Ability.AbilityRuntime.Core
822     * @since 9
823     */
824    /**
825     * Starts an ability without a UI (valid only in the FA model).
826     *
827     * @syscap SystemCapability.Ability.AbilityRuntime.Core
828     * @atomicservice
829     * @since arkts {'1.1':'12', '1.2':'20'}
830     * @arkts 1.1&1.2
831     */
832    START_SERVICE,
833
834    /**
835     * Sends a common event.
836     *
837     * @syscap SystemCapability.Ability.AbilityRuntime.Core
838     * @since 9
839     */
840    /**
841     * Sends a common event.
842     *
843     * @syscap SystemCapability.Ability.AbilityRuntime.Core
844     * @atomicservice
845     * @since arkts {'1.1':'12', '1.2':'20'}
846     * @arkts 1.1&1.2
847     */
848    SEND_COMMON_EVENT,
849
850    /**
851     * Starts a service extension.
852     *
853     * @syscap SystemCapability.Ability.AbilityRuntime.Core
854     * @systemapi
855     * @stagemodelonly
856     * @since arkts {'1.1':'12', '1.2':'20'}
857     * @arkts 1.1&1.2
858     */
859    START_SERVICE_EXTENSION = 6
860  }
861
862  /**
863   * Describes the data returned by after wantAgent.trigger is called.
864   *
865   * @typedef CompleteData
866   * @syscap SystemCapability.Ability.AbilityRuntime.Core
867   * @since 9
868   */
869  /**
870   * Describes the data returned by the operation of proactive triggering a WantAgent object.
871   *
872   * @typedef CompleteData
873   * @syscap SystemCapability.Ability.AbilityRuntime.Core
874   * @atomicservice
875   * @since arkts {'1.1':'12', '1.2':'20'}
876   * @arkts 1.1&1.2
877   */
878  export interface CompleteData {
879    /**
880     * Triggered WantAgent.
881     *
882     * @type { WantAgent }
883     * @syscap SystemCapability.Ability.AbilityRuntime.Core
884     * @since 9
885     */
886    /**
887     * WantAgent object that is triggered.
888     *
889     * @type { WantAgent }
890     * @syscap SystemCapability.Ability.AbilityRuntime.Core
891     * @atomicservice
892     * @since 12
893     */
894    info: WantAgent;
895
896    /**
897     * Existing Want that is triggered.
898     *
899     * @type { Want }
900     * @syscap SystemCapability.Ability.AbilityRuntime.Core
901     * @since 9
902     */
903    /**
904     * Existing Want that is triggered.
905     *
906     * @type { Want }
907     * @syscap SystemCapability.Ability.AbilityRuntime.Core
908     * @atomicservice
909     * @since 12
910     */
911    want: Want;
912
913    /**
914     * Request code used to trigger the WantAgent.
915     *
916     * @type { number }
917     * @syscap SystemCapability.Ability.AbilityRuntime.Core
918     * @since 9
919     */
920    /**
921     * Request code that triggers the WantAgent object.
922     *
923     * @type { number }
924     * @syscap SystemCapability.Ability.AbilityRuntime.Core
925     * @atomicservice
926     * @since 12
927     */
928    finalCode: number;
929
930    /**
931     * Final data collected by the common event.
932     *
933     * @type { string }
934     * @syscap SystemCapability.Ability.AbilityRuntime.Core
935     * @since 9
936     */
937    /**
938     * Final data collected by the common event.
939     *
940     * @type { string }
941     * @syscap SystemCapability.Ability.AbilityRuntime.Core
942     * @atomicservice
943     * @since 12
944     */
945    finalData: string;
946
947    /**
948     * Extra data collected by the common event.
949     *
950     * @type { ?object }
951     * @syscap SystemCapability.Ability.AbilityRuntime.Core
952     * @since 9
953     */
954    /**
955     * Extra data collected by the common event.
956     *
957     * @type { ?Record<string, Object> }
958     * @syscap SystemCapability.Ability.AbilityRuntime.Core
959     * @since 11
960     */
961    /**
962     * Extra information.
963     *
964     * @type { ?Record<string, Object> }
965     * @syscap SystemCapability.Ability.AbilityRuntime.Core
966     * @atomicservice
967     * @since 12
968     */
969    extraInfo?: Record<string, Object>;
970  }
971
972  /**
973   * Provides the information required for triggering a WantAgent.
974   *
975   * @typedef { _TriggerInfo }
976   * @syscap SystemCapability.Ability.AbilityRuntime.Core
977   * @since 9
978   */
979  /**
980   * Defines the TriggerInfo object.
981   *
982   * @typedef { _TriggerInfo }
983   * @syscap SystemCapability.Ability.AbilityRuntime.Core
984   * @atomicservice
985   * @since arkts {'1.1':'12', '1.2':'20'}
986   * @arkts 1.1&1.2
987   */
988  export type TriggerInfo = _TriggerInfo;
989
990  /**
991   * Provides the information required for triggering a WantAgent.
992   *
993   * @typedef { _WantAgentInfo }
994   * @syscap SystemCapability.Ability.AbilityRuntime.Core
995   * @since 9
996   */
997  /**
998   * Defines the WantAgentInfo object.
999   *
1000   * @typedef { _WantAgentInfo }
1001   * @syscap SystemCapability.Ability.AbilityRuntime.Core
1002   * @atomicservice
1003   * @since arkts {'1.1':'12', '1.2':'20'}
1004   * @arkts 1.1&1.2
1005   */
1006  export type WantAgentInfo = _WantAgentInfo;
1007
1008  /**
1009   * Provides the information required to create a local WantAgent.
1010   *
1011   * @typedef { _LocalWantAgentInfo }
1012   * @syscap SystemCapability.Ability.AbilityRuntime.Core
1013   * @systemapi
1014   * @since 20
1015   */
1016  export type LocalWantAgentInfo = _LocalWantAgentInfo;
1017
1018}
1019
1020/**
1021 * Target WantAgent object.
1022 *
1023 * @typedef { object }
1024 * @syscap SystemCapability.Ability.AbilityRuntime.Core
1025 * @since arkts {'1.1':'9', '1.2':'20'}
1026 * @arkts 1.1&1.2
1027 */
1028export type WantAgent = object;
1029
1030export default wantAgent;
1031