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