1e41f4b71Sopenharmony_ci# @ohos.ability.featureAbility (FeatureAbility)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **FeatureAbility** module provides APIs that enable user interaction. You can use the APIs to start or terminate an ability, obtain a **dataAbilityHelper** object, obtain the window corresponding to the current ability, and connect to or disconnect from a ServiceAbility.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci> The APIs of this module can be used only in the FA model.
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Constraints
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ciThe APIs of the **FeatureAbility** module can be called only by PageAbilities.
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci## Modules to Import
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci```ts
17e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
18e41f4b71Sopenharmony_ci```
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci## featureAbility.startAbility
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_cistartAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<number>): void
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ciStarts an ability. This API uses an asynchronous callback to return the result.
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci> **NOTE**
27e41f4b71Sopenharmony_ci>
28e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci**Parameters**
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
37e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
38e41f4b71Sopenharmony_ci| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes   | Ability to start.|
39e41f4b71Sopenharmony_ci| callback  | AsyncCallback\<number>                   | Yes   | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **0**; otherwise, **err** is a non-zero value.     |
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci**Example**
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
44e41f4b71Sopenharmony_ci```ts
45e41f4b71Sopenharmony_ciimport { featureAbility, wantConstant } from '@kit.AbilityKit';
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_cifeatureAbility.startAbility(
48e41f4b71Sopenharmony_ci  {
49e41f4b71Sopenharmony_ci    want:
50e41f4b71Sopenharmony_ci    {
51e41f4b71Sopenharmony_ci      action: '',
52e41f4b71Sopenharmony_ci      entities: [''],
53e41f4b71Sopenharmony_ci      type: '',
54e41f4b71Sopenharmony_ci      flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
55e41f4b71Sopenharmony_ci      deviceId: '',
56e41f4b71Sopenharmony_ci      bundleName: 'com.example.myapplication',
57e41f4b71Sopenharmony_ci      /* In the FA model, abilityName consists of package and ability names. */
58e41f4b71Sopenharmony_ci      abilityName: 'com.example.myapplication.secondAbility',
59e41f4b71Sopenharmony_ci      uri: ''
60e41f4b71Sopenharmony_ci    },
61e41f4b71Sopenharmony_ci  },
62e41f4b71Sopenharmony_ci  (error, data) => {
63e41f4b71Sopenharmony_ci    if (error && error.code !== 0) {
64e41f4b71Sopenharmony_ci      console.error(`startAbility fail, error: ${JSON.stringify(error)}`);
65e41f4b71Sopenharmony_ci    } else {
66e41f4b71Sopenharmony_ci      console.log(`startAbility success, data: ${JSON.stringify(data)}`);
67e41f4b71Sopenharmony_ci    }
68e41f4b71Sopenharmony_ci  }
69e41f4b71Sopenharmony_ci);
70e41f4b71Sopenharmony_ci```
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci## featureAbility.startAbility
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_cistartAbility(parameter: StartAbilityParameter): Promise\<number>
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ciStarts an ability. This API uses a promise to return the result.
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci> **NOTE**
81e41f4b71Sopenharmony_ci>
82e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci**Parameters**
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
91e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
92e41f4b71Sopenharmony_ci| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes   | Ability to start.|
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci**Return value**
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci| Type                                      | Description     |
97e41f4b71Sopenharmony_ci| ---------------------------------------- | ------- |
98e41f4b71Sopenharmony_ci| Promise\<number> | Promise used to return the result. If the operation is successful, **0** is returned; otherwise, a non-zero value is returned.|
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci**Example**
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
103e41f4b71Sopenharmony_ci```ts
104e41f4b71Sopenharmony_ciimport { featureAbility, wantConstant } from '@kit.AbilityKit';
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_cifeatureAbility.startAbility(
107e41f4b71Sopenharmony_ci  {
108e41f4b71Sopenharmony_ci    want:
109e41f4b71Sopenharmony_ci    {
110e41f4b71Sopenharmony_ci      action: 'ohos.want.action.home',
111e41f4b71Sopenharmony_ci      entities: ['entity.system.home'],
112e41f4b71Sopenharmony_ci      type: 'MIMETYPE',
113e41f4b71Sopenharmony_ci      flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
114e41f4b71Sopenharmony_ci      deviceId: '',
115e41f4b71Sopenharmony_ci      bundleName: 'com.example.myapplication',
116e41f4b71Sopenharmony_ci      /* In the FA model, abilityName consists of package and ability names. */
117e41f4b71Sopenharmony_ci      abilityName: 'com.example.myapplication.secondAbility',
118e41f4b71Sopenharmony_ci      uri: ''
119e41f4b71Sopenharmony_ci    },
120e41f4b71Sopenharmony_ci  }
121e41f4b71Sopenharmony_ci).then((data) => {
122e41f4b71Sopenharmony_ci  console.info(`startAbility data: ${JSON.stringify(data)}`);
123e41f4b71Sopenharmony_ci});
124e41f4b71Sopenharmony_ci```
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci## featureAbility.acquireDataAbilityHelper<sup>7+</sup>
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ciacquireDataAbilityHelper(uri: string): DataAbilityHelper
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ciObtains a **dataAbilityHelper** object.
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ci> **NOTE**
133e41f4b71Sopenharmony_ci>
134e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
135e41f4b71Sopenharmony_ci> To access a DataAbility of another application, the target application must be configured with associated startup (**AssociateWakeUp** set to **true**).
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_ci**Parameters**
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ci| Name  | Type    | Mandatory  | Description          |
145e41f4b71Sopenharmony_ci| ---- | ------ | ---- | ------------ |
146e41f4b71Sopenharmony_ci| uri  | string | Yes   | URI of the file to open.|
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ci**Return value**
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci| Type               | Description                             |
151e41f4b71Sopenharmony_ci| ----------------- | ------------------------------- |
152e41f4b71Sopenharmony_ci| [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | A utility class used to help other abilities access the Data ability.|
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci**Example**
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
157e41f4b71Sopenharmony_ci```ts
158e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_cilet dataAbilityHelper = featureAbility.acquireDataAbilityHelper(
161e41f4b71Sopenharmony_ci  'dataability:///com.example.DataAbility'
162e41f4b71Sopenharmony_ci);
163e41f4b71Sopenharmony_ci```
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci## featureAbility.startAbilityForResult<sup>7+</sup>
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_cistartAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\<AbilityResult>): void
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ciStarts an ability. This API uses an asynchronous callback to return the result when the ability is terminated. The following situations may be possible for a started ability:
170e41f4b71Sopenharmony_ci - Normally, you can call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability. The result is returned to the caller.
171e41f4b71Sopenharmony_ci - If an exception occurs, for example, the ability is killed, an exception message, in which **resultCode** is **-1**, is returned to the caller.
172e41f4b71Sopenharmony_ci - If different applications call this API to start an ability that uses the singleton mode and then call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability, the normal result is returned to the last caller, and an exception message, in which **resultCode** is **-1**, is returned to others.
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci> **NOTE**
175e41f4b71Sopenharmony_ci>
176e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci**Parameters**
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
186e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
187e41f4b71Sopenharmony_ci| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes   | Ability to start.|
188e41f4b71Sopenharmony_ci| callback  | AsyncCallback\<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Yes   | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is an **AbilityResult** object; otherwise, err is an error object.     |
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci**Example**
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
193e41f4b71Sopenharmony_ci```ts
194e41f4b71Sopenharmony_ciimport { featureAbility, wantConstant } from '@kit.AbilityKit';
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_cifeatureAbility.startAbilityForResult(
197e41f4b71Sopenharmony_ci  {
198e41f4b71Sopenharmony_ci    want:
199e41f4b71Sopenharmony_ci    {
200e41f4b71Sopenharmony_ci      action: 'ohos.want.action.home',
201e41f4b71Sopenharmony_ci      entities: ['entity.system.home'],
202e41f4b71Sopenharmony_ci      type: 'MIMETYPE',
203e41f4b71Sopenharmony_ci      flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
204e41f4b71Sopenharmony_ci      deviceId: '',
205e41f4b71Sopenharmony_ci      bundleName: 'com.example.myapplication',
206e41f4b71Sopenharmony_ci      /* In the FA model, abilityName consists of package and ability names. */
207e41f4b71Sopenharmony_ci      abilityName: 'com.example.myapplication.secondAbility',
208e41f4b71Sopenharmony_ci      uri: ''
209e41f4b71Sopenharmony_ci    },
210e41f4b71Sopenharmony_ci  },
211e41f4b71Sopenharmony_ci  (error, data) => {
212e41f4b71Sopenharmony_ci    if (error && error.code !== 0) {
213e41f4b71Sopenharmony_ci      console.error(`startAbilityForResult fail, error: ${JSON.stringify(error)}`);
214e41f4b71Sopenharmony_ci    } else {
215e41f4b71Sopenharmony_ci      console.log(`startAbilityForResult success, data: ${JSON.stringify(data)}`);
216e41f4b71Sopenharmony_ci    }
217e41f4b71Sopenharmony_ci  }
218e41f4b71Sopenharmony_ci);
219e41f4b71Sopenharmony_ci```
220e41f4b71Sopenharmony_ci
221e41f4b71Sopenharmony_ci## featureAbility.startAbilityForResult<sup>7+</sup>
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_cistartAbilityForResult(parameter: StartAbilityParameter): Promise\<AbilityResult>
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ciStarts an ability. This API uses a promise to return the result when the ability is terminated. The following situations may be possible for a started ability:
226e41f4b71Sopenharmony_ci - Normally, you can call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability. The result is returned to the caller.
227e41f4b71Sopenharmony_ci - If an exception occurs, for example, the ability is killed, an exception message, in which **resultCode** is **-1**, is returned to the caller.
228e41f4b71Sopenharmony_ci - If different applications call this API to start an ability that uses the singleton mode and then call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability, the normal result is returned to the last caller, and an exception message, in which **resultCode** is **-1**, is returned to others.
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci> **NOTE**
231e41f4b71Sopenharmony_ci>
232e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
237e41f4b71Sopenharmony_ci**Parameters**
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description           |
240e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | ------------- |
241e41f4b71Sopenharmony_ci| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes   | Ability to start.|
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci**Return value**
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci| Type                                      | Description     |
246e41f4b71Sopenharmony_ci| ---------------------------------------- | ------- |
247e41f4b71Sopenharmony_ci| Promise\<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Promise used to return the result.|
248e41f4b71Sopenharmony_ci
249e41f4b71Sopenharmony_ci**Example**
250e41f4b71Sopenharmony_ci
251e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
252e41f4b71Sopenharmony_ci```ts
253e41f4b71Sopenharmony_ciimport { featureAbility, wantConstant } from '@kit.AbilityKit';
254e41f4b71Sopenharmony_ci
255e41f4b71Sopenharmony_cifeatureAbility.startAbilityForResult(
256e41f4b71Sopenharmony_ci  {
257e41f4b71Sopenharmony_ci    want:
258e41f4b71Sopenharmony_ci    {
259e41f4b71Sopenharmony_ci      action: 'ohos.want.action.home',
260e41f4b71Sopenharmony_ci      entities: ['entity.system.home'],
261e41f4b71Sopenharmony_ci      type: 'MIMETYPE',
262e41f4b71Sopenharmony_ci      flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
263e41f4b71Sopenharmony_ci      deviceId: '',
264e41f4b71Sopenharmony_ci      bundleName: 'com.example.myapplication',
265e41f4b71Sopenharmony_ci      /* In the FA model, abilityName consists of package and ability names. */
266e41f4b71Sopenharmony_ci      abilityName: 'com.example.myapplication.secondAbility',
267e41f4b71Sopenharmony_ci      uri: '',
268e41f4b71Sopenharmony_ci      parameters:
269e41f4b71Sopenharmony_ci      {
270e41f4b71Sopenharmony_ci        mykey0: 1111,
271e41f4b71Sopenharmony_ci        mykey1: [1, 2, 3],
272e41f4b71Sopenharmony_ci        mykey2: '[1, 2, 3]',
273e41f4b71Sopenharmony_ci        mykey3: 'xxxxxxxxxxxxxxxxxxxxxx',
274e41f4b71Sopenharmony_ci        mykey4: [1, 15],
275e41f4b71Sopenharmony_ci        mykey5: [false, true, false],
276e41f4b71Sopenharmony_ci        mykey6: ['aaaaaa', 'bbbbb', 'ccccccccccc'],
277e41f4b71Sopenharmony_ci        mykey7: true,
278e41f4b71Sopenharmony_ci      },
279e41f4b71Sopenharmony_ci    },
280e41f4b71Sopenharmony_ci  },
281e41f4b71Sopenharmony_ci).then((data) => {
282e41f4b71Sopenharmony_ci  console.info(`startAbilityForResult data: ${JSON.stringify(data)}`);
283e41f4b71Sopenharmony_ci});
284e41f4b71Sopenharmony_ci```
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ci## featureAbility.terminateSelfWithResult<sup>7+</sup>
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_citerminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\<void>): void
289e41f4b71Sopenharmony_ci
290e41f4b71Sopenharmony_ciTerminates this ability. This API uses an asynchronous callback to return the result. If the ability is started by calling [startAbilityForResult](#featureabilitystartabilityforresult7), the result is returned to the caller when **terminateSelfWithResult** is called. Otherwise, no result is returned to the caller when **terminateSelfWithResult** is called.
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_ci**Parameters**
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_ci| Name       | Type                             | Mandatory  | Description            |
299e41f4b71Sopenharmony_ci| --------- | ------------------------------- | ---- | -------------- |
300e41f4b71Sopenharmony_ci| parameter | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Yes   | Result returned after the ability is terminated.|
301e41f4b71Sopenharmony_ci| callback  | AsyncCallback\<void>            | Yes   | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.     |
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci**Example**
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
306e41f4b71Sopenharmony_ci```ts
307e41f4b71Sopenharmony_ciimport { featureAbility, wantConstant } from '@kit.AbilityKit';
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_cifeatureAbility.terminateSelfWithResult(
310e41f4b71Sopenharmony_ci  {
311e41f4b71Sopenharmony_ci    resultCode: 1,
312e41f4b71Sopenharmony_ci    want:
313e41f4b71Sopenharmony_ci    {
314e41f4b71Sopenharmony_ci      action: 'ohos.want.action.home',
315e41f4b71Sopenharmony_ci      entities: ['entity.system.home'],
316e41f4b71Sopenharmony_ci      type: 'MIMETYPE',
317e41f4b71Sopenharmony_ci      flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
318e41f4b71Sopenharmony_ci      deviceId: '',
319e41f4b71Sopenharmony_ci      bundleName: 'com.example.myapplication',
320e41f4b71Sopenharmony_ci      /* In the FA model, abilityName consists of package and ability names. */
321e41f4b71Sopenharmony_ci      abilityName: 'com.example.myapplication.secondAbility',
322e41f4b71Sopenharmony_ci      uri: '',
323e41f4b71Sopenharmony_ci      parameters: {
324e41f4b71Sopenharmony_ci        mykey0: 2222,
325e41f4b71Sopenharmony_ci        mykey1: [1, 2, 3],
326e41f4b71Sopenharmony_ci        mykey2: '[1, 2, 3]',
327e41f4b71Sopenharmony_ci        mykey3: 'ssssssssssssssssssssssssss',
328e41f4b71Sopenharmony_ci        mykey4: [1, 15],
329e41f4b71Sopenharmony_ci        mykey5: [false, true, false],
330e41f4b71Sopenharmony_ci        mykey6: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
331e41f4b71Sopenharmony_ci        mykey7: true,
332e41f4b71Sopenharmony_ci      }
333e41f4b71Sopenharmony_ci    },
334e41f4b71Sopenharmony_ci  },
335e41f4b71Sopenharmony_ci  (error) => {
336e41f4b71Sopenharmony_ci    console.error(`error: ${JSON.stringify(error)}`);
337e41f4b71Sopenharmony_ci  }
338e41f4b71Sopenharmony_ci);
339e41f4b71Sopenharmony_ci```
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci## featureAbility.terminateSelfWithResult<sup>7+</sup>
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_citerminateSelfWithResult(parameter: AbilityResult): Promise\<void>
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ciTerminates this ability. This API uses a promise to return the result. If the ability is started by calling [startAbilityForResult](#featureabilitystartabilityforresult7), the result is returned to the caller when **terminateSelfWithResult** is called. Otherwise, no result is returned to the caller when **terminateSelfWithResult** is called.
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
350e41f4b71Sopenharmony_ci
351e41f4b71Sopenharmony_ci**Parameters**
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_ci| Name       | Type                             | Mandatory  | Description           |
354e41f4b71Sopenharmony_ci| --------- | ------------------------------- | ---- | ------------- |
355e41f4b71Sopenharmony_ci| parameter | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Yes   | Result returned after the ability is terminated.|
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci**Return value**
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ci| Type            | Description             |
360e41f4b71Sopenharmony_ci| -------------- | --------------- |
361e41f4b71Sopenharmony_ci| Promise\<void> | Promise that returns no value.|
362e41f4b71Sopenharmony_ci
363e41f4b71Sopenharmony_ci**Example**
364e41f4b71Sopenharmony_ci
365e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
366e41f4b71Sopenharmony_ci```ts
367e41f4b71Sopenharmony_ciimport { featureAbility, wantConstant } from '@kit.AbilityKit';
368e41f4b71Sopenharmony_ci
369e41f4b71Sopenharmony_cifeatureAbility.terminateSelfWithResult(
370e41f4b71Sopenharmony_ci  {
371e41f4b71Sopenharmony_ci    resultCode: 1,
372e41f4b71Sopenharmony_ci    want:
373e41f4b71Sopenharmony_ci    {
374e41f4b71Sopenharmony_ci      action: 'ohos.want.action.home',
375e41f4b71Sopenharmony_ci      entities: ['entity.system.home'],
376e41f4b71Sopenharmony_ci      type: 'MIMETYPE',
377e41f4b71Sopenharmony_ci      flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
378e41f4b71Sopenharmony_ci      deviceId: '',
379e41f4b71Sopenharmony_ci      bundleName: 'com.example.myapplication',
380e41f4b71Sopenharmony_ci      /* In the FA model, abilityName consists of package and ability names. */
381e41f4b71Sopenharmony_ci      abilityName: 'com.example.myapplication.secondAbility',
382e41f4b71Sopenharmony_ci      uri:'',
383e41f4b71Sopenharmony_ci      parameters: {
384e41f4b71Sopenharmony_ci        mykey0: 2222,
385e41f4b71Sopenharmony_ci        mykey1: [1, 2, 3],
386e41f4b71Sopenharmony_ci        mykey2: '[1, 2, 3]',
387e41f4b71Sopenharmony_ci        mykey3: 'ssssssssssssssssssssssssss',
388e41f4b71Sopenharmony_ci        mykey4: [1, 15],
389e41f4b71Sopenharmony_ci        mykey5: [false, true, false],
390e41f4b71Sopenharmony_ci        mykey6: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
391e41f4b71Sopenharmony_ci        mykey7: true,
392e41f4b71Sopenharmony_ci      }
393e41f4b71Sopenharmony_ci    },
394e41f4b71Sopenharmony_ci  }
395e41f4b71Sopenharmony_ci).then(() => {
396e41f4b71Sopenharmony_ci  console.info('==========================>terminateSelfWithResult=======================>');
397e41f4b71Sopenharmony_ci});
398e41f4b71Sopenharmony_ci```
399e41f4b71Sopenharmony_ci
400e41f4b71Sopenharmony_ci## featureAbility.hasWindowFocus<sup>7+<sup>
401e41f4b71Sopenharmony_ci
402e41f4b71Sopenharmony_cihasWindowFocus(callback: AsyncCallback\<boolean>): void
403e41f4b71Sopenharmony_ci
404e41f4b71Sopenharmony_ciChecks whether the main window of this ability has the focus. This API uses an asynchronous callback to return the result.
405e41f4b71Sopenharmony_ci
406e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
407e41f4b71Sopenharmony_ci
408e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
409e41f4b71Sopenharmony_ci
410e41f4b71Sopenharmony_ci**Parameters**
411e41f4b71Sopenharmony_ci
412e41f4b71Sopenharmony_ci| Name      | Type                     | Mandatory  | Description                                      |
413e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | ---------------------------------------- |
414e41f4b71Sopenharmony_ci| callback | AsyncCallback\<boolean> | Yes   |Callback used to return the result.<br>If the main window has the focus, **true** is returned. Otherwise, **false** is returned.|
415e41f4b71Sopenharmony_ci
416e41f4b71Sopenharmony_ci**Example**
417e41f4b71Sopenharmony_ci
418e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
419e41f4b71Sopenharmony_ci```ts
420e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_cifeatureAbility.hasWindowFocus((error, data) => {
423e41f4b71Sopenharmony_ci  if (error && error.code !== 0) {
424e41f4b71Sopenharmony_ci    console.error(`hasWindowFocus fail, error: ${JSON.stringify(error)}`);
425e41f4b71Sopenharmony_ci  } else {
426e41f4b71Sopenharmony_ci    console.log(`hasWindowFocus success, data: ${JSON.stringify(data)}`);
427e41f4b71Sopenharmony_ci  }
428e41f4b71Sopenharmony_ci});
429e41f4b71Sopenharmony_ci```
430e41f4b71Sopenharmony_ci
431e41f4b71Sopenharmony_ci## featureAbility.hasWindowFocus<sup>7+<sup>
432e41f4b71Sopenharmony_ci
433e41f4b71Sopenharmony_cihasWindowFocus(): Promise\<boolean>
434e41f4b71Sopenharmony_ci
435e41f4b71Sopenharmony_ciChecks whether the main window of this ability has the focus. This API uses a promise to return the result.
436e41f4b71Sopenharmony_ci
437e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
438e41f4b71Sopenharmony_ci
439e41f4b71Sopenharmony_ci**Return value**
440e41f4b71Sopenharmony_ci
441e41f4b71Sopenharmony_ci| Type               | Description                                   |
442e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------- |
443e41f4b71Sopenharmony_ci| Promise\<boolean> | Promise used to return the result. If the main window has the focus, **true** is returned. Otherwise, **false** is returned.|
444e41f4b71Sopenharmony_ci
445e41f4b71Sopenharmony_ci**Example**
446e41f4b71Sopenharmony_ci
447e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
448e41f4b71Sopenharmony_ci```ts
449e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
450e41f4b71Sopenharmony_ci
451e41f4b71Sopenharmony_cifeatureAbility.hasWindowFocus().then((data) => {
452e41f4b71Sopenharmony_ci  console.info(`hasWindowFocus data: ${JSON.stringify(data)}`);
453e41f4b71Sopenharmony_ci});
454e41f4b71Sopenharmony_ci```
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ci## featureAbility.getWant
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_cigetWant(callback: AsyncCallback\<Want>): void
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_ciObtains the Want corresponding to the ability to start. This API uses an asynchronous callback to return the result.
461e41f4b71Sopenharmony_ci
462e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
463e41f4b71Sopenharmony_ci
464e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
465e41f4b71Sopenharmony_ci
466e41f4b71Sopenharmony_ci**Parameters**
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci| Name      | Type                           | Mandatory  | Description       |
469e41f4b71Sopenharmony_ci| -------- | ----------------------------- | ---- | --------- |
470e41f4b71Sopenharmony_ci| callback | AsyncCallback\<[Want](js-apis-application-want.md)> | Yes   | Callback used to return the Want.|
471e41f4b71Sopenharmony_ci
472e41f4b71Sopenharmony_ci**Example**
473e41f4b71Sopenharmony_ci
474e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
475e41f4b71Sopenharmony_ci```ts
476e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
477e41f4b71Sopenharmony_ci
478e41f4b71Sopenharmony_cifeatureAbility.getWant((error, data) => {
479e41f4b71Sopenharmony_ci  if (error && error.code !== 0) {
480e41f4b71Sopenharmony_ci    console.error(`getWant fail, error: ${JSON.stringify(error)}`);
481e41f4b71Sopenharmony_ci  } else {
482e41f4b71Sopenharmony_ci    console.log(`getWant success, data: ${JSON.stringify(data)}`);
483e41f4b71Sopenharmony_ci  }
484e41f4b71Sopenharmony_ci});
485e41f4b71Sopenharmony_ci```
486e41f4b71Sopenharmony_ci
487e41f4b71Sopenharmony_ci## featureAbility.getWant
488e41f4b71Sopenharmony_ci
489e41f4b71Sopenharmony_cigetWant(): Promise\<Want>
490e41f4b71Sopenharmony_ci
491e41f4b71Sopenharmony_ciObtains the Want corresponding to the ability to start. This API uses a promise to return the result.
492e41f4b71Sopenharmony_ci
493e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
494e41f4b71Sopenharmony_ci
495e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
496e41f4b71Sopenharmony_ci
497e41f4b71Sopenharmony_ci**Return value**
498e41f4b71Sopenharmony_ci
499e41f4b71Sopenharmony_ci| Type                     | Description              |
500e41f4b71Sopenharmony_ci| ----------------------- | ---------------- |
501e41f4b71Sopenharmony_ci| Promise\<[Want](js-apis-application-want.md)> | Promise used to return the Want.|
502e41f4b71Sopenharmony_ci
503e41f4b71Sopenharmony_ci**Example**
504e41f4b71Sopenharmony_ci
505e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
506e41f4b71Sopenharmony_ci```ts
507e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
508e41f4b71Sopenharmony_ci
509e41f4b71Sopenharmony_cifeatureAbility.getWant().then((data) => {
510e41f4b71Sopenharmony_ci  console.info(`getWant data: ${JSON.stringify(data)}`);
511e41f4b71Sopenharmony_ci});
512e41f4b71Sopenharmony_ci```
513e41f4b71Sopenharmony_ci
514e41f4b71Sopenharmony_ci## featureAbility.getContext
515e41f4b71Sopenharmony_ci
516e41f4b71Sopenharmony_cigetContext(): Context
517e41f4b71Sopenharmony_ci
518e41f4b71Sopenharmony_ciObtains the application context.
519e41f4b71Sopenharmony_ci
520e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
521e41f4b71Sopenharmony_ci
522e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
523e41f4b71Sopenharmony_ci
524e41f4b71Sopenharmony_ci**Return value**
525e41f4b71Sopenharmony_ci
526e41f4b71Sopenharmony_ci| Type     | Description        |
527e41f4b71Sopenharmony_ci| ------- | ---------- |
528e41f4b71Sopenharmony_ci| Context | Application context.|
529e41f4b71Sopenharmony_ci
530e41f4b71Sopenharmony_ci**Example**
531e41f4b71Sopenharmony_ci
532e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
533e41f4b71Sopenharmony_ci```ts
534e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
535e41f4b71Sopenharmony_ci
536e41f4b71Sopenharmony_cilet context = featureAbility.getContext();
537e41f4b71Sopenharmony_cicontext.getBundleName((error, data) => {
538e41f4b71Sopenharmony_ci  if (error && error.code !== 0) {
539e41f4b71Sopenharmony_ci    console.error(`getBundleName fail, error: ${JSON.stringify(error)}`);
540e41f4b71Sopenharmony_ci  } else {
541e41f4b71Sopenharmony_ci    console.log(`getBundleName success, data: ${JSON.stringify(data)}`);
542e41f4b71Sopenharmony_ci  }
543e41f4b71Sopenharmony_ci});
544e41f4b71Sopenharmony_ci```
545e41f4b71Sopenharmony_ci
546e41f4b71Sopenharmony_ci## featureAbility.terminateSelf<sup>7+</sup>
547e41f4b71Sopenharmony_ci
548e41f4b71Sopenharmony_citerminateSelf(callback: AsyncCallback\<void>): void
549e41f4b71Sopenharmony_ci
550e41f4b71Sopenharmony_ciTerminates this ability. This API uses an asynchronous callback to return the result.
551e41f4b71Sopenharmony_ci
552e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
553e41f4b71Sopenharmony_ci
554e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
555e41f4b71Sopenharmony_ci
556e41f4b71Sopenharmony_ci**Parameters**
557e41f4b71Sopenharmony_ci
558e41f4b71Sopenharmony_ci| Name      | Type                  | Mandatory  | Description      |
559e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | -------- |
560e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void> | Yes   | Callback used to return the result. If the ability is terminated, **err** is **undefined**; otherwise, **err** is an error object.|
561e41f4b71Sopenharmony_ci
562e41f4b71Sopenharmony_ci**Example**
563e41f4b71Sopenharmony_ci
564e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
565e41f4b71Sopenharmony_ci```ts
566e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
567e41f4b71Sopenharmony_ci
568e41f4b71Sopenharmony_cifeatureAbility.terminateSelf(
569e41f4b71Sopenharmony_ci  (error) => {
570e41f4b71Sopenharmony_ci    console.error(`error: ${JSON.stringify(error)}`);
571e41f4b71Sopenharmony_ci  }
572e41f4b71Sopenharmony_ci)
573e41f4b71Sopenharmony_ci```
574e41f4b71Sopenharmony_ci
575e41f4b71Sopenharmony_ci## featureAbility.terminateSelf<sup>7+</sup>
576e41f4b71Sopenharmony_ci
577e41f4b71Sopenharmony_citerminateSelf(): Promise\<void>
578e41f4b71Sopenharmony_ci
579e41f4b71Sopenharmony_ciTerminates this ability. This API uses a promise to return the result.
580e41f4b71Sopenharmony_ci
581e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
582e41f4b71Sopenharmony_ci
583e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
584e41f4b71Sopenharmony_ci
585e41f4b71Sopenharmony_ci**Return value**
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_ci| Type            | Description              |
588e41f4b71Sopenharmony_ci| -------------- | ---------------- |
589e41f4b71Sopenharmony_ci| Promise\<void> | Promise that returns no value.|
590e41f4b71Sopenharmony_ci
591e41f4b71Sopenharmony_ci**Example**
592e41f4b71Sopenharmony_ci
593e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
594e41f4b71Sopenharmony_ci```ts
595e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
596e41f4b71Sopenharmony_ci
597e41f4b71Sopenharmony_cifeatureAbility.terminateSelf().then(() => {
598e41f4b71Sopenharmony_ci  console.info('==========================>terminateSelf=======================>');
599e41f4b71Sopenharmony_ci});
600e41f4b71Sopenharmony_ci```
601e41f4b71Sopenharmony_ci
602e41f4b71Sopenharmony_ci## featureAbility.connectAbility<sup>7+</sup>
603e41f4b71Sopenharmony_ci
604e41f4b71Sopenharmony_ciconnectAbility(request: Want, options:ConnectOptions): number
605e41f4b71Sopenharmony_ci
606e41f4b71Sopenharmony_ciConnects this ability to a ServiceAbility.
607e41f4b71Sopenharmony_ci
608e41f4b71Sopenharmony_ci> **NOTE**
609e41f4b71Sopenharmony_ci>
610e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
611e41f4b71Sopenharmony_ci> To connect to a ServiceAbility of another application, the target application must be configured with associated startup (**AssociateWakeUp** set to **true**).
612e41f4b71Sopenharmony_ci
613e41f4b71Sopenharmony_ci
614e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
615e41f4b71Sopenharmony_ci
616e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
617e41f4b71Sopenharmony_ci
618e41f4b71Sopenharmony_ci**Parameters**
619e41f4b71Sopenharmony_ci
620e41f4b71Sopenharmony_ci| Name     | Type            | Mandatory  | Description                   |
621e41f4b71Sopenharmony_ci| ------- | -------------- | ---- | --------------------- |
622e41f4b71Sopenharmony_ci| request | [Want](js-apis-application-want.md)  | Yes   | ServiceAbility to connect.|
623e41f4b71Sopenharmony_ci| options | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Yes   | Connection options.            |
624e41f4b71Sopenharmony_ci
625e41f4b71Sopenharmony_ci**Return value**
626e41f4b71Sopenharmony_ci
627e41f4b71Sopenharmony_ci| Type    | Description                  |
628e41f4b71Sopenharmony_ci| ------ | -------------------- |
629e41f4b71Sopenharmony_ci| number | ID of the connected ServiceAbility. The ID starts from 0 and is incremented by 1 each time a connection is set up.|
630e41f4b71Sopenharmony_ci
631e41f4b71Sopenharmony_ci**Example**
632e41f4b71Sopenharmony_ci
633e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
634e41f4b71Sopenharmony_ci```ts
635e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
636e41f4b71Sopenharmony_ciimport { rpc } from '@kit.IPCKit';
637e41f4b71Sopenharmony_ci
638e41f4b71Sopenharmony_cilet connectId = featureAbility.connectAbility(
639e41f4b71Sopenharmony_ci  {
640e41f4b71Sopenharmony_ci    deviceId: '',
641e41f4b71Sopenharmony_ci    bundleName: 'com.ix.ServiceAbility',
642e41f4b71Sopenharmony_ci    abilityName: 'com.ix.ServiceAbility.ServiceAbilityA',
643e41f4b71Sopenharmony_ci  },
644e41f4b71Sopenharmony_ci  {
645e41f4b71Sopenharmony_ci    onConnect: (element, remote) => {
646e41f4b71Sopenharmony_ci      console.log(`ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}`);
647e41f4b71Sopenharmony_ci    },
648e41f4b71Sopenharmony_ci    onDisconnect: (element) => {
649e41f4b71Sopenharmony_ci      console.log(`ConnectAbility onDisconnect element.deviceId : ${element.deviceId}`)
650e41f4b71Sopenharmony_ci    },
651e41f4b71Sopenharmony_ci    onFailed: (code) => {
652e41f4b71Sopenharmony_ci      console.error(`featureAbilityTest ConnectAbility onFailed errCode : ${code}`)
653e41f4b71Sopenharmony_ci    },
654e41f4b71Sopenharmony_ci  },
655e41f4b71Sopenharmony_ci);
656e41f4b71Sopenharmony_ci```
657e41f4b71Sopenharmony_ci
658e41f4b71Sopenharmony_ci## featureAbility.disconnectAbility<sup>7+</sup>
659e41f4b71Sopenharmony_ci
660e41f4b71Sopenharmony_cidisconnectAbility(connection: number, callback:AsyncCallback\<void>): void
661e41f4b71Sopenharmony_ci
662e41f4b71Sopenharmony_ciDisconnects this ability from a specific ServiceAbility. This API uses an asynchronous callback to return the result.
663e41f4b71Sopenharmony_ci
664e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
665e41f4b71Sopenharmony_ci
666e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
667e41f4b71Sopenharmony_ci
668e41f4b71Sopenharmony_ci**Parameters**
669e41f4b71Sopenharmony_ci
670e41f4b71Sopenharmony_ci| Name        | Type                  | Mandatory  | Description                     |
671e41f4b71Sopenharmony_ci| ---------- | -------------------- | ---- | ----------------------- |
672e41f4b71Sopenharmony_ci| connection | number               | Yes   | ID of the ServiceAbility to disconnect.|
673e41f4b71Sopenharmony_ci| callback   | AsyncCallback\<void> | Yes   | Callback used to return the result. If the disconnection is successful, **err** is **undefined**. Otherwise, **err** is an error object.     |
674e41f4b71Sopenharmony_ci
675e41f4b71Sopenharmony_ci**Example**
676e41f4b71Sopenharmony_ci
677e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
678e41f4b71Sopenharmony_ci```ts
679e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
680e41f4b71Sopenharmony_ciimport { rpc } from '@kit.IPCKit';
681e41f4b71Sopenharmony_ci
682e41f4b71Sopenharmony_cilet connectId = featureAbility.connectAbility(
683e41f4b71Sopenharmony_ci  {
684e41f4b71Sopenharmony_ci    bundleName: 'com.ix.ServiceAbility',
685e41f4b71Sopenharmony_ci    abilityName: 'com.ix.ServiceAbility.ServiceAbilityA',
686e41f4b71Sopenharmony_ci  },
687e41f4b71Sopenharmony_ci  {
688e41f4b71Sopenharmony_ci    onConnect: (element, remote) => {
689e41f4b71Sopenharmony_ci      console.log(`ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}`);
690e41f4b71Sopenharmony_ci    },
691e41f4b71Sopenharmony_ci    onDisconnect: (element) => {
692e41f4b71Sopenharmony_ci      console.log(`ConnectAbility onDisconnect element.deviceId : ${element.deviceId}`);
693e41f4b71Sopenharmony_ci    },
694e41f4b71Sopenharmony_ci    onFailed: (code) => {
695e41f4b71Sopenharmony_ci      console.error(`featureAbilityTest ConnectAbility onFailed errCode : ${code}`);
696e41f4b71Sopenharmony_ci    },
697e41f4b71Sopenharmony_ci  },
698e41f4b71Sopenharmony_ci);
699e41f4b71Sopenharmony_ci
700e41f4b71Sopenharmony_cifeatureAbility.disconnectAbility(connectId, (error) => {
701e41f4b71Sopenharmony_ci  if (error && error.code !== 0) {
702e41f4b71Sopenharmony_ci    console.error(`disconnectAbility fail, connectId: ${connectId}, error: ${JSON.stringify(error)}`);
703e41f4b71Sopenharmony_ci  } else {
704e41f4b71Sopenharmony_ci    console.log(`disconnectAbility success, connectId: ${connectId}`);
705e41f4b71Sopenharmony_ci  }
706e41f4b71Sopenharmony_ci});
707e41f4b71Sopenharmony_ci```
708e41f4b71Sopenharmony_ci
709e41f4b71Sopenharmony_ci## featureAbility.disconnectAbility<sup>7+</sup>
710e41f4b71Sopenharmony_ci
711e41f4b71Sopenharmony_cidisconnectAbility(connection: number): Promise\<void>
712e41f4b71Sopenharmony_ci
713e41f4b71Sopenharmony_ciDisconnects this ability from a specific a ServiceAbility. This API uses a promise to return the result.
714e41f4b71Sopenharmony_ci
715e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
716e41f4b71Sopenharmony_ci
717e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
718e41f4b71Sopenharmony_ci
719e41f4b71Sopenharmony_ci**Parameters**
720e41f4b71Sopenharmony_ci
721e41f4b71Sopenharmony_ci| Name        | Type    | Mandatory  | Description                     |
722e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ----------------------- |
723e41f4b71Sopenharmony_ci| connection | number | Yes   | ID of the ServiceAbility to disconnect.|
724e41f4b71Sopenharmony_ci
725e41f4b71Sopenharmony_ci**Return value**
726e41f4b71Sopenharmony_ci
727e41f4b71Sopenharmony_ci| Type            | Description             |
728e41f4b71Sopenharmony_ci| -------------- | --------------- |
729e41f4b71Sopenharmony_ci| Promise\<void> | Promise that returns no value.|
730e41f4b71Sopenharmony_ci
731e41f4b71Sopenharmony_ci**Example**
732e41f4b71Sopenharmony_ci
733e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
734e41f4b71Sopenharmony_ci```ts
735e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
736e41f4b71Sopenharmony_ciimport { rpc } from '@kit.IPCKit';
737e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
738e41f4b71Sopenharmony_ci
739e41f4b71Sopenharmony_cilet connectId = featureAbility.connectAbility(
740e41f4b71Sopenharmony_ci  {
741e41f4b71Sopenharmony_ci    bundleName: 'com.ix.ServiceAbility',
742e41f4b71Sopenharmony_ci    abilityName: 'com.ix.ServiceAbility.ServiceAbilityA',
743e41f4b71Sopenharmony_ci  },
744e41f4b71Sopenharmony_ci  {
745e41f4b71Sopenharmony_ci    onConnect: (element, remote) => {
746e41f4b71Sopenharmony_ci      console.log(`ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}`);
747e41f4b71Sopenharmony_ci    },
748e41f4b71Sopenharmony_ci    onDisconnect: (element) => {
749e41f4b71Sopenharmony_ci      console.log(`ConnectAbility onDisconnect element.deviceId : ${element.deviceId}`);
750e41f4b71Sopenharmony_ci    },
751e41f4b71Sopenharmony_ci    onFailed: (code) => {
752e41f4b71Sopenharmony_ci      console.error(`featureAbilityTest ConnectAbility onFailed errCode : ${code}`);
753e41f4b71Sopenharmony_ci    },
754e41f4b71Sopenharmony_ci  },
755e41f4b71Sopenharmony_ci);
756e41f4b71Sopenharmony_ci
757e41f4b71Sopenharmony_cifeatureAbility.disconnectAbility(connectId).then(() => {
758e41f4b71Sopenharmony_ci  console.log('disconnectAbility success')
759e41f4b71Sopenharmony_ci}).catch((error: BusinessError)=>{
760e41f4b71Sopenharmony_ci  console.error(`featureAbilityTest result errCode : ${error.code}`);
761e41f4b71Sopenharmony_ci});
762e41f4b71Sopenharmony_ci```
763e41f4b71Sopenharmony_ci
764e41f4b71Sopenharmony_ci
765e41f4b71Sopenharmony_ci## featureAbility.getWindow<sup>7+</sup>
766e41f4b71Sopenharmony_ci
767e41f4b71Sopenharmony_cigetWindow(callback: AsyncCallback\<window.Window>): void
768e41f4b71Sopenharmony_ci
769e41f4b71Sopenharmony_ciObtains the window corresponding to this ability. This API uses an asynchronous callback to return the result.
770e41f4b71Sopenharmony_ci
771e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
772e41f4b71Sopenharmony_ci
773e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
774e41f4b71Sopenharmony_ci
775e41f4b71Sopenharmony_ci**Parameters**
776e41f4b71Sopenharmony_ci
777e41f4b71Sopenharmony_ci| Name    | Type                         | Mandatory| Description                         |
778e41f4b71Sopenharmony_ci| -------- | ----------------------------- | ---- | ----------------------------- |
779e41f4b71Sopenharmony_ci| callback | AsyncCallback\<[window.Window](../apis-arkui/js-apis-window.md#window)> | Yes  | Callback used to return the window.|
780e41f4b71Sopenharmony_ci
781e41f4b71Sopenharmony_ci**Example**
782e41f4b71Sopenharmony_ci
783e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
784e41f4b71Sopenharmony_ci```ts
785e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
786e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
787e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
788e41f4b71Sopenharmony_ci
789e41f4b71Sopenharmony_cifeatureAbility.getWindow((error: BusinessError, data: window.Window) => {
790e41f4b71Sopenharmony_ci  if (error && error.code !== 0) {
791e41f4b71Sopenharmony_ci    console.error(`getWindow fail, error: ${JSON.stringify(error)}`);
792e41f4b71Sopenharmony_ci  } else {
793e41f4b71Sopenharmony_ci    console.log(`getWindow success, data: ${typeof(data)}`);
794e41f4b71Sopenharmony_ci  }
795e41f4b71Sopenharmony_ci});
796e41f4b71Sopenharmony_ci```
797e41f4b71Sopenharmony_ci
798e41f4b71Sopenharmony_ci## featureAbility.getWindow<sup>7+</sup>
799e41f4b71Sopenharmony_ci
800e41f4b71Sopenharmony_cigetWindow(): Promise\<window.Window>
801e41f4b71Sopenharmony_ci
802e41f4b71Sopenharmony_ciObtains the window corresponding to this ability. This API uses a promise to return the result.
803e41f4b71Sopenharmony_ci
804e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
805e41f4b71Sopenharmony_ci
806e41f4b71Sopenharmony_ci**Note**: This API can be used only in the FA model.
807e41f4b71Sopenharmony_ci
808e41f4b71Sopenharmony_ci**Return value**
809e41f4b71Sopenharmony_ci
810e41f4b71Sopenharmony_ci| Type                   | Description                         |
811e41f4b71Sopenharmony_ci| ----------------------- | ----------------------------- |
812e41f4b71Sopenharmony_ci| Promise\<[window.Window](../apis-arkui/js-apis-window.md#window)> | Promise used to return the window.|
813e41f4b71Sopenharmony_ci
814e41f4b71Sopenharmony_ci**Example**
815e41f4b71Sopenharmony_ci
816e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
817e41f4b71Sopenharmony_ci```ts
818e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
819e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
820e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
821e41f4b71Sopenharmony_ci
822e41f4b71Sopenharmony_cifeatureAbility.getWindow().then((data: window.Window) => {
823e41f4b71Sopenharmony_ci  console.log(`getWindow success, data: ${typeof(data)}`);
824e41f4b71Sopenharmony_ci}).catch((error: BusinessError)=>{
825e41f4b71Sopenharmony_ci  console.error(`getWindow fail, error: ${JSON.stringify(error)}`);
826e41f4b71Sopenharmony_ci});
827e41f4b71Sopenharmony_ci```
828e41f4b71Sopenharmony_ci
829e41f4b71Sopenharmony_ci## AbilityWindowConfiguration<sup>7+</sup>
830e41f4b71Sopenharmony_ci
831e41f4b71Sopenharmony_ciDefines the window configuration corresponding to this ability. The configuration is obtained through **featureAbility.AbilityWindowConfiguration**.
832e41f4b71Sopenharmony_ci
833e41f4b71Sopenharmony_ci**Example**
834e41f4b71Sopenharmony_ci
835e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
836e41f4b71Sopenharmony_ci```ts
837e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
838e41f4b71Sopenharmony_ci
839e41f4b71Sopenharmony_cifeatureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED
840e41f4b71Sopenharmony_ci```
841e41f4b71Sopenharmony_ci
842e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
843e41f4b71Sopenharmony_ci
844e41f4b71Sopenharmony_ci| Name                                    | Value  | Description                                      |
845e41f4b71Sopenharmony_ci| ---------------------------------------- | ---- | ---------------------------------------- |
846e41f4b71Sopenharmony_ci| WINDOW_MODE_UNDEFINED       | 0    | The PageAbility is in an undefined window display mode.|
847e41f4b71Sopenharmony_ci| WINDOW_MODE_FULLSCREEN      | 1    | The PageAbility is in full screen mode.   |
848e41f4b71Sopenharmony_ci| WINDOW_MODE_SPLIT_PRIMARY   | 100  | The left screen in horizontal direction or the upper screen in vertical direction is the primary window.|
849e41f4b71Sopenharmony_ci| WINDOW_MODE_SPLIT_SECONDARY | 101  | The right screen in horizontal direction or the lower screen in vertical direction is the secondary window.|
850e41f4b71Sopenharmony_ci| WINDOW_MODE_FLOATING        | 102  | The PageAbility is displayed in floating window mode.|
851e41f4b71Sopenharmony_ci
852e41f4b71Sopenharmony_ci
853e41f4b71Sopenharmony_ci## AbilityStartSetting<sup>7+</sup>
854e41f4b71Sopenharmony_ci
855e41f4b71Sopenharmony_ciDefines the window property corresponding to this ability. The **abilityStartSetting** property is an object defined in the format of [**key: string]: any**, where **key** is an enumerated value of **AbilityStartSetting** and **value** is an enumerated value of **AbilityWindowConfiguration**.
856e41f4b71Sopenharmony_ci
857e41f4b71Sopenharmony_ciThe value is obtained through **featureAbility.AbilityStartSetting**.
858e41f4b71Sopenharmony_ci
859e41f4b71Sopenharmony_ci**Example**
860e41f4b71Sopenharmony_ci
861e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
862e41f4b71Sopenharmony_ci```ts
863e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
864e41f4b71Sopenharmony_ci
865e41f4b71Sopenharmony_cifeatureAbility.AbilityStartSetting.BOUNDS_KEY
866e41f4b71Sopenharmony_ci```
867e41f4b71Sopenharmony_ci
868e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
869e41f4b71Sopenharmony_ci
870e41f4b71Sopenharmony_ci| Name                          | Value             | Description                                      |
871e41f4b71Sopenharmony_ci| ---------------------------- | --------------- | ---------------------------------------- |
872e41f4b71Sopenharmony_ci| BOUNDS_KEY      | 'abilityBounds' | Ability window size.|
873e41f4b71Sopenharmony_ci| WINDOW_MODE_KEY | 'windowMode'    | Ability window display mode.|
874e41f4b71Sopenharmony_ci| DISPLAY_ID_KEY  | 'displayId'     | Display device ID.|
875e41f4b71Sopenharmony_ci
876e41f4b71Sopenharmony_ci## ErrorCode<sup>7+</sup>
877e41f4b71Sopenharmony_ci
878e41f4b71Sopenharmony_ciEnumerates the error codes that may be returned when an ability is started.
879e41f4b71Sopenharmony_ci
880e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
881e41f4b71Sopenharmony_ci
882e41f4b71Sopenharmony_ci| Name                            | Value   | Description                                      |
883e41f4b71Sopenharmony_ci| ------------------------------ | ---- | ---------------------------------------- |
884e41f4b71Sopenharmony_ci| NO_ERROR         | 0    | No error.  |
885e41f4b71Sopenharmony_ci| INVALID_PARAMETER | -1   | Invalid parameter.|
886e41f4b71Sopenharmony_ci| ABILITY_NOT_FOUND | -2   | The ability is not found.|
887e41f4b71Sopenharmony_ci| PERMISSION_DENY   | -3   | Permission denied.  |
888e41f4b71Sopenharmony_ci
889e41f4b71Sopenharmony_ci## DataAbilityOperationType<sup>7+</sup>
890e41f4b71Sopenharmony_ci
891e41f4b71Sopenharmony_ciEnumerates the operation types of a DataAbility. The DataAbility can use an enumerated value to specify the operation type when operating data in batches.
892e41f4b71Sopenharmony_ci
893e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
894e41f4b71Sopenharmony_ci
895e41f4b71Sopenharmony_ci| Name                      | Value   | Description                                      |
896e41f4b71Sopenharmony_ci| ------------------------ | ---- | ---------------------------------------- |
897e41f4b71Sopenharmony_ci| TYPE_INSERT | 1    | Insert operation.|
898e41f4b71Sopenharmony_ci| TYPE_UPDATE | 2    | Update operation.|
899e41f4b71Sopenharmony_ci| TYPE_DELETE | 3    | Deletion operation.|
900e41f4b71Sopenharmony_ci| TYPE_ASSERT | 4    | Assert operation.|
901