1/* 2 * Copyright (c) 2020 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 * @typedef Result 18 * @syscap SystemCapability.ArkUI.ArkUI.Lite 19 * @since 5 20 * @deprecated since 8 21 */ 22export interface Result { 23 /** 24 * Result code. 25 * @syscap SystemCapability.ArkUI.ArkUI.Lite 26 * @since 5 27 * @deprecated since 8 28 */ 29 code: number; 30 31 /** 32 * Returned data. 33 * @syscap SystemCapability.ArkUI.ArkUI.Lite 34 * @since 5 35 * @deprecated since 8 36 */ 37 data: object; 38} 39 40/** 41 * @typedef SubscribeMessageResponse 42 * @syscap SystemCapability.ArkUI.ArkUI.Lite 43 * @since 5 44 * @deprecated since 8 45 */ 46export interface SubscribeMessageResponse { 47 /** 48 * Peer device ID. 49 * @syscap SystemCapability.ArkUI.ArkUI.Lite 50 * @since 5 51 * @deprecated since 8 52 */ 53 deviceId: string; 54 55 /** 56 * Name of the bundle where the peer ability has been located. The name is case sensitive. 57 * @syscap SystemCapability.ArkUI.ArkUI.Lite 58 * @since 5 59 * @deprecated since 8 60 */ 61 bundleName: string; 62 63 /** 64 * Peer ability name, which is case sensitive. 65 * @syscap SystemCapability.ArkUI.ArkUI.Lite 66 * @since 5 67 * @deprecated since 8 68 */ 69 abilityName: string; 70 71 /** 72 * Messages received from the device. 73 * @syscap SystemCapability.ArkUI.ArkUI.Lite 74 * @since 5 75 * @deprecated since 8 76 */ 77 message: string; 78} 79 80/** 81 * @typedef CallAbilityParam 82 * @syscap SystemCapability.ArkUI.ArkUI.Lite 83 * @since 5 84 * @deprecated since 8 85 */ 86export interface CallAbilityParam { 87 /** 88 * Name of the bundle where the ability has been located. The name is case sensitive and must be the same as that on the AA side. 89 * @syscap SystemCapability.ArkUI.ArkUI.Lite 90 * @since 5 91 * @deprecated since 8 92 */ 93 bundleName: string; 94 95 /** 96 * Ability name, which is case sensitive and must be the same as that on the AA side. 97 * @syscap SystemCapability.ArkUI.ArkUI.Lite 98 * @since 5 99 * @deprecated since 8 100 */ 101 abilityName: string; 102 103 /** 104 * Ability operation code, which defines the service function of an AA and must be consistent with the AA side. 105 * @syscap SystemCapability.ArkUI.ArkUI.Lite 106 * @since 5 107 * @deprecated since 8 108 */ 109 messageCode: number; 110 111 /** 112 * Ability type. Different types of abilities have different implementation on the AA side. 113 * 0: Ability, which has an independent lifecycle. The FA starts and requests an AA through an RPC. Such type of abilities are used to provide basic services for multiple FAs to call or are used when the abilities should run in the background. 114 * 1: Internal ability, which shares the same process with the FA and communicates with it by calling internal functions. Such type of abilities are used in scenarios that require low response latency and cannot be called by other FAs. 115 * @syscap SystemCapability.ArkUI.ArkUI.Lite 116 * @since 5 117 * @deprecated since 8 118 */ 119 abilityType: number; 120 121 /** 122 * Data sent to the ability. The data to carry differs depending on the service to be processed and its field name must be consistent with the AA side. 123 * @syscap SystemCapability.ArkUI.ArkUI.Lite 124 * @since 5 125 * @deprecated since 8 126 */ 127 data?: object; 128 129 /** 130 * Whether the request is synchronous or asynchronous. The synchronous mode is used by default. Currently, the asynchronous mode is available only for internal abilities. 131 * 0: Synchronous mode (default value) 132 * 1: Asynchronous mode 133 * @syscap SystemCapability.ArkUI.ArkUI.Lite 134 * @since 5 135 * @deprecated since 8 136 */ 137 syncOption?: number; 138} 139 140/** 141 * @typedef SubscribeAbilityEventParam 142 * @syscap SystemCapability.ArkUI.ArkUI.Lite 143 * @since 5 144 * @deprecated since 8 145 */ 146export interface SubscribeAbilityEventParam { 147 /** 148 * Name of the bundle where the ability has been located. The name is case sensitive and must be the same as that on the AA side. 149 * @syscap SystemCapability.ArkUI.ArkUI.Lite 150 * @since 5 151 * @deprecated since 8 152 */ 153 bundleName: string; 154 155 /** 156 * Ability name, which is case sensitive and must be the same as that on the AA side. 157 * @syscap SystemCapability.ArkUI.ArkUI.Lite 158 * @since 5 159 * @deprecated since 8 160 */ 161 abilityName: string; 162 163 /** 164 * Ability operation code, which defines the service function of an AA and must be consistent with the AA side. 165 * @syscap SystemCapability.ArkUI.ArkUI.Lite 166 * @since 5 167 * @deprecated since 8 168 */ 169 messageCode: number; 170 171 /** 172 * Ability type. Different types of abilities have different implementation on the AA side. 173 * 0: Ability, which has an independent lifecycle. The FA starts and requests an AA through an RPC. Such type of abilities are used to provide basic services for multiple FAs to call or are used when the abilities should run in the background. 174 * 1: Internal ability, which shares the same process with the FA and communicates with it by calling internal functions. Such type of abilities are used in scenarios that require low response latency and cannot be called by other FAs. 175 * @syscap SystemCapability.ArkUI.ArkUI.Lite 176 * @since 5 177 * @deprecated since 8 178 */ 179 abilityType: number; 180 181 /** 182 * Whether the request is synchronous or asynchronous. The synchronous mode is used by default. Currently, the asynchronous mode is available only for internal abilities. 183 * 0: Synchronous mode (default value) 184 * 1: Asynchronous mode 185 * @syscap SystemCapability.ArkUI.ArkUI.Lite 186 * @since 5 187 * @deprecated since 8 188 */ 189 syncOption?: number; 190} 191 192/** 193 * @typedef SendMessageOptions 194 * @syscap SystemCapability.ArkUI.ArkUI.Lite 195 * @since 5 196 * @deprecated since 8 197 */ 198export interface SendMessageOptions { 199 /** 200 * Destination device ID. 201 * @syscap SystemCapability.ArkUI.ArkUI.Lite 202 * @since 5 203 * @deprecated since 8 204 */ 205 deviceId: string; 206 207 /** 208 * Name of the destination bundle where the ability has been located. The name is case sensitive. 209 * @syscap SystemCapability.ArkUI.ArkUI.Lite 210 * @since 5 211 * @deprecated since 8 212 */ 213 bundleName: string; 214 215 /** 216 * Destination ability name, which is case sensitive. 217 * @syscap SystemCapability.ArkUI.ArkUI.Lite 218 * @since 5 219 * @deprecated since 8 220 */ 221 abilityName: string; 222 223 /** 224 * Messages sent to the destination device. 225 * A maximum of 1 KB of data can be transmitted at a time. 226 * If more than 1 KB of data needs to be transmitted, split the messages into multiple parts to transmit. 227 * @syscap SystemCapability.ArkUI.ArkUI.Lite 228 * @since 5 229 * @deprecated since 8 230 */ 231 message?: string; 232 233 /** 234 * Called when the messages are sent successfully. 235 * @syscap SystemCapability.ArkUI.ArkUI.Lite 236 * @since 5 237 * @deprecated since 8 238 */ 239 success?: () => void; 240 241 /** 242 * Called when the messages fail to be sent. 243 * @syscap SystemCapability.ArkUI.ArkUI.Lite 244 * @since 5 245 * @deprecated since 8 246 */ 247 fail?: (data: string, code: number) => void; 248 249 /** 250 * Called when the execution is completed. 251 * @syscap SystemCapability.ArkUI.ArkUI.Lite 252 * @since 5 253 * @deprecated since 8 254 */ 255 complete?: () => void; 256} 257 258/** 259 * @typedef SubscribeMessageOptions 260 * @syscap SystemCapability.ArkUI.ArkUI.Lite 261 * @since 5 262 * @deprecated since 8 263 */ 264export interface SubscribeMessageOptions { 265 /** 266 * Called when the messages are sent successfully. 267 * @syscap SystemCapability.ArkUI.ArkUI.Lite 268 * @since 5 269 * @deprecated since 8 270 */ 271 success?: (data: SubscribeMessageResponse) => void; 272 273 /** 274 * Called when the messages fail to be sent. 275 * @syscap SystemCapability.ArkUI.ArkUI.Lite 276 * @since 5 277 * @deprecated since 8 278 */ 279 fail?: (data: string, code: number) => void; 280} 281 282/** 283 * @typedef RequestParams 284 * @syscap SystemCapability.ArkUI.ArkUI.Lite 285 * @since 5 286 * @deprecated since 8 287 */ 288export interface RequestParams { 289 /** 290 * The name of the bundle to start. It should be used with abilityname and case sensitive. 291 * @syscap SystemCapability.ArkUI.ArkUI.Lite 292 * @since 5 293 * @deprecated since 8 294 */ 295 bundleName?: string; 296 297 /** 298 * Ability name, which is case sensitive. 299 * @syscap SystemCapability.ArkUI.ArkUI.Lite 300 * @since 5 301 * @deprecated since 8 302 */ 303 abilityName?: string; 304 305 /** 306 * The list of entities to which the FA to be called. If it is not filled in, all entity lists will be found by default. It should be used with action. 307 * @syscap SystemCapability.ArkUI.ArkUI.Lite 308 * @since 5 309 * @deprecated since 8 310 */ 311 entities?: Array<string>; 312 313 /** 314 * Without specifying the bundle name and ability name, you can start the application according to other properties with action. 315 * @syscap SystemCapability.ArkUI.ArkUI.Lite 316 * @since 5 317 * @deprecated since 8 318 */ 319 action?: string; 320 321 /** 322 * If more than one FA meets the conditions, the user can select the device from the popup. 323 * 0: Default. Select the FA to start from the local and remote devices. 324 * 1: start FA from the local device. 325 * @syscap SystemCapability.ArkUI.ArkUI.Lite 326 * @since 5 327 * @deprecated since 8 328 */ 329 deviceType?: number; 330 331 /** 332 * Data sent to the ability which need to be serializable. 333 * @syscap SystemCapability.ArkUI.ArkUI.Lite 334 * @since 5 335 * @deprecated since 8 336 */ 337 data?: object; 338 339 /** 340 * Configuration switch when start FA. 341 * @syscap SystemCapability.ArkUI.ArkUI.Lite 342 * @since 5 343 * @deprecated since 8 344 */ 345 flag?: number; 346 347 /** 348 * Specify the url of the page which the FA to be called. Use home page directly by default. 349 * @syscap SystemCapability.ArkUI.ArkUI.Lite 350 * @since 5 351 * @deprecated since 8 352 */ 353 url?: string; 354} 355 356/** 357 * @typedef FinishWithResultParams 358 * @syscap SystemCapability.ArkUI.ArkUI.Lite 359 * @since 5 360 * @deprecated since 8 361 */ 362export interface FinishWithResultParams { 363 /** 364 * Result code. 365 * @syscap SystemCapability.ArkUI.ArkUI.Lite 366 * @since 5 367 * @deprecated since 8 368 */ 369 code: number; 370 371 /** 372 * Returned data. 373 * @syscap SystemCapability.ArkUI.ArkUI.Lite 374 * @since 5 375 * @deprecated since 8 376 */ 377 result: object; 378} 379 380/** 381 * @syscap SystemCapability.ArkUI.ArkUI.Lite 382 * @since 5 383 * @deprecated since 8 384 * @useinstead ohos.ability.featureAbility.FeatureAbility 385 */ 386export declare class FeatureAbility { 387 /** 388 * Start a FA without callback result. 389 * @param { RequestParams } request - Indicates the request param. 390 * @returns { Promise<Result> } A Promise object is returned, which contains the result of whether to call Ability's interface successfully. 391 * @syscap SystemCapability.ArkUI.ArkUI.Lite 392 * @since 5 393 * @deprecated since 8 394 * @useinstead ohos.ability.featureAbility.FeatureAbility#startAbility 395 */ 396 static startAbility(request: RequestParams): Promise<Result>; 397 398 /** 399 * Start a FA with callback result. 400 * @param { RequestParams } request - Indicates the request param. 401 * @returns { Promise<Result> } A Promise object is returned, which contains the result of the data FA returned. 402 * @syscap SystemCapability.ArkUI.ArkUI.Lite 403 * @since 5 404 * @deprecated since 8 405 * @useinstead ohos.ability.featureAbility.FeatureAbility#startAbilityForResult 406 */ 407 static startAbilityForResult(request: RequestParams): Promise<Result>; 408 409 /** 410 * FA call the interface to destroy itself and set the result as parameters. 411 * @param { FinishWithResultParams } param - Indicates the request param. 412 * @returns { Promise<Result> } A Promise object is returned, which contains the result whether to callback successfully. 413 * @syscap SystemCapability.ArkUI.ArkUI.Lite 414 * @since 5 415 * @deprecated since 8 416 * @useinstead ohos.ability.featureAbility.FeatureAbility#terminateSelfWithResult 417 */ 418 static finishWithResult(param: FinishWithResultParams): Promise<Result>; 419 420 /** 421 * Get device information list. 422 * @param { number } flag - Default 0, get the information list of all devices in the network. 423 * @returns { Promise<Result> } A Promise object is returned, which contains the result whether the device information list is obtained successfully. 424 * @syscap SystemCapability.ArkUI.ArkUI.Lite 425 * @since 5 426 * @deprecated since 8 427 */ 428 static getDeviceList(flag: number): Promise<Result>; 429 430 /** 431 * Calls an AA. 432 * @param { CallAbilityParam } param - Indicates the request param. 433 * @returns { Promise<string> } A Promise object is returned, which contains the result data returned by the AA. The result is a JSON string. 434 * @syscap SystemCapability.ArkUI.ArkUI.Lite 435 * @since 5 436 * @deprecated since 8 437 */ 438 static callAbility(param: CallAbilityParam): Promise<string>; 439 440 /** 441 * Start FA migration. 442 * @returns { Promise<Result> } A Promise object is returned, which contains the result data returned by the AA. The result is a JSON string. 443 * @syscap SystemCapability.ArkUI.ArkUI.Lite 444 * @since 5 445 * @deprecated since 8 446 */ 447 static continueAbility(): Promise<Result>; 448 449 /** 450 * Subscribe to events of an AA. 451 * @param { SubscribeAbilityEventParam } param - Indicates the request param. 452 * @param { Function } func - Indicates the event reporting callback. 453 * @returns { Promise<string> } A Promise object is returned, which contains the result data returned by the AA. The result is a JSON string. 454 * @syscap SystemCapability.ArkUI.ArkUI.Lite 455 * @since 5 456 * @deprecated since 8 457 */ 458 static subscribeAbilityEvent(param: SubscribeAbilityEventParam, func: Function): Promise<string>; 459 460 /** 461 * Unsubscribe from events of an AA. 462 * @param { SubscribeAbilityEventParam } param - Indicates the request param. 463 * @returns { Promise<string> } A Promise object is returned, which contains the result data returned by the AA. The result is a JSON string. 464 * @syscap SystemCapability.ArkUI.ArkUI.Lite 465 * @since 5 466 * @deprecated since 8 467 */ 468 static unsubscribeAbilityEvent(param: SubscribeAbilityEventParam): Promise<string>; 469 470 /** 471 * Sends messages to the destination device. 472 * @param { SendMessageOptions } options - Options. 473 * @syscap SystemCapability.ArkUI.ArkUI.Lite 474 * @since 5 475 * @deprecated since 8 476 */ 477 static sendMsg(options: SendMessageOptions): void; 478 479 /** 480 * Listens for messages sent from other devices. 481 * @param { SubscribeMessageOptions } options - Options. 482 * @syscap SystemCapability.ArkUI.ArkUI.Lite 483 * @since 5 484 * @deprecated since 8 485 */ 486 static subscribeMsg(options: SubscribeMessageOptions): void; 487 488 /** 489 * Cancel the listening for messages sent from other devices. 490 * @syscap SystemCapability.ArkUI.ArkUI.Lite 491 * @since 5 492 * @deprecated since 8 493 */ 494 static unsubscribeMsg(): void; 495} 496