js-apis-Context.md 41.2 KB
Newer Older
W
wusongqing 已提交
1
# Context
W
wusongqing 已提交
2

3 4
The **Context** module provides context for abilities or applications. It allows access to application-specific resources, as well as permission requests and verification.

W
wusongqing 已提交
5
> **NOTE**
6
>
7
> 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.  
W
wusongqing 已提交
8
> The APIs of this module can be used only in the FA model.
W
wusongqing 已提交
9

W
wusongqing 已提交
10 11
## Usage

12
The **Context** object is created in a **featureAbility** and returned through its **getContext()** API. Therefore, you must import the **@ohos.ability.featureAbility** package before using the **Context** module. An example is as follows:
W
wusongqing 已提交
13 14 15 16 17 18 19

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getOrCreateLocalDir()
```

W
wusongqing 已提交
20
## Context.getOrCreateLocalDir<sup>7+</sup>
W
wusongqing 已提交
21

W
wusongqing 已提交
22
getOrCreateLocalDir(callback: AsyncCallback\<string>): void
W
wusongqing 已提交
23

W
wusongqing 已提交
24
Obtains the local root directory of the application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
25

W
wusongqing 已提交
26
If this API is called for the first time, a root directory will be created.
W
wusongqing 已提交
27

W
wusongqing 已提交
28
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
29

W
wusongqing 已提交
30
**Parameters**
W
wusongqing 已提交
31

32 33 34
| Name      | Type                    | Mandatory  | Description           |
| -------- | ---------------------- | ---- | ------------- |
| callback | AsyncCallback\<string> | Yes   | Callback used to return the local root directory.|
W
wusongqing 已提交
35

W
wusongqing 已提交
36
**Example**
W
wusongqing 已提交
37 38 39 40 41 42 43 44 45 46 47

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getOrCreateLocalDir((err, data)=>{
    console.info("data=" + data);
})
```



W
wusongqing 已提交
48
## Context.getOrCreateLocalDir<sup>7+</sup>
W
wusongqing 已提交
49

W
wusongqing 已提交
50
getOrCreateLocalDir(): Promise\<string>
W
wusongqing 已提交
51

W
wusongqing 已提交
52
Obtains the local root directory of the application. This API uses a promise to return the result.
W
wusongqing 已提交
53

W
wusongqing 已提交
54
If this API is called for the first time, a root directory will be created.
W
wusongqing 已提交
55

W
wusongqing 已提交
56
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
57

W
wusongqing 已提交
58
**Return value**
W
wusongqing 已提交
59

60 61
| Type              | Description         |
| ---------------- | ----------- |
W
wusongqing 已提交
62
| Promise\<string> | Promise used to return the local root directory.|
W
wusongqing 已提交
63

W
wusongqing 已提交
64
**Example**
W
wusongqing 已提交
65 66 67 68

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
69 70
context.getOrCreateLocalDir().then((data) => {
    console.info("data=" + data);
W
wusongqing 已提交
71 72 73 74 75
});
```



W
wusongqing 已提交
76
## Context.verifyPermission<sup>7+</sup>
W
wusongqing 已提交
77

W
wusongqing 已提交
78
verifyPermission(permission: string, options: PermissionOptions, callback: AsyncCallback\<number>): void
W
wusongqing 已提交
79

W
wusongqing 已提交
80
Verifies whether a specific PID and UID have the given permission. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
81

W
wusongqing 已提交
82
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
83

W
wusongqing 已提交
84
**Parameters**
W
wusongqing 已提交
85

86 87 88 89 90
| Name        | Type                                     | Mandatory  | Description                  |
| ---------- | --------------------------------------- | ---- | -------------------- |
| permission | string                                  | Yes   | Name of the permission to verify.            |
| options    | [PermissionOptions](#permissionoptions) | Yes   | Permission options.               |
| callback   | AsyncCallback\<number>                  | Yes   | Callback used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.|
W
wusongqing 已提交
91

W
wusongqing 已提交
92
**Example**
W
wusongqing 已提交
93 94 95 96 97

```js
import featureAbility from '@ohos.ability.featureAbility'
import bundle from '@ohos.bundle'
var context = featureAbility.getContext();
W
wusongqing 已提交
98 99
bundle.getBundleInfo('com.context.test', 1, (err,datainfo) =>{
	context.verifyPermission("com.example.permission", {uid:datainfo.uid});
W
wusongqing 已提交
100
});
W
wusongqing 已提交
101 102 103 104
```



W
wusongqing 已提交
105
## Context.verifyPermission<sup>7+</sup>
W
wusongqing 已提交
106

W
wusongqing 已提交
107
verifyPermission(permission: string, callback: AsyncCallback\<number>): void
W
wusongqing 已提交
108

W
wusongqing 已提交
109
Verifies whether the current PID and UID have the given permission. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
110

W
wusongqing 已提交
111
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
112

W
wusongqing 已提交
113
**Parameters**
W
wusongqing 已提交
114

115 116 117 118
| Name        | Type                    | Mandatory  | Description                  |
| ---------- | ---------------------- | ---- | -------------------- |
| permission | string                 | Yes   | Name of the permission to verify.            |
| callback   | AsyncCallback\<number> | Yes   | Callback used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.|
W
wusongqing 已提交
119

W
wusongqing 已提交
120
**Example**
W
wusongqing 已提交
121 122 123 124 125 126 127

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.verifyPermission("com.example.permission")
```

W
wusongqing 已提交
128
## Context.verifyPermission<sup>7+</sup>
W
wusongqing 已提交
129

W
wusongqing 已提交
130
verifyPermission(permission: string, options?: PermissionOptions): Promise\<number>
W
wusongqing 已提交
131

W
wusongqing 已提交
132
Verifies whether a specific PID and UID have the given permission. This API uses a promise to return the result.
W
wusongqing 已提交
133

W
wusongqing 已提交
134
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
135

W
wusongqing 已提交
136
**Parameters**
W
wusongqing 已提交
137

138 139 140 141
| Name        | Type                                     | Mandatory  | Description      |
| ---------- | --------------------------------------- | ---- | -------- |
| permission | string                                  | Yes   | Name of the permission to verify.|
| options    | [PermissionOptions](#permissionoptions) | No   | Permission options.   |
W
wusongqing 已提交
142

W
wusongqing 已提交
143
**Return value**
W
wusongqing 已提交
144

145 146
| Type              | Description                                |
| ---------------- | ---------------------------------- |
147
| Promise\<number> | Promise used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.|
W
wusongqing 已提交
148

W
wusongqing 已提交
149
**Example**
W
wusongqing 已提交
150 151 152 153

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
154
var Permission = {pid:1};
W
wusongqing 已提交
155 156 157
context.verifyPermission('com.context.permission',Permission).then((data) => {
    console.info("======================>verifyPermissionCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
W
wusongqing 已提交
158 159 160 161 162
});
```



W
wusongqing 已提交
163
## Context.requestPermissionsFromUser<sup>7+</sup>
W
wusongqing 已提交
164

W
wusongqing 已提交
165
requestPermissionsFromUser(permissions: Array\<string>, requestCode: number, resultCallback: AsyncCallback<[PermissionRequestResult](#permissionrequestresult)>): void
W
wusongqing 已提交
166

W
wusongqing 已提交
167
Requests certain permissions from the system. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
168

W
wusongqing 已提交
169
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
170

W
wusongqing 已提交
171
**Parameters**
W
wusongqing 已提交
172

173 174 175 176 177
| Name            | Type                                      | Mandatory  | Description                                 |
| -------------- | ---------------------------------------- | ---- | ----------------------------------- |
| permissions    | Array\<string>                           | Yes   | Permissions to request. This parameter cannot be **null**.             |
| requestCode    | number                                   | Yes   | Request code to be passed to **PermissionRequestResult**.|
| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | Yes   | Permission request result.                          |
W
wusongqing 已提交
178

W
wusongqing 已提交
179
**Example**
W
wusongqing 已提交
180 181 182 183

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
184
context.requestPermissionsFromUser(
W
wusongqing 已提交
185 186 187 188 189
    ["com.example.permission1",
     "com.example.permission2",
     "com.example.permission3",
     "com.example.permission4",
     "com.example.permission5"],
W
wusongqing 已提交
190 191 192 193
    1,(err, data)=>{
        console.info("====>requestdata====>" + JSON.stringify(data));
        console.info("====>requesterrcode====>" + JSON.stringify(err.code));
    }
W
wusongqing 已提交
194 195 196 197 198
)
```



W
wusongqing 已提交
199
## Context.getApplicationInfo<sup>7+</sup>
W
wusongqing 已提交
200

W
wusongqing 已提交
201
getApplicationInfo(callback: AsyncCallback\<ApplicationInfo>): void
W
wusongqing 已提交
202

W
wusongqing 已提交
203
Obtains information about the current application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
204

W
wusongqing 已提交
205
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
206

W
wusongqing 已提交
207
**Parameters**
W
wusongqing 已提交
208

209 210 211
| Name      | Type                             | Mandatory  | Description          |
| -------- | ------------------------------- | ---- | ------------ |
| callback | AsyncCallback\<ApplicationInfo> | Yes   | Callback used to return the application information.|
W
wusongqing 已提交
212

W
wusongqing 已提交
213
**Example**
W
wusongqing 已提交
214 215 216 217 218 219 220 221 222

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getApplicationInfo()
```



W
wusongqing 已提交
223
## Context.getApplicationInfo<sup>7+</sup>
W
wusongqing 已提交
224

W
wusongqing 已提交
225
getApplicationInfo(): Promise\<ApplicationInfo>
W
wusongqing 已提交
226

W
wusongqing 已提交
227
Obtains information about the current application. This API uses a promise to return the result.
W
wusongqing 已提交
228

W
wusongqing 已提交
229
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
230

W
wusongqing 已提交
231
**Return value**
W
wusongqing 已提交
232

233 234
| Type                       | Description       |
| ------------------------- | --------- |
W
wusongqing 已提交
235
| Promise\<ApplicationInfo> | Promise used to return the application information.|
W
wusongqing 已提交
236

W
wusongqing 已提交
237
**Example**
W
wusongqing 已提交
238 239 240 241

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
242 243 244
context.getApplicationInfo().then((data) => {
    console.info("=====================>getApplicationInfoCallback===================>");
    console.info("====>data====>" + JSON.stringify(data));
W
wusongqing 已提交
245 246 247 248 249
});
```



W
wusongqing 已提交
250
## Context.getBundleName<sup>7+</sup>
W
wusongqing 已提交
251

W
wusongqing 已提交
252
getBundleName(callback: AsyncCallback\<string>): void
W
wusongqing 已提交
253

254
Obtains the bundle name of this ability. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
255

W
wusongqing 已提交
256
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
257

W
wusongqing 已提交
258
**Parameters**
W
wusongqing 已提交
259

260 261 262
| Name      | Type                    | Mandatory  | Description                |
| -------- | ---------------------- | ---- | ------------------ |
| callback | AsyncCallback\<string> | Yes   | Callback used to return the bundle name.|
W
wusongqing 已提交
263

W
wusongqing 已提交
264
**Example**
W
wusongqing 已提交
265 266 267 268 269 270 271 272 273

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getBundleName()
```



W
wusongqing 已提交
274
## Context.getBundleName<sup>7+</sup>
W
wusongqing 已提交
275

W
wusongqing 已提交
276
getBundleName(): Promise\<string>
W
wusongqing 已提交
277

278
Obtains the bundle name of this ability. This API uses a promise to return the result.
W
wusongqing 已提交
279

W
wusongqing 已提交
280
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
281

W
wusongqing 已提交
282
**Return value**
W
wusongqing 已提交
283

284 285
| Type              | Description              |
| ---------------- | ---------------- |
W
wusongqing 已提交
286
| Promise\<string> | Promise used to return the bundle name.|
W
wusongqing 已提交
287

W
wusongqing 已提交
288
**Example**
W
wusongqing 已提交
289 290 291 292

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
293 294 295
context.getBundleName().then((data) => {
    console.info("=======================>getBundleNameCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
W
wusongqing 已提交
296 297 298
});
```

299 300 301 302 303 304 305 306 307 308
## Context.getDisplayOrientation<sup>7+</sup>

getDisplayOrientation(callback: AsyncCallback\<bundle.DisplayOrientation>): void

Obtains the display orientation of this ability. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

309 310 311
| Name    | Type                                                        | Mandatory| Description              |
| -------- | ------------------------------------------------------------ | ---- | ------------------ |
| callback | AsyncCallback\<[bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation)> | Yes  | Callback used to return the display orientation.|
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getDisplayOrientation()
```

## Context.getDisplayOrientation<sup>7+</sup>

getDisplayOrientation(): Promise\<bundle.DisplayOrientation>;

Obtains the display orientation of this ability. This API uses a promise to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

331 332 333
| Type                                      | Description       |
| ---------------------------------------- | --------- |
| Promise\<[bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation)> | Promise used to return the display orientation.|
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getDisplayOrientation().then((data) => {
    console.info("=======================>getDisplayOrientationCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
});
```

## Context.setDisplayOrientation<sup>7+</sup>

setDisplayOrientation(orientation: bundle.DisplayOrientation, callback: AsyncCallback\<void>): void

350
Sets the display orientation for this ability. This API uses an asynchronous callback to return the result.
351 352 353 354 355

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

356 357 358 359
| Name         | Type                                      | Mandatory  | Description          |
| ----------- | ---------------------------------------- | ---- | ------------ |
| orientation | [bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation) | Yes   | Display orientation to set.|
| callback    | AsyncCallback\<[bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation)> | Yes   | Callback used to return the display orientation.   |
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
import bundle from '@ohos.bundle'
var context = featureAbility.getContext();
var orientation=bundle.DisplayOrientation.UNSPECIFIED
context.setDisplayOrientation(orientation, (err) => {
    console.log('---------- setDisplayOrientation fail, err: -----------', err);
});
```

## Context.setDisplayOrientation<sup>7+</sup>

setDisplayOrientation(orientation: bundle.DisplayOrientation): Promise\<void>;

377
Sets the display orientation for this ability. This API uses a promise to return the result.
378 379 380 381 382

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

383 384 385 386
| Type                                      | Description                                      |
| ---------------------------------------- | ---------------------------------------- |
| orientation                              | [bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation) |
| Promise\<[bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation)> | Promise used to return the display orientation.                               |
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
import bundle from '@ohos.bundle'
var context = featureAbility.getContext();
var orientation=bundle.DisplayOrientation.UNSPECIFIED
context.setDisplayOrientation(orientation).then((data) => {
    console.info("=======================>setDisplayOrientationCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
});
```

## Context.setShowOnLockScreen<sup>7+</sup>

setShowOnLockScreen(show: boolean, callback: AsyncCallback\<void>): void

405
Sets whether to show this feature at the top of the lock screen so that the feature remains activated. This API uses an asynchronous callback to return the result.
406 407 408 409 410

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

411 412 413 414
| Name      | Type                  | Mandatory  | Description                                      |
| -------- | -------------------- | ---- | ---------------------------------------- |
| show     | boolean              | Yes   | Whether to show this feature at the top of the lock screen. The value **true** means to show this feature at the top of the lock screen, and **false** means the opposite.|
| callback | AsyncCallback\<void> | Yes   | Callback used to return the result.                                 |
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
var show=true
context.setShowOnLockScreen(show, (err) => {
       console.log('---------- setShowOnLockScreen fail, err: -----------', err);
});
```

## Context.setShowOnLockScreen<sup>7+</sup>

setShowOnLockScreen(show: boolean): Promise\<void>;

431
Sets whether to show this feature at the top of the lock screen so that the feature remains activated. This API uses a promise to return the result.
432 433 434 435 436

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

437 438 439
| Name  | Type     | Mandatory  | Description                                      |
| ---- | ------- | ---- | ---------------------------------------- |
| show | boolean | Yes   | Whether to show this feature at the top of the lock screen. The value **true** means to show this feature at the top of the lock screen, and **false** means the opposite.|
440 441 442

**Return value**

443 444 445
| Type            | Description             |
| -------------- | --------------- |
| Promise\<void> | Promise used to return the result.|
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
var show=true
context.setShowOnLockScreen(show).then((data) => {
    console.info("=======================>setShowOnLockScreenCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
});
```

## Context.setWakeUpScreen<sup>7+</sup>

setWakeUpScreen(wakeUp: boolean, callback: AsyncCallback\<void>): void

Sets whether to wake up the screen when this feature is restored. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

469 470 471 472
| Name      | Type                  | Mandatory  | Description                               |
| -------- | -------------------- | ---- | --------------------------------- |
| wakeUp   | boolean              | Yes   | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite.|
| callback | AsyncCallback\<void> | Yes   | Callback used to return the result.                          |
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
var wakeUp=true
context.setWakeUpScreen(wakeUp, (err) => {
       console.log('---------- setWakeUpScreen fail, err: -----------', err);
});
```

## Context.setWakeUpScreen<sup>7+</sup>

setWakeUpScreen(wakeUp: boolean): Promise\<void>; 

Sets whether to wake up the screen when this feature is restored. This API uses a promise to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

495 496 497
| Name    | Type     | Mandatory  | Description                               |
| ------ | ------- | ---- | --------------------------------- |
| wakeUp | boolean | Yes   | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite.|
498 499 500

**Return value**

501 502 503
| Type            | Description             |
| -------------- | --------------- |
| Promise\<void> | Promise used to return the result.|
504 505 506 507 508 509 510 511 512 513 514 515 516 517

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
var wakeUp=true
context.setWakeUpScreen(wakeUp).then((data) => {
    console.info("=======================>setWakeUpScreenCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
});
```


W
wusongqing 已提交
518 519


W
wusongqing 已提交
520
## Context.getProcessInfo<sup>7+</sup>
W
wusongqing 已提交
521

W
wusongqing 已提交
522
getProcessInfo(callback: AsyncCallback\<ProcessInfo>): void
W
wusongqing 已提交
523

W
wusongqing 已提交
524
Obtains information about the current process, including the PID and process name. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
525

W
wusongqing 已提交
526
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
527

W
wusongqing 已提交
528
**Parameters**
W
wusongqing 已提交
529

530 531 532
| Name      | Type                         | Mandatory  | Description        |
| -------- | --------------------------- | ---- | ---------- |
| callback | AsyncCallback\<ProcessInfo> | Yes   | Callback used to return the process information.|
W
wusongqing 已提交
533

W
wusongqing 已提交
534
**Example**
W
wusongqing 已提交
535 536 537 538 539 540 541 542 543

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getProcessInfo()
```



W
wusongqing 已提交
544
## Context.getProcessInfo<sup>7+</sup>
W
wusongqing 已提交
545

W
wusongqing 已提交
546
getProcessInfo(): Promise\<ProcessInfo>
W
wusongqing 已提交
547

W
wusongqing 已提交
548
Obtains information about the current process, including the PID and process name. This API uses a promise to return the result.
W
wusongqing 已提交
549

W
wusongqing 已提交
550
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
551

W
wusongqing 已提交
552
**Return value**
W
wusongqing 已提交
553

554 555
| Type                   | Description     |
| --------------------- | ------- |
W
wusongqing 已提交
556
| Promise\<ProcessInfo> | Promise used to return the process information.|
W
wusongqing 已提交
557

W
wusongqing 已提交
558
**Example**
W
wusongqing 已提交
559 560 561 562

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
563 564 565
context.getProcessInfo().then((data) => {
    console.info("=======================>getProcessInfoCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
W
wusongqing 已提交
566 567 568 569 570
});
```



W
wusongqing 已提交
571
## Context.getElementName<sup>7+</sup>
W
wusongqing 已提交
572

W
wusongqing 已提交
573
getElementName(callback: AsyncCallback\<ElementName>): void
W
wusongqing 已提交
574

575
Obtains the **ohos.bundle.ElementName** object of this ability. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
576

W
wusongqing 已提交
577
This API is available only to Page abilities.
W
wusongqing 已提交
578

W
wusongqing 已提交
579
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
580

W
wusongqing 已提交
581
**Parameters**
W
wusongqing 已提交
582

583 584 585
| Name      | Type                         | Mandatory  | Description                                    |
| -------- | --------------------------- | ---- | -------------------------------------- |
| callback | AsyncCallback\<ElementName> | Yes   | Callback used to return the **ohos.bundle.ElementName** object.|
W
wusongqing 已提交
586

W
wusongqing 已提交
587
**Example**
W
wusongqing 已提交
588 589 590 591 592 593 594 595 596

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getElementName()
```



W
wusongqing 已提交
597
## Context.getElementName<sup>7+</sup>
W
wusongqing 已提交
598

W
wusongqing 已提交
599
getElementName(): Promise\<ElementName>
W
wusongqing 已提交
600

601
Obtains the **ohos.bundle.ElementName** object of this ability. This API uses a promise to return the result.
W
wusongqing 已提交
602

W
wusongqing 已提交
603
This API is available only to Page abilities.
W
wusongqing 已提交
604

W
wusongqing 已提交
605
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
606

W
wusongqing 已提交
607
**Return value**
W
wusongqing 已提交
608

609 610
| Type                   | Description                                  |
| --------------------- | ------------------------------------ |
W
wusongqing 已提交
611
| Promise\<ElementName> | Promise used to return the **ohos.bundle.ElementName** object.|
W
wusongqing 已提交
612

W
wusongqing 已提交
613
**Example**
W
wusongqing 已提交
614 615 616 617

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
618 619 620
context.getElementName().then((data) => {
    console.info("=======================>getElementNameCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
W
wusongqing 已提交
621 622 623
});
```

W
wusongqing 已提交
624
## Context.getProcessName<sup>7+</sup>
W
wusongqing 已提交
625

W
wusongqing 已提交
626
getProcessName(callback: AsyncCallback\<string>): void
W
wusongqing 已提交
627

W
wusongqing 已提交
628
Obtains the name of the current process. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
629

W
wusongqing 已提交
630
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
631

W
wusongqing 已提交
632
**Parameters**
W
wusongqing 已提交
633

634 635 636
| Name      | Type                    | Mandatory  | Description        |
| -------- | ---------------------- | ---- | ---------- |
| callback | AsyncCallback\<string> | Yes   | Callback used to return the process name.|
W
wusongqing 已提交
637

W
wusongqing 已提交
638
**Example**
W
wusongqing 已提交
639 640 641 642 643 644 645 646 647

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getProcessName()
```



W
wusongqing 已提交
648
## Context.getProcessName<sup>7+</sup>
W
wusongqing 已提交
649

W
wusongqing 已提交
650
getProcessName(): Promise\<string>
W
wusongqing 已提交
651

W
wusongqing 已提交
652
Obtains the name of the current process. This API uses a promise to return the result.
W
wusongqing 已提交
653

W
wusongqing 已提交
654
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
655

W
wusongqing 已提交
656
**Return value**
W
wusongqing 已提交
657

658 659
| Type              | Description        |
| ---------------- | ---------- |
W
wusongqing 已提交
660
| Promise\<string> | Promise used to return the process name.|
W
wusongqing 已提交
661

W
wusongqing 已提交
662
**Example**
W
wusongqing 已提交
663 664 665 666

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
667 668 669
context.getProcessName().then((data) => {
    console.info("=======================>getProcessNameCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
W
wusongqing 已提交
670 671 672 673 674
});
```



W
wusongqing 已提交
675
## Context.getCallingBundle<sup>7+</sup>
W
wusongqing 已提交
676

W
wusongqing 已提交
677
getCallingBundle(callback: AsyncCallback\<string>): void
W
wusongqing 已提交
678

W
wusongqing 已提交
679
Obtains the bundle name of the calling ability. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
680

W
wusongqing 已提交
681
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
682

W
wusongqing 已提交
683
**Parameters**
W
wusongqing 已提交
684

685 686 687
| Name      | Type                    | Mandatory  | Description              |
| -------- | ---------------------- | ---- | ---------------- |
| callback | AsyncCallback\<string> | Yes   | Callback used to return the bundle name.|
W
wusongqing 已提交
688

W
wusongqing 已提交
689
**Example**
W
wusongqing 已提交
690 691 692 693 694 695 696 697 698

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getCallingBundle()
```



W
wusongqing 已提交
699
## Context.getCallingBundle<sup>7+</sup>
W
wusongqing 已提交
700

W
wusongqing 已提交
701
getCallingBundle(): Promise\<string>
W
wusongqing 已提交
702

W
wusongqing 已提交
703
Obtains the bundle name of the calling ability. This API uses a promise to return the result.
W
wusongqing 已提交
704

W
wusongqing 已提交
705
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
706

W
wusongqing 已提交
707
**Return value**
W
wusongqing 已提交
708

709 710
| Type              | Description            |
| ---------------- | -------------- |
W
wusongqing 已提交
711
| Promise\<string> | Promise used to return the bundle name.|
W
wusongqing 已提交
712

W
wusongqing 已提交
713
**Example**
W
wusongqing 已提交
714 715 716 717

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
718 719 720
context.getCallingBundle().then((data) => {
    console.info("======================>getCallingBundleCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
W
wusongqing 已提交
721 722
});
```
W
wusongqing 已提交
723

W
wusongqing 已提交
724 725 726 727
## Context.getCacheDir

getCacheDir(callback: AsyncCallback\<string>): void

728
Obtains the cache directory of the application in the internal storage. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
729 730 731 732 733

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

734 735 736
| Name      | Type                    | Mandatory  | Description             |
| -------- | ---------------------- | ---- | --------------- |
| callback | AsyncCallback\<string> | Yes   | Callback used to return the cache directory.|
W
wusongqing 已提交
737 738 739 740 741

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
W
wusongqing 已提交
742
var context = featureAbility.getContext();
W
wusongqing 已提交
743 744 745 746 747 748 749 750 751 752 753 754 755
context.getCacheDir((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

## Context.getCacheDir

getCacheDir(): Promise\<string>

756
Obtains the cache directory of the application in the internal storage. This API uses a promise to return the result.
W
wusongqing 已提交
757 758 759 760 761

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

762 763
| Type              | Description             |
| ---------------- | --------------- |
W
wusongqing 已提交
764
| Promise\<string> | Promise used to return the cache directory.|
W
wusongqing 已提交
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getCacheDir().then((data) => {
    console.info("======================>getCacheDirPromsie====================>");
    console.info("====>data====>" + JSON.stringify(data));
});
```

## Context.getFilesDir

getFilesDir(callback: AsyncCallback\<string>): void

781
Obtains the file directory of the application in the internal storage. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
782 783 784 785 786

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

787 788 789
| Name      | Type                    | Mandatory  | Description                 |
| -------- | ---------------------- | ---- | ------------------- |
| callback | AsyncCallback\<string> | Yes   | Callback used to return the file directory.|
W
wusongqing 已提交
790 791 792 793 794

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
W
wusongqing 已提交
795
var context = featureAbility.getContext();
W
wusongqing 已提交
796 797 798 799 800 801 802 803 804 805 806 807 808
context.getFilesDir((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

## Context.getFilesDir

getFilesDir(): Promise\<string>

809
Obtains the file directory of the application in the internal storage. This API uses a promise to return the result.
W
wusongqing 已提交
810 811 812 813 814

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

815 816
| Type              | Description                 |
| ---------------- | ------------------- |
W
wusongqing 已提交
817
| Promise\<string> | Promise used to return the file directory.|
W
wusongqing 已提交
818 819 820 821 822 823 824 825 826 827 828 829

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getFilesDir().then((data) => {
    console.info("======================>getFilesDirPromsie====================>");
    console.info("====>data====>" + JSON.stringify(data));
});
```

W
wusongqing 已提交
830
## Context.getOrCreateDistributedDir<sup>7+</sup>
W
wusongqing 已提交
831 832 833 834 835 836 837 838 839 840 841

getOrCreateDistributedDir(callback: AsyncCallback\<string>): void

Obtains the distributed file path for storing ability or application data files. This API uses an asynchronous callback to return the result.

If the distributed file path does not exist, the system will create one and return the created path.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

842 843 844
| Name      | Type                    | Mandatory  | Description                                      |
| -------- | ---------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback\<string> | Yes   | Callback used to return the distributed file path. If the distributed file path does not exist, the system will create one and return the created path.|
W
wusongqing 已提交
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getOrCreateDistributedDir((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

W
wusongqing 已提交
860
## Context.getOrCreateDistributedDir<sup>7+</sup>
W
wusongqing 已提交
861 862 863 864 865 866 867 868 869 870 871

getOrCreateDistributedDir(): Promise\<string>

Obtains the distributed file path for storing ability or application data files. This API uses a promise to return the result.

If the distributed file path does not exist, the system will create one and return the created path.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

872 873
| Type              | Description                                 |
| ---------------- | ----------------------------------- |
W
wusongqing 已提交
874
| Promise\<string> | Promise used to return the distributed file path. If this API is called for the first time, a new path will be created.|
W
wusongqing 已提交
875 876 877 878 879 880 881 882 883 884 885

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getOrCreateDistributedDir().then((data) => {
    console.info("====>data====>" + JSON.stringify(data));
});
```

W
wusongqing 已提交
886
## Context.getAppType<sup>7+</sup>
W
wusongqing 已提交
887 888 889 890 891 892 893 894 895

getAppType(callback: AsyncCallback\<string>): void

Obtains the application type. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

896 897 898
| Name      | Type                    | Mandatory  | Description                              |
| -------- | ---------------------- | ---- | -------------------------------- |
| callback | AsyncCallback\<string> | Yes   | Callback used to return the application type.|
W
wusongqing 已提交
899 900 901 902 903 904 905 906 907 908 909 910 911 912 913

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getAppType((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

W
wusongqing 已提交
914
## Context.getAppType<sup>7+</sup>
W
wusongqing 已提交
915 916 917 918 919 920 921 922 923

getAppType(): Promise\<string>

Obtains the application type. This API uses a promise to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

924 925
| Type              | Description                |
| ---------------- | ------------------ |
W
wusongqing 已提交
926
| Promise\<string> | Promise used to return the application type.|
W
wusongqing 已提交
927 928 929 930 931 932 933 934 935 936 937

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getAppType().then((data) => {
    console.info("====>data====>" + JSON.stringify(data));
});
```

W
wusongqing 已提交
938
## Context.getHapModuleInfo<sup>7+</sup>
W
wusongqing 已提交
939 940 941 942 943 944 945 946 947

getHapModuleInfo(callback: AsyncCallback\<HapModuleInfo>): void

Obtains the **ModuleInfo** object of the application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

948 949 950
| Name      | Type                                      | Mandatory  | Description                                     |
| -------- | ---------------------------------------- | ---- | --------------------------------------- |
| callback | AsyncCallback\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | Yes   | Callback used to return the **ModuleInfo** object.|
W
wusongqing 已提交
951 952 953 954 955 956 957 958 959 960 961 962 963 964 965

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getHapModuleInfo((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

W
wusongqing 已提交
966
## Context.getHapModuleInfo<sup>7+</sup>
W
wusongqing 已提交
967 968 969 970 971 972 973 974 975

getHapModuleInfo(): Promise\<HapModuleInfo>

Obtains the **ModuleInfo** object of the application. This API uses a promise to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

976 977
| Type                                      | Description                |
| ---------------------------------------- | ------------------ |
978
| Promise\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | Promise used to return the **ModuleInfo** object.|
W
wusongqing 已提交
979 980 981 982 983 984 985 986 987 988 989

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getHapModuleInfo().then((data) => {
    console.info("====>data====>" + JSON.stringify(data));
});
```

W
wusongqing 已提交
990
## Context.getAppVersionInfo<sup>7+</sup>
W
wusongqing 已提交
991

992
getAppVersionInfo(callback: AsyncCallback\<AppVersionInfo>): void
W
wusongqing 已提交
993

994
Obtains the version information of this application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
995 996 997 998 999

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

1000 1001 1002
| Name      | Type                                      | Mandatory  | Description                            |
| -------- | ---------------------------------------- | ---- | ------------------------------ |
| callback | AsyncCallback\<[AppVersionInfo](#appversioninfo)> | Yes   | Callback used to return the version information.|
W
wusongqing 已提交
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getAppVersionInfo((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

W
wusongqing 已提交
1018
## Context.getAppVersionInfo<sup>7+</sup>
W
wusongqing 已提交
1019 1020 1021

getAppVersionInfo(): Promise\<AppVersionInfo>

1022
Obtains the version information of this application. This API uses a promise to return the result.
W
wusongqing 已提交
1023 1024 1025 1026 1027

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

1028 1029
| Type                                      | Description       |
| ---------------------------------------- | --------- |
W
wusongqing 已提交
1030
| Promise\<[AppVersionInfo](#appversioninfo)> | Promise used to return the version information.|
W
wusongqing 已提交
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getAppVersionInfo().then((data) => {
    console.info("====>data====>" + JSON.stringify(data));
});
```

W
wusongqing 已提交
1042
## Context.getAbilityInfo<sup>7+</sup>
W
wusongqing 已提交
1043 1044 1045

getAbilityInfo(callback: AsyncCallback\<AbilityInfo>): void

1046
Obtains information about this ability. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1047 1048 1049 1050 1051

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

1052 1053 1054
| Name      | Type                                      | Mandatory  | Description                                     |
| -------- | ---------------------------------------- | ---- | --------------------------------------- |
| callback | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes   | Callback used to return the ability information.|
W
wusongqing 已提交
1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getAbilityInfo((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

W
wusongqing 已提交
1070
## Context.getAbilityInfo<sup>7+</sup>
W
wusongqing 已提交
1071 1072 1073

getAbilityInfo(): Promise\<AbilityInfo>

1074
Obtains information about this ability. This API uses a promise to return the result.
W
wusongqing 已提交
1075 1076 1077 1078 1079

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

1080 1081
| Type                                      | Description                |
| ---------------------------------------- | ------------------ |
1082
| Promise\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Promise used to return the ability information.|
W
wusongqing 已提交
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getAbilityInfo().then((data) => {
    console.info("====>data====>" + JSON.stringify(data));
});
```

W
wusongqing 已提交
1094
## Context.getApplicationContext<sup>7+</sup>
W
wusongqing 已提交
1095 1096 1097 1098 1099 1100 1101 1102 1103

getApplicationContext(): Context

Obtains the context of the application.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

1104 1105 1106
| Type     | Description        |
| ------- | ---------- |
| Context | Application context.|
W
wusongqing 已提交
1107 1108 1109 1110 1111 1112 1113 1114

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext().getApplicationContext();
```

1115 1116 1117 1118
## Context.isUpdatingConfigurations<sup>7+</sup>

isUpdatingConfigurations(callback: AsyncCallback\<boolean>): void;

1119
Checks whether the configuration of this ability is being updated. This API uses an asynchronous callback to return the result.
1120 1121 1122 1123 1124

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

1125 1126 1127
| Name      | Type                     | Mandatory  | Description                           |
| -------- | ----------------------- | ---- | ----------------------------- |
| callback | AsyncCallback\<boolean> | Yes   | Returns **true** if the configuration of the capability is being updated; returns **false** otherwise.|
1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.isUpdatingConfigurations((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

## Context.isUpdatingConfigurations<sup>7+</sup>

isUpdatingConfigurations(): Promise\<boolean>;

1147
Checks whether the configuration of this ability is being updated. This API uses a promise to return the result.
1148 1149 1150 1151 1152

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

1153 1154 1155
| Type               | Description                           |
| ----------------- | ----------------------------- |
| Promise\<boolean> | Returns **true** if the configuration of the capability is being updated; returns **false** otherwise.|
1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.isUpdatingConfigurations().then((data) => {
    console.info("====>data====>" + JSON.stringify(data));
});
```

## Context.printDrawnCompleted<sup>7+</sup>

printDrawnCompleted(callback: AsyncCallback\<void>): void;

Notifies the system of the time required to draw this page function. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

1177 1178 1179
| Name      | Type                  | Mandatory  | Description         |
| -------- | -------------------- | ---- | ----------- |
| callback | AsyncCallback\<void> | Yes   | Callback used to return the result.|
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.printDrawnCompleted((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

## Context.printDrawnCompleted<sup>7+</sup>

printDrawnCompleted(): Promise\<void>;

Notifies the system of the time required to draw this page function. This API uses a promise to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

1205 1206 1207
| Type            | Description             |
| -------------- | --------------- |
| Promise\<void> | Promise used to return the result.|
1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.printDrawnCompleted().then((data) => {
    console.info("====>data====>" + JSON.stringify(data));
});
```


W
wusongqing 已提交
1220
## PermissionOptions<sup>7+</sup>
W
wusongqing 已提交
1221

W
wusongqing 已提交
1222 1223
**System capability**: SystemCapability.Ability.AbilityRuntime.Core

1224 1225 1226 1227
| Name  | Readable/Writable| Type    | Mandatory  | Description   |
| ---- | ---- | ------ | ---- | ----- |
| pid  | Read-only  | number | No   | Process ID.|
| uid  | Read-only  | number | No   | User ID.|
W
wusongqing 已提交
1228

W
wusongqing 已提交
1229
## PermissionRequestResult<sup>7+</sup>
W
wusongqing 已提交
1230

W
wusongqing 已提交
1231 1232
**System capability**: SystemCapability.Ability.AbilityRuntime.Core

1233 1234 1235 1236 1237
| Name         | Readable/Writable| Type            | Mandatory  | Description        |
| ----------- | ---- | -------------- | ---- | ---------- |
| requestCode | Read-only  | number         | Yes   | Request code passed.|
| permissions | Read-only  | Array\<string> | Yes   | Permissions requested.  |
| authResults | Read-only  | Array\<number> | Yes   | Permission request result.  |
W
wusongqing 已提交
1238

W
wusongqing 已提交
1239
## AppVersionInfo<sup>7+</sup>
W
wusongqing 已提交
1240

1241 1242
**System capability**: SystemCapability.Ability.AbilityRuntime.Core

1243 1244 1245 1246 1247
| Name         | Type    | Readable  | Writable  | Description     |
| ----------- | ------ | ---- | ---- | ------- |
| appName     | string | Yes   | No   | Module name.  |
| versionCode | number | Yes   | No   | Module description.|
| versionName | string | Yes   | No   | Module description ID.|