• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2024 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
21/**
22 * Want is the basic communication component of the system.
23 *
24 * @syscap SystemCapability.Ability.AbilityBase
25 * @since 9
26 */
27/**
28 * Want is the basic communication component of the system.
29 *
30 * @syscap SystemCapability.Ability.AbilityBase
31 * @crossplatform
32 * @since 10
33 */
34/**
35 * Want is a carrier for information transfer between objects (application components).
36 * Want can be used as a parameter of startAbility to specify a startup target and information that needs to be carried
37 * during startup, for example, bundleName and abilityName, which respectively indicate the bundle name of the target
38 * ability and the ability name in the bundle.
39 * When UIAbilityA needs to start UIAbilityB and transfer some data to UIAbilityB, it can use Want a carrier to
40 * transfer the data.
41 *
42 * @syscap SystemCapability.Ability.AbilityBase
43 * @crossplatform
44 * @atomicservice
45 * @since arkts {'1.1':'11', '1.2':'20'}
46 * @arkts 1.1&1.2
47 */
48export default class Want {
49  /**
50   * bundle name
51   *
52   * @type { ?string }
53   * @syscap SystemCapability.Ability.AbilityBase
54   * @since 9
55   */
56  /**
57   * bundle name
58   *
59   * @syscap SystemCapability.Ability.AbilityBase
60   * @crossplatform
61   * @since 10
62   */
63  /**
64   * Bundle name of the ability.
65   *
66   * @type { ?string }
67   * @syscap SystemCapability.Ability.AbilityBase
68   * @crossplatform
69   * @atomicservice
70   * @since arkts {'1.1':'11', '1.2':'20'}
71   * @arkts 1.1&1.2
72   */
73  bundleName?: string;
74
75  /**
76   * ability name
77   *
78   * @type { ?string }
79   * @syscap SystemCapability.Ability.AbilityBase
80   * @since 9
81   */
82  /**
83   * ability name
84   *
85   * @syscap SystemCapability.Ability.AbilityBase
86   * @crossplatform
87   * @since 10
88   */
89  /**
90   * Name of the ability.
91   * If both bundleName and abilityName are specified in a Want object, the Want object can match a specific ability.
92   *
93   * <p>**NOTE**:
94   * <br>The value of abilityName must be unique in an application.
95   * </p>
96   *
97   * @type { ?string }
98   * @syscap SystemCapability.Ability.AbilityBase
99   * @crossplatform
100   * @atomicservice
101   * @since arkts {'1.1':'11', '1.2':'20'}
102   * @arkts 1.1&1.2
103   */
104  abilityName?: string;
105
106  /**
107   * device id
108   *
109   * @type { ?string }
110   * @syscap SystemCapability.Ability.AbilityBase
111   * @since 9
112   */
113  /**
114   * ID of the device running the ability.
115   *
116   * <p>**NOTE**:
117   * <br>If this field is unspecified, the local device is used.
118   * </p>
119   *
120   * @type { ?string }
121   * @syscap SystemCapability.Ability.AbilityBase
122   * @atomicservice
123   * @since arkts {'1.1':'11', '1.2':'20'}
124   * @arkts 1.1&1.2
125   */
126  deviceId?: string;
127
128  /**
129   * The description of a URI in a Want.
130   *
131   * @type { ?string }
132   * @syscap SystemCapability.Ability.AbilityBase
133   * @since 9
134   */
135  /**
136   * Data carried.
137   * This field is used together with type to specify the data type.
138   * If uri is specified in a Want, the Want will match the specified URI information, including scheme,
139   * schemeSpecificPart, authority, and path.
140   *
141   * @type { ?string }
142   * @syscap SystemCapability.Ability.AbilityBase
143   * @atomicservice
144   * @since arkts {'1.1':'11', '1.2':'20'}
145   * @arkts 1.1&1.2
146   */
147  uri?: string;
148
149  /**
150   * The description of the type in this Want.
151   *
152   * @type { ?string }
153   * @syscap SystemCapability.Ability.AbilityBase
154   * @since 9
155   */
156  /**
157   * The description of the type in this Want.
158   *
159   * @type { ?string }
160   * @syscap SystemCapability.Ability.AbilityBase
161   * @atomicservice
162   * @since 11
163   */
164  /**
165   * MIME type, that is, the type of the file to open, for example, 'text/xml' and 'image/*'.
166   *
167   * <p>**NOTE**:
168   * <br>For details about the MIME type definition,
169   * see {@link https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com}.
170   * </p>
171   *
172   * @type { ?string }
173   * @syscap SystemCapability.Ability.AbilityBase
174   * @crossplatform
175   * @atomicservice
176   * @since arkts {'1.1':'18', '1.2':'20'}
177   * @arkts 1.1&1.2
178   */
179  type?: string;
180
181  /**
182   * The options of the flags in this Want.
183   *
184   * @type { ?number }
185   * @syscap SystemCapability.Ability.AbilityBase
186   * @since 9
187   */
188  /**
189   * How the Want object will be handled. By default, a number is passed in.
190   * For example, wantConstant.Flags.FLAG_ABILITY_CONTINUATION specifies whether to start the ability in cross-device
191   * migration scenarios.
192   *
193   * @type { ?number }
194   * @syscap SystemCapability.Ability.AbilityBase
195   * @atomicservice
196   * @since 11
197   */
198  flags?: number;
199
200  /**
201   * The description of an action in an want.
202   *
203   * @type { ?string }
204   * @syscap SystemCapability.Ability.AbilityBase
205   * @since 9
206   */
207  /**
208   * Action to take, such as viewing and sharing application details.
209   * In implicit Want, you can define this field and use it together with uri or parameters to specify the operation
210   * to be performed on the data.
211   *
212   * @type { ?string }
213   * @syscap SystemCapability.Ability.AbilityBase
214   * @atomicservice
215   * @since arkts {'1.1':'11', '1.2':'20'}
216   * @arkts 1.1&1.2
217   */
218  action?: string;
219
220  /**
221   * The description of the WantParams object in an Want
222   *
223   * @type { ?object }
224   * @syscap SystemCapability.Ability.AbilityBase
225   * @since 9
226   */
227  /**
228   * The description of the WantParams object in an Want
229   *
230   * @type { ?object }
231   * @syscap SystemCapability.Ability.AbilityBase
232   * @crossplatform
233   * @since 10
234   */
235  /**
236   * List of parameters in the Want object.
237   *
238   * <p>**NOTE**:
239   * <br>1. The values of the following keys are assigned by the system. Manual settings do not take effect, since the
240   * system automatically changes the values to the actual values during data transfer.
241   * -ohos.aafwk.param.callerPid: PID of the caller. The value is a string.
242   * -ohos.aafwk.param.callerBundleName: bundle name of the caller. The value is a string.
243   * -ohos.aafwk.param.callerAbilityName: ability name of the caller. The value is a string.
244   * -ohos.aafwk.param.callerNativeName: process name of the caller when the native method is called. The value is
245   * a string.
246   * -ohos.aafwk.param.callerAppId: appId of the caller. The value is a string.
247   * -ohos.aafwk.param.callerAppIdentifier: appIdentifier of the caller. The value is a string.
248   * -ohos.aafwk.param.callerToken: token of the caller. The value is a string.
249   * -ohos.aafwk.param.callerUid: UID in BundleInfo, that is, the application's UID in the bundle information. The
250   * value is a number.
251   * -ohos.param.callerAppCloneIndex: clone index of the caller. The value is of the numeric type.
252   * -component.startup.newRules: enabled status of the new control rule. The value is of the Boolean type.
253   * -moduleName: module name of the caller. The value is a string.
254   * -ability.params.backToOtherMissionStack: support for redirection back across mission stacks. The value is of
255   * the Boolean type.
256   * -ohos.ability.params.abilityRecoveryRestart: support for ability restart upon fault recovery. The value is of
257   * the Boolean type.
258   * -ohos.extra.param.key.contentTitle: title that can be shared by the atomic service. The value is a string.
259   * -ohos.extra.param.key.shareAbstract: content that can be shared by the atomic service. The value is a string.
260   * -ohos.extra.param.key.shareUrl: URL of the content that can be shared by the atomic service. The value is
261   * a string.
262   * -ohos.extra.param.key.supportContinuePageStack: support for migration of page stack information during
263   * cross-device migration. The value is of the Boolean type. The default value is true, indicating that page stack
264   * information is automatically migrated.
265   * -ohos.extra.param.key.supportContinueSourceExit: support for application exit on the source device during
266   * cross-device migration. The value is of the Boolean type. The default value is true, indicating that the
267   * application on the source device automatically exits.
268   * -ohos.extra.param.key.showMode: mode to show the atomic service startup. The value is an enumerated value of
269   * wantConstant.ShowMode.
270   * -ohos.dlp.params.sandbox: available only for DLP files. This key is involved only in system applications.
271   * -ohos.dlp.params.bundleName: bundle name of DLP. The value is a string. This key is involved only in system
272   * applications.
273   * -ohos.dlp.params.moduleName: module name of DLP. The value is a string. This key is involved only in system
274   * applications.
275   * -ohos.dlp.params.abilityName: ability name of DLP. The value is a string. This key is involved only in system
276   * applications.
277   * -ohos.dlp.params.index: DLP index. The value is a number. This key is involved only in system applications.
278   * -ohos.ability.params.asssertFaultSessionId: session ID of the fault assertion. The value is a string. This key
279   * is involved only in system applications.
280   *
281   * <br>2. The following keys are defined by the system, and their values need to be manually assigned.
282   * -ability.params.stream: File URIs to be authorized to the target ability. The value is a file URI array of the
283   * string type.
284   * -ohos.extra.param.key.appCloneIndex: index of the application clone.
285   *
286   * <br>3. In addition to the foregoing cases, applications may further agree on the key-value pairs to transfer.
287   * </p>
288   *
289   * <p>**NOTE**:
290   * <br>For details about the constants of Params in want, see wantConstant.
291   * <br>Note that a maximum of 200 KB data that can be transferred by using WantParams. If the data volume exceeds
292   * 200 KB, transfer data in WriteRawDataBuffer or uri mode.
293   * <br>The values of parameters must be of the following basic data types: String, Number, Boolean, Object,
294   * undefined, and null. Functions in an object cannot be transferred.
295   * </p>
296   *
297   * @type { ?Record<string, Object> }
298   * @syscap SystemCapability.Ability.AbilityBase
299   * @crossplatform
300   * @atomicservice
301   * @since arkts {'1.1':'11', '1.2':'20'}
302   * @arkts 1.1&1.2
303   */
304  parameters?: Record<string, Object>;
305
306  /**
307   * The description of a entities in a Want.
308   *
309   * @type { ?Array<string> }
310   * @syscap SystemCapability.Ability.AbilityBase
311   * @since 9
312   */
313  /**
314   * Additional category information (such as browser and video player) of the ability.
315   * It is a supplement to the action field for implicit Want. and is used to filter ability types.
316   *
317   * @type { ?Array<string> }
318   * @syscap SystemCapability.Ability.AbilityBase
319   * @atomicservice
320   * @since arkts {'1.1':'11', '1.2':'20'}
321   * @arkts 1.1&1.2
322   */
323  entities?: Array<string>;
324
325  /**
326   * The description of an module name in an want.
327   *
328   * @type { ?string }
329   * @syscap SystemCapability.Ability.AbilityBase
330   * @since 9
331   */
332  /**
333   * The description of an module name in an want.
334   *
335   * @syscap SystemCapability.Ability.AbilityBase
336   * @crossplatform
337   * @since 10
338   */
339  /**
340   * Name of the module to which the ability belongs.
341   *
342   * <p>**NOTE**:
343   * <br>If the ability belongs to a HAR module, moduleName must be set to the name of the HAP or HSP module that
344   * depends on this HAR.
345   * </p>
346   *
347   * @type { ?string }
348   * @syscap SystemCapability.Ability.AbilityBase
349   * @crossplatform
350   * @atomicservice
351   * @since arkts {'1.1':'11', '1.2':'20'}
352   * @arkts 1.1&1.2
353   */
354  moduleName?: string;
355
356  /**
357   * Want file descriptor (FD), which is used to identify the Want file opened.
358   * You can obtain the FD from fs.open. When the FD is no longer needed, you must call fs.close to destroy the FD in a
359   * timely manner to prevent FD leakage.
360   *
361   * @type { ?Record<string, number> }
362   * @readonly
363   * @syscap SystemCapability.Ability.AbilityBase
364   * @atomicservice
365   * @since arkts {'1.1':'15', '1.2':'20'}
366   * @arkts 1.1&1.2
367   */
368  readonly fds?: Record<string, number>;
369}
370