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'; 25 26/** 27 * Provide the method obtain trigger, cancel, and compare and to obtain 28 * the bundle name, UID of an {@link WantAgent} object. 29 * 30 * @namespace wantAgent 31 * @syscap SystemCapability.Ability.AbilityRuntime.Core 32 * @since 9 33 */ 34/** 35 * Provide the method obtain trigger, cancel, and compare and to obtain 36 * the bundle name, UID of an {@link WantAgent} object. 37 * 38 * @namespace wantAgent 39 * @syscap SystemCapability.Ability.AbilityRuntime.Core 40 * @atomicservice 41 * @since 12 42 */ 43declare namespace wantAgent { 44 /** 45 * Obtains the bundle name of a WantAgent. 46 * 47 * @param { WantAgent } agent - Indicates the WantAgent. 48 * @param { AsyncCallback<string> } callback - The callback is used to return the bundle name. 49 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 50 * 2. Incorrect parameter types. 51 * @throws { BusinessError } 16000007 - Service busy, there are concurrent tasks, waiting for retry. 52 * @throws { BusinessError } 16000151 - Invalid wantagent object. 53 * @syscap SystemCapability.Ability.AbilityRuntime.Core 54 * @since 9 55 */ 56 /** 57 * Obtains the bundle name of a WantAgent. 58 * 59 * @param { WantAgent } agent - Indicates the WantAgent. 60 * @param { AsyncCallback<string> } callback - The callback is used to return the bundle name. 61 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 62 * 2. Incorrect parameter types. 63 * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later. 64 * @throws { BusinessError } 16000151 - Invalid wantagent object. 65 * @syscap SystemCapability.Ability.AbilityRuntime.Core 66 * @atomicservice 67 * @since 12 68 */ 69 function getBundleName(agent: WantAgent, callback: AsyncCallback<string>): void; 70 71 /** 72 * Obtains the bundle name of a WantAgent. 73 * 74 * @param { WantAgent } agent - Indicates the WantAgent. 75 * @returns { Promise<string> } Returns the bundle name. 76 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 77 * 2. Incorrect parameter types. 78 * @throws { BusinessError } 16000007 - Service busy, there are concurrent tasks, waiting for retry. 79 * @throws { BusinessError } 16000151 - Invalid wantagent object. 80 * @syscap SystemCapability.Ability.AbilityRuntime.Core 81 * @since 9 82 */ 83 /** 84 * Obtains the bundle name of a WantAgent. 85 * 86 * @param { WantAgent } agent - Indicates the WantAgent. 87 * @returns { Promise<string> } Returns the bundle name. 88 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 89 * 2. Incorrect parameter types. 90 * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later. 91 * @throws { BusinessError } 16000151 - Invalid wantagent object. 92 * @syscap SystemCapability.Ability.AbilityRuntime.Core 93 * @atomicservice 94 * @since 12 95 */ 96 function getBundleName(agent: WantAgent): Promise<string>; 97 98 /** 99 * Obtains the UID of a WantAgent. 100 * 101 * @param { WantAgent } agent - Indicates the WantAgent. 102 * @param { AsyncCallback<number> } callback - The callback is used to return the UID. 103 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 104 * 2. Incorrect parameter types. 105 * @throws { BusinessError } 16000007 - Service busy, there are concurrent tasks, waiting for retry. 106 * @throws { BusinessError } 16000151 - Invalid wantagent object. 107 * @syscap SystemCapability.Ability.AbilityRuntime.Core 108 * @since 9 109 */ 110 /** 111 * Obtains the UID of a WantAgent. 112 * 113 * @param { WantAgent } agent - Indicates the WantAgent. 114 * @param { AsyncCallback<number> } callback - The callback is used to return the UID. 115 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 116 * 2. Incorrect parameter types. 117 * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later. 118 * @throws { BusinessError } 16000151 - Invalid wantagent object. 119 * @syscap SystemCapability.Ability.AbilityRuntime.Core 120 * @atomicservice 121 * @since 12 122 */ 123 function getUid(agent: WantAgent, callback: AsyncCallback<number>): void; 124 125 /** 126 * Obtains the UID of a WantAgent. 127 * 128 * @param { WantAgent } agent - Indicates the WantAgent. 129 * @returns { Promise<number> } Returns the UID. 130 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 131 * 2. Incorrect parameter types. 132 * @throws { BusinessError } 16000007 - Service busy, there are concurrent tasks, waiting for retry. 133 * @throws { BusinessError } 16000151 - Invalid wantagent object. 134 * @syscap SystemCapability.Ability.AbilityRuntime.Core 135 * @since 9 136 */ 137 /** 138 * Obtains the UID of a WantAgent. 139 * 140 * @param { WantAgent } agent - Indicates the WantAgent. 141 * @returns { Promise<number> } Returns the UID. 142 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 143 * 2. Incorrect parameter types. 144 * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later. 145 * @throws { BusinessError } 16000151 - Invalid wantagent object. 146 * @syscap SystemCapability.Ability.AbilityRuntime.Core 147 * @atomicservice 148 * @since 12 149 */ 150 function getUid(agent: WantAgent): Promise<number>; 151 152 /** 153 * Obtains the {@link Want} of an {@link WantAgent}. 154 * 155 * @param { WantAgent } agent - Indicates the WantAgent. 156 * @param { AsyncCallback<Want> } callback - The callback is used to return the Want. 157 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 158 * 2. Incorrect parameter types. 159 * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later. 160 * @throws { BusinessError } 16000015 - Service timeout. 161 * @throws { BusinessError } 16000151 - Invalid wantagent object. 162 * @syscap SystemCapability.Ability.AbilityRuntime.Core 163 * @systemapi 164 * @since 9 165 */ 166 function getWant(agent: WantAgent, callback: AsyncCallback<Want>): void; 167 168 /** 169 * Obtains the {@link Want} of an {@link WantAgent}. 170 * 171 * @param { WantAgent } agent - Indicates the WantAgent. 172 * @returns { Promise<Want> } Returns the Want. 173 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 174 * 2. Incorrect parameter types. 175 * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later. 176 * @throws { BusinessError } 16000015 - Service timeout. 177 * @throws { BusinessError } 16000151 - Invalid wantagent object. 178 * @syscap SystemCapability.Ability.AbilityRuntime.Core 179 * @systemapi 180 * @since 9 181 */ 182 function getWant(agent: WantAgent): Promise<Want>; 183 184 /** 185 * Cancel a WantAgent. Only the application that creates the WantAgent can cancel it. 186 * 187 * @param { WantAgent } agent - Indicates the WantAgent. 188 * @param { AsyncCallback<void> } callback - The callback of cancel. 189 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 190 * 2. Incorrect parameter types. 191 * @throws { BusinessError } 16000007 - Service busy, there are concurrent tasks, waiting for retry. 192 * @throws { BusinessError } 16000151 - Invalid wantagent object. 193 * @syscap SystemCapability.Ability.AbilityRuntime.Core 194 * @since 9 195 */ 196 /** 197 * Cancel a WantAgent. Only the application that creates the WantAgent can cancel it. 198 * 199 * @param { WantAgent } agent - Indicates the WantAgent. 200 * @param { AsyncCallback<void> } callback - The callback of cancel. 201 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 202 * 2. Incorrect parameter types. 203 * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later. 204 * @throws { BusinessError } 16000151 - Invalid wantagent object. 205 * @syscap SystemCapability.Ability.AbilityRuntime.Core 206 * @atomicservice 207 * @since 12 208 */ 209 function cancel(agent: WantAgent, callback: AsyncCallback<void>): void; 210 211 /** 212 * Cancel a WantAgent. Only the application that creates the WantAgent can cancel it. 213 * 214 * @param { WantAgent } agent - Indicates the WantAgent. 215 * @returns { Promise<void> } The promise returned by the function. 216 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 217 * 2. Incorrect parameter types. 218 * @throws { BusinessError } 16000007 - Service busy, there are concurrent tasks, waiting for retry. 219 * @throws { BusinessError } 16000151 - Invalid wantagent object. 220 * @syscap SystemCapability.Ability.AbilityRuntime.Core 221 * @since 9 222 */ 223 /** 224 * Cancel a WantAgent. Only the application that creates the WantAgent can cancel it. 225 * 226 * @param { WantAgent } agent - Indicates the WantAgent. 227 * @returns { Promise<void> } The promise returned by the function. 228 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 229 * 2. Incorrect parameter types. 230 * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later. 231 * @throws { BusinessError } 16000151 - Invalid wantagent object. 232 * @syscap SystemCapability.Ability.AbilityRuntime.Core 233 * @atomicservice 234 * @since 12 235 */ 236 function cancel(agent: WantAgent): Promise<void>; 237 238 /** 239 * Triggers a WantAgent. 240 * 241 * @param { WantAgent } agent - Indicates the WantAgent. 242 * @param { TriggerInfo } triggerInfo - Indicates the information required for triggering a WantAgent. 243 * @param { AsyncCallback<CompleteData> } [callback] - The callback is used to return the CompleteData. 244 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 245 * 2. Incorrect parameter types. 246 * @syscap SystemCapability.Ability.AbilityRuntime.Core 247 * @since 9 248 */ 249 /** 250 * Triggers a WantAgent. 251 * 252 * @param { WantAgent } agent - Indicates the WantAgent. 253 * @param { TriggerInfo } triggerInfo - Indicates the information required for triggering a WantAgent. 254 * @param { AsyncCallback<CompleteData> } [callback] - The callback is used to return the CompleteData. 255 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 256 * 2. Incorrect parameter types. 257 * @syscap SystemCapability.Ability.AbilityRuntime.Core 258 * @atomicservice 259 * @since 12 260 */ 261 function trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback<CompleteData>): void; 262 263 /** 264 * Checks whether two WantAgent objects are equal. 265 * 266 * @param { WantAgent } agent - Indicates the WantAgent. 267 * @param { WantAgent } otherAgent - Indicates the other WantAgent. 268 * @param { AsyncCallback<boolean> } callback - Returns true if the two WantAgents are the same. 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 * Checks whether two WantAgent objects are equal. 276 * 277 * @param { WantAgent } agent - Indicates the WantAgent. 278 * @param { WantAgent } otherAgent - Indicates the other WantAgent. 279 * @param { AsyncCallback<boolean> } callback - Returns true if the two WantAgents are the same. 280 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 281 * 2. Incorrect parameter types. 282 * @syscap SystemCapability.Ability.AbilityRuntime.Core 283 * @atomicservice 284 * @since 12 285 */ 286 function equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback<boolean>): void; 287 288 /** 289 * Checks whether two WantAgent objects are equal. 290 * 291 * @param { WantAgent } agent - Indicates the WantAgent. 292 * @param { WantAgent } otherAgent - Indicates the other WantAgent. 293 * @returns { Promise<boolean> } Returns true if the two WantAgents are the same. 294 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 295 * 2. Incorrect parameter types. 296 * @syscap SystemCapability.Ability.AbilityRuntime.Core 297 * @since 9 298 */ 299 /** 300 * Checks whether two WantAgent objects are equal. 301 * 302 * @param { WantAgent } agent - Indicates the WantAgent. 303 * @param { WantAgent } otherAgent - Indicates the other WantAgent. 304 * @returns { Promise<boolean> } Returns true if the two WantAgents are the same. 305 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 306 * 2. Incorrect parameter types. 307 * @syscap SystemCapability.Ability.AbilityRuntime.Core 308 * @atomicservice 309 * @since 12 310 */ 311 function equal(agent: WantAgent, otherAgent: WantAgent): Promise<boolean>; 312 313 /** 314 * Obtains a WantAgent object. 315 * 316 * @param { WantAgentInfo } info - Information about the WantAgent object to obtain. 317 * @param { AsyncCallback<WantAgent> } callback - The callback is used to return the created WantAgent. 318 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 319 * 2. Incorrect parameter types. 320 * @throws { BusinessError } 16000007 - Service busy, there are concurrent tasks, waiting for retry. 321 * @throws { BusinessError } 16000151 - Invalid wantagent object. 322 * @syscap SystemCapability.Ability.AbilityRuntime.Core 323 * @since 9 324 */ 325 /** 326 * Obtains a WantAgent object. 327 * 328 * @param { WantAgentInfo } info - Information about the WantAgent object to obtain. 329 * @param { AsyncCallback<WantAgent> } callback - The callback is used to return the created WantAgent. 330 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 331 * 2. Incorrect parameter types. 332 * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later. 333 * @throws { BusinessError } 16000151 - Invalid wantagent object. 334 * @syscap SystemCapability.Ability.AbilityRuntime.Core 335 * @atomicservice 336 * @since 12 337 */ 338 function getWantAgent(info: WantAgentInfo, callback: AsyncCallback<WantAgent>): void; 339 340 /** 341 * Obtains a WantAgent object. 342 * 343 * @param { WantAgentInfo } info - Information about the WantAgent object to obtain. 344 * @returns { Promise<WantAgent> } Returns the created WantAgent. 345 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 346 * 2. Incorrect parameter types. 347 * @throws { BusinessError } 16000007 - Service busy, there are concurrent tasks, waiting for retry. 348 * @throws { BusinessError } 16000151 - Invalid wantagent object. 349 * @syscap SystemCapability.Ability.AbilityRuntime.Core 350 * @since 9 351 */ 352 /** 353 * Obtains a WantAgent object. 354 * 355 * @param { WantAgentInfo } info - Information about the WantAgent object to obtain. 356 * @returns { Promise<WantAgent> } Returns the created WantAgent. 357 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 358 * 2. Incorrect parameter types. 359 * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later. 360 * @throws { BusinessError } 16000151 - Invalid wantagent object. 361 * @syscap SystemCapability.Ability.AbilityRuntime.Core 362 * @atomicservice 363 * @since 12 364 */ 365 function getWantAgent(info: WantAgentInfo): Promise<WantAgent>; 366 367 /** 368 * Obtains the {@link OperationType} of a {@link WantAgent}. 369 * 370 * @param { WantAgent } agent - Indicates the WantAgent. 371 * @param { AsyncCallback<number> } callback - The callback is used to return the OperationType of the WantAgent. 372 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 373 * 2. Incorrect parameter types. 374 * @throws { BusinessError } 16000007 - Service busy, there are concurrent tasks, waiting for retry. 375 * @throws { BusinessError } 16000015 - Service timeout. 376 * @throws { BusinessError } 16000151 - Invalid wantagent object. 377 * @syscap SystemCapability.Ability.AbilityRuntime.Core 378 * @since 9 379 */ 380 /** 381 * Obtains the {@link OperationType} of a {@link WantAgent}. 382 * 383 * @param { WantAgent } agent - Indicates the WantAgent. 384 * @param { AsyncCallback<number> } callback - The callback is used to return the OperationType of the WantAgent. 385 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 386 * 2. Incorrect parameter types. 387 * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later. 388 * @throws { BusinessError } 16000015 - Service timeout. 389 * @throws { BusinessError } 16000151 - Invalid wantagent object. 390 * @syscap SystemCapability.Ability.AbilityRuntime.Core 391 * @atomicservice 392 * @since 12 393 */ 394 function getOperationType(agent: WantAgent, callback: AsyncCallback<number>): void; 395 396 /** 397 * Obtains the {@link OperationType} of a {@link WantAgent}. 398 * 399 * @param { WantAgent } agent - Indicates the WantAgent. 400 * @returns { Promise<number> } Returns the OperationType of the WantAgent. 401 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 402 * 2. Incorrect parameter types. 403 * @throws { BusinessError } 16000007 - Service busy, there are concurrent tasks, waiting for retry. 404 * @throws { BusinessError } 16000015 - Service timeout. 405 * @throws { BusinessError } 16000151 - Invalid wantagent object. 406 * @syscap SystemCapability.Ability.AbilityRuntime.Core 407 * @since 9 408 */ 409 /** 410 * Obtains the {@link OperationType} of a {@link WantAgent}. 411 * 412 * @param { WantAgent } agent - Indicates the WantAgent. 413 * @returns { Promise<number> } Returns the OperationType of the WantAgent. 414 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 415 * 2. Incorrect parameter types. 416 * @throws { BusinessError } 16000007 - Service busy. There are concurrent tasks. Try again later. 417 * @throws { BusinessError } 16000015 - Service timeout. 418 * @throws { BusinessError } 16000151 - Invalid wantagent object. 419 * @syscap SystemCapability.Ability.AbilityRuntime.Core 420 * @atomicservice 421 * @since 12 422 */ 423 function getOperationType(agent: WantAgent): Promise<number>; 424 425 /** 426 * Set the wantagent within the process to support multithreading. 427 * 428 * @param { boolean } isMultithreadingSupported - Indicates the WantAgent support multithreading or not. 429 * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app. 430 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 431 * 2. Incorrect parameter types. 432 * @syscap SystemCapability.Ability.AbilityRuntime.Core 433 * @systemapi 434 * @stagemodelonly 435 * @since 18 436 */ 437 function setWantAgentMultithreading(isMultithreadingSupported: boolean) : void; 438 439 /** 440 * Enumerates flags for using a WantAgent. 441 * 442 * @enum { number } 443 * @syscap SystemCapability.Ability.AbilityRuntime.Core 444 * @since 9 445 */ 446 /** 447 * Enumerates flags for using a WantAgent. 448 * 449 * @enum { number } 450 * @syscap SystemCapability.Ability.AbilityRuntime.Core 451 * @atomicservice 452 * @since 12 453 */ 454 export enum WantAgentFlags { 455 /** 456 * Indicates that the WantAgent can be used only once. 457 * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT. 458 * 459 * @syscap SystemCapability.Ability.AbilityRuntime.Core 460 * @since 9 461 */ 462 /** 463 * Indicates that the WantAgent can be used only once. 464 * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT. 465 * 466 * @syscap SystemCapability.Ability.AbilityRuntime.Core 467 * @atomicservice 468 * @since 12 469 */ 470 ONE_TIME_FLAG = 0, 471 472 /** 473 * Indicates that null is returned if the WantAgent does not exist. 474 * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT. 475 * 476 * @syscap SystemCapability.Ability.AbilityRuntime.Core 477 * @since 9 478 */ 479 /** 480 * Indicates that null is returned if the WantAgent does not exist. 481 * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT. 482 * 483 * @syscap SystemCapability.Ability.AbilityRuntime.Core 484 * @atomicservice 485 * @since 12 486 */ 487 NO_BUILD_FLAG, 488 489 /** 490 * Indicates that the existing WantAgent should be canceled before a new object is generated. 491 * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT. 492 * 493 * @syscap SystemCapability.Ability.AbilityRuntime.Core 494 * @since 9 495 */ 496 /** 497 * Indicates that the existing WantAgent should be canceled before a new object is generated. 498 * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT. 499 * 500 * @syscap SystemCapability.Ability.AbilityRuntime.Core 501 * @atomicservice 502 * @since 12 503 */ 504 CANCEL_PRESENT_FLAG, 505 506 /** 507 * Indicates that the system only replaces the extra data of the existing WantAgent with that of the new object. 508 * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT. 509 * 510 * @syscap SystemCapability.Ability.AbilityRuntime.Core 511 * @since 9 512 */ 513 /** 514 * Indicates that the system only replaces the extra data of the existing WantAgent with that of the new object. 515 * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT. 516 * 517 * @syscap SystemCapability.Ability.AbilityRuntime.Core 518 * @atomicservice 519 * @since 12 520 */ 521 UPDATE_PRESENT_FLAG, 522 523 /** 524 * Indicates that the created WantAgent should be immutable. 525 * 526 * @syscap SystemCapability.Ability.AbilityRuntime.Core 527 * @since 9 528 */ 529 /** 530 * Indicates that the created WantAgent should be immutable. 531 * 532 * @syscap SystemCapability.Ability.AbilityRuntime.Core 533 * @atomicservice 534 * @since 12 535 */ 536 CONSTANT_FLAG, 537 538 /** 539 * Indicates that the current value of element can be replaced when the WantAgent is triggered. 540 * 541 * @syscap SystemCapability.Ability.AbilityRuntime.Core 542 * @since 9 543 */ 544 /** 545 * Indicates that the current value of element can be replaced when the WantAgent is triggered. 546 * 547 * @syscap SystemCapability.Ability.AbilityRuntime.Core 548 * @atomicservice 549 * @since 12 550 */ 551 REPLACE_ELEMENT, 552 553 /** 554 * Indicates that the current value of action can be replaced when the WantAgent is triggered. 555 * 556 * @syscap SystemCapability.Ability.AbilityRuntime.Core 557 * @since 9 558 */ 559 /** 560 * Indicates that the current value of action can be replaced when the WantAgent is triggered. 561 * 562 * @syscap SystemCapability.Ability.AbilityRuntime.Core 563 * @atomicservice 564 * @since 12 565 */ 566 REPLACE_ACTION, 567 568 /** 569 * Indicates that the current value of uri can be replaced when the WantAgent is triggered. 570 * 571 * @syscap SystemCapability.Ability.AbilityRuntime.Core 572 * @since 9 573 */ 574 /** 575 * Indicates that the current value of uri can be replaced when the WantAgent is triggered. 576 * 577 * @syscap SystemCapability.Ability.AbilityRuntime.Core 578 * @atomicservice 579 * @since 12 580 */ 581 REPLACE_URI, 582 583 /** 584 * Indicates that the current value of entities can be replaced when the WantAgent is triggered. 585 * 586 * @syscap SystemCapability.Ability.AbilityRuntime.Core 587 * @since 9 588 */ 589 /** 590 * Indicates that the current value of entities can be replaced when the WantAgent is triggered. 591 * 592 * @syscap SystemCapability.Ability.AbilityRuntime.Core 593 * @atomicservice 594 * @since 12 595 */ 596 REPLACE_ENTITIES, 597 598 /** 599 * Indicates that the current value of packageName can be replaced when the WantAgent is triggered. 600 * 601 * @syscap SystemCapability.Ability.AbilityRuntime.Core 602 * @since 9 603 */ 604 /** 605 * Indicates that the current value of packageName can be replaced when the WantAgent is triggered. 606 * 607 * @syscap SystemCapability.Ability.AbilityRuntime.Core 608 * @atomicservice 609 * @since 12 610 */ 611 REPLACE_BUNDLE 612 } 613 614 /** 615 * Identifies the operation for using a WantAgent, such as starting an ability or sending a common event. 616 * 617 * @enum { number } 618 * @syscap SystemCapability.Ability.AbilityRuntime.Core 619 * @since 9 620 */ 621 /** 622 * Identifies the operation for using a WantAgent, such as starting an ability or sending a common event. 623 * 624 * @enum { number } 625 * @syscap SystemCapability.Ability.AbilityRuntime.Core 626 * @atomicservice 627 * @since 12 628 */ 629 export enum OperationType { 630 /** 631 * Unknown operation. 632 * 633 * @syscap SystemCapability.Ability.AbilityRuntime.Core 634 * @since 9 635 */ 636 /** 637 * Unknown operation. 638 * 639 * @syscap SystemCapability.Ability.AbilityRuntime.Core 640 * @atomicservice 641 * @since 12 642 */ 643 UNKNOWN_TYPE = 0, 644 645 /** 646 * Starts an ability with a UI. 647 * 648 * @syscap SystemCapability.Ability.AbilityRuntime.Core 649 * @since 9 650 */ 651 /** 652 * Starts an ability with a UI. 653 * 654 * @syscap SystemCapability.Ability.AbilityRuntime.Core 655 * @atomicservice 656 * @since 12 657 */ 658 START_ABILITY, 659 660 /** 661 * Starts multiple abilities with a UI. 662 * 663 * @syscap SystemCapability.Ability.AbilityRuntime.Core 664 * @since 9 665 */ 666 /** 667 * Starts multiple abilities with a UI. 668 * 669 * @syscap SystemCapability.Ability.AbilityRuntime.Core 670 * @atomicservice 671 * @since 12 672 */ 673 START_ABILITIES, 674 675 /** 676 * Starts an ability without a UI. 677 * 678 * @syscap SystemCapability.Ability.AbilityRuntime.Core 679 * @since 9 680 */ 681 /** 682 * Starts an ability without a UI. 683 * 684 * @syscap SystemCapability.Ability.AbilityRuntime.Core 685 * @atomicservice 686 * @since 12 687 */ 688 START_SERVICE, 689 690 /** 691 * Sends a common event. 692 * 693 * @syscap SystemCapability.Ability.AbilityRuntime.Core 694 * @since 9 695 */ 696 /** 697 * Sends a common event. 698 * 699 * @syscap SystemCapability.Ability.AbilityRuntime.Core 700 * @atomicservice 701 * @since 12 702 */ 703 SEND_COMMON_EVENT, 704 705 /** 706 * Starts a service extension. 707 * 708 * @syscap SystemCapability.Ability.AbilityRuntime.Core 709 * @systemapi 710 * @stagemodelonly 711 * @since 12 712 */ 713 START_SERVICE_EXTENSION = 6 714 } 715 716 /** 717 * Describes the data returned by after wantAgent.trigger is called. 718 * 719 * @typedef CompleteData 720 * @syscap SystemCapability.Ability.AbilityRuntime.Core 721 * @since 9 722 */ 723 /** 724 * Describes the data returned by after wantAgent.trigger is called. 725 * 726 * @typedef CompleteData 727 * @syscap SystemCapability.Ability.AbilityRuntime.Core 728 * @atomicservice 729 * @since 12 730 */ 731 export interface CompleteData { 732 /** 733 * Triggered WantAgent. 734 * 735 * @type { WantAgent } 736 * @syscap SystemCapability.Ability.AbilityRuntime.Core 737 * @since 9 738 */ 739 /** 740 * Triggered WantAgent. 741 * 742 * @type { WantAgent } 743 * @syscap SystemCapability.Ability.AbilityRuntime.Core 744 * @atomicservice 745 * @since 12 746 */ 747 info: WantAgent; 748 749 /** 750 * Existing Want that is triggered. 751 * 752 * @type { Want } 753 * @syscap SystemCapability.Ability.AbilityRuntime.Core 754 * @since 9 755 */ 756 /** 757 * Existing Want that is triggered. 758 * 759 * @type { Want } 760 * @syscap SystemCapability.Ability.AbilityRuntime.Core 761 * @atomicservice 762 * @since 12 763 */ 764 want: Want; 765 766 /** 767 * Request code used to trigger the WantAgent. 768 * 769 * @type { number } 770 * @syscap SystemCapability.Ability.AbilityRuntime.Core 771 * @since 9 772 */ 773 /** 774 * Request code used to trigger the WantAgent. 775 * 776 * @type { number } 777 * @syscap SystemCapability.Ability.AbilityRuntime.Core 778 * @atomicservice 779 * @since 12 780 */ 781 finalCode: number; 782 783 /** 784 * Final data collected by the common event. 785 * 786 * @type { string } 787 * @syscap SystemCapability.Ability.AbilityRuntime.Core 788 * @since 9 789 */ 790 /** 791 * Final data collected by the common event. 792 * 793 * @type { string } 794 * @syscap SystemCapability.Ability.AbilityRuntime.Core 795 * @atomicservice 796 * @since 12 797 */ 798 finalData: string; 799 800 /** 801 * Extra data collected by the common event. 802 * 803 * @type { ?object } 804 * @syscap SystemCapability.Ability.AbilityRuntime.Core 805 * @since 9 806 */ 807 /** 808 * Extra data collected by the common event. 809 * 810 * @type { ?Record<string, Object> } 811 * @syscap SystemCapability.Ability.AbilityRuntime.Core 812 * @since 11 813 */ 814 /** 815 * Extra data collected by the common event. 816 * 817 * @type { ?Record<string, Object> } 818 * @syscap SystemCapability.Ability.AbilityRuntime.Core 819 * @atomicservice 820 * @since 12 821 */ 822 extraInfo?: Record<string, Object>; 823 } 824 825 /** 826 * Provides the information required for triggering a WantAgent. 827 * 828 * @typedef { _TriggerInfo } 829 * @syscap SystemCapability.Ability.AbilityRuntime.Core 830 * @since 9 831 */ 832 /** 833 * Provides the information required for triggering a WantAgent. 834 * 835 * @typedef { _TriggerInfo } 836 * @syscap SystemCapability.Ability.AbilityRuntime.Core 837 * @atomicservice 838 * @since 12 839 */ 840 export type TriggerInfo = _TriggerInfo; 841 842 /** 843 * Provides the information required for triggering a WantAgent. 844 * 845 * @typedef { _WantAgentInfo } 846 * @syscap SystemCapability.Ability.AbilityRuntime.Core 847 * @since 9 848 */ 849 /** 850 * Provides the information required for triggering a WantAgent. 851 * 852 * @typedef { _WantAgentInfo } 853 * @syscap SystemCapability.Ability.AbilityRuntime.Core 854 * @atomicservice 855 * @since 12 856 */ 857 export type WantAgentInfo = _WantAgentInfo; 858} 859 860/** 861 * WantAgent object. 862 * 863 * @typedef { object } 864 * @syscap SystemCapability.Ability.AbilityRuntime.Core 865 * @since 9 866 */ 867export type WantAgent = object; 868 869export default wantAgent; 870