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