1# Context 2 3The **Context** module provides context for abilities or applications. It allows access to application-specific resources, as well as permission requests and verification. 4 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. 8> 9> The APIs of this module can be used only in the FA model. 10 11## Modules to Import 12 13```ts 14import featureAbility from '@ohos.ability.featureAbility'; 15``` 16 17## Usage 18 19The **Context** object is created in a **featureAbility** and returned through its [getContext](js-apis-ability-featureAbility.md#featureabilitygetcontext) API. Therefore, you must import the **@ohos.ability.featureAbility** package before using the **Context** module. An example is as follows: 20 21<!--code_no_check_fa--> 22```ts 23import featureAbility from '@ohos.ability.featureAbility'; 24 25let context: featureAbility.Context = featureAbility.getContext(); 26context.getOrCreateLocalDir().then((data) => { 27 console.info(`getOrCreateLocalDir data: ${JSON.stringify(data)}`); 28}); 29``` 30 31## Context.getOrCreateLocalDir<sup>7+</sup> 32 33getOrCreateLocalDir(callback: AsyncCallback\<string>): void 34 35Obtains the local root directory of the application. This API uses an asynchronous callback to return the result. 36 37If this API is called for the first time, a root directory will be created. 38 39**System capability**: SystemCapability.Ability.AbilityRuntime.Core 40 41**Parameters** 42 43| Name | Type | Mandatory | Description | 44| -------- | ---------------------- | ---- | ------------- | 45| callback | AsyncCallback\<string> | Yes | Callback used to return the local root directory.| 46 47**Example** 48 49<!--code_no_check_fa--> 50```ts 51import featureAbility from '@ohos.ability.featureAbility'; 52 53let context: featureAbility.Context = featureAbility.getContext(); 54context.getOrCreateLocalDir((error, data)=>{ 55 if (error && error.code !== 0) { 56 console.error(`getOrCreateLocalDir fail, error: ${JSON.stringify(error)}`); 57 } else { 58 console.log(`getOrCreateLocalDir success, data: ${JSON.stringify(data)}`); 59 } 60}); 61``` 62 63 64 65## Context.getOrCreateLocalDir<sup>7+</sup> 66 67getOrCreateLocalDir(): Promise\<string> 68 69Obtains the local root directory of the application. This API uses a promise to return the result. 70 71If this API is called for the first time, a root directory will be created. 72 73**System capability**: SystemCapability.Ability.AbilityRuntime.Core 74 75**Return value** 76 77| Type | Description | 78| ---------------- | ----------- | 79| Promise\<string> | Promise used to return the local root directory.| 80 81**Example** 82 83<!--code_no_check_fa--> 84```ts 85import featureAbility from '@ohos.ability.featureAbility'; 86 87let context: featureAbility.Context = featureAbility.getContext(); 88context.getOrCreateLocalDir().then((data) => { 89 console.info(`getOrCreateLocalDir data: ${JSON.stringify(data)}`); 90}); 91``` 92 93## Context.verifyPermission<sup>7+</sup> 94 95verifyPermission(permission: string, options: PermissionOptions, callback: AsyncCallback\<number>): void 96 97Verifies whether a PID and UID have the given permission. This API uses an asynchronous callback to return the result. 98 99**System capability**: SystemCapability.Ability.AbilityRuntime.Core 100 101**Parameters** 102 103| Name | Type | Mandatory | Description | 104| ---------- | --------------------------------------- | ---- | -------------------- | 105| permission | string | Yes | Name of the permission to verify. | 106| options | [PermissionOptions](#permissionoptions7) | Yes | Permission options. | 107| 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.| 108 109**Example** 110 111<!--code_no_check_fa--> 112```ts 113import featureAbility from '@ohos.ability.featureAbility'; 114import bundle from '@ohos.bundle.bundleManager'; 115import { BusinessError } from '@ohos.base'; 116 117let context: featureAbility.Context = featureAbility.getContext(); 118bundle.getBundleInfo('com.context.test', 1, (err: BusinessError, datainfo: bundle.BundleInfo) =>{ 119 context.verifyPermission('com.example.permission', {uid:datainfo.appInfo.uid}, (error, data) =>{ 120 if (error && error.code !== 0) { 121 console.error(`verifyPermission fail, error: ${JSON.stringify(error)}`); 122 } else { 123 console.log(`verifyPermission success, data: ${JSON.stringify(data)}`); 124 } 125 }); 126}); 127``` 128For details about **getBundleInfo** in the sample code, see [bundleManager](js-apis-bundleManager.md). 129 130 131 132## Context.verifyPermission<sup>7+</sup> 133 134verifyPermission(permission: string, callback: AsyncCallback\<number>): void 135 136Verifies whether the current PID and UID have the given permission. This API uses an asynchronous callback to return the result. 137 138**System capability**: SystemCapability.Ability.AbilityRuntime.Core 139 140**Parameters** 141 142| Name | Type | Mandatory | Description | 143| ---------- | ---------------------- | ---- | -------------------- | 144| permission | string | Yes | Name of the permission to verify. | 145| 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.| 146 147**Example** 148 149<!--code_no_check_fa--> 150```ts 151import featureAbility from '@ohos.ability.featureAbility'; 152 153let context: featureAbility.Context = featureAbility.getContext(); 154context.verifyPermission('com.example.permission', (error, data) =>{ 155 if (error && error.code !== 0) { 156 console.error(`verifyPermission fail, error: ${JSON.stringify(error)}`); 157 } else { 158 console.log(`verifyPermission success, data: ${JSON.stringify(data)}`); 159 } 160}); 161``` 162 163## Context.verifyPermission<sup>7+</sup> 164 165verifyPermission(permission: string, options?: PermissionOptions): Promise\<number> 166 167Verifies whether a PID and UID have the given permission. This API uses a promise to return the result. 168 169**System capability**: SystemCapability.Ability.AbilityRuntime.Core 170 171**Parameters** 172 173| Name | Type | Mandatory | Description | 174| ---------- | --------------------------------------- | ---- | -------- | 175| permission | string | Yes | Name of the permission to verify.| 176| options | [PermissionOptions](#permissionoptions7) | No | Permission options. | 177 178**Return value** 179 180| Type | Description | 181| ---------------- | ---------------------------------- | 182| 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.| 183 184**Example** 185 186<!--code_no_check_fa--> 187```ts 188import featureAbility from '@ohos.ability.featureAbility'; 189 190let context: featureAbility.Context = featureAbility.getContext(); 191context.verifyPermission('com.context.permission', {pid:1}).then((data) => { 192 console.info(`verifyPermission data: ${JSON.stringify(data)}`); 193}); 194``` 195 196 197 198## Context.requestPermissionsFromUser<sup>7+</sup> 199 200requestPermissionsFromUser(permissions: Array\<string>, requestCode: number, resultCallback: AsyncCallback\<PermissionRequestResult>): void 201 202Requests certain permissions from the system. This API uses an asynchronous callback to return the result. 203 204**System capability**: SystemCapability.Ability.AbilityRuntime.Core 205 206**Parameters** 207 208| Name | Type | Mandatory | Description | 209| -------------- | ---------------------------------------- | ---- | ----------------------------------- | 210| permissions | Array\<string> | Yes | Permissions to request. This parameter cannot be **null**. | 211| requestCode | number | Yes | Request code to be passed to [PermissionRequestResult](#permissionrequestresult7).| 212| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult7)> | Yes | Callback used to return the permission request result. | 213 214**Example** 215 216<!--code_no_check_fa--> 217```ts 218import featureAbility from '@ohos.ability.featureAbility'; 219 220let context: featureAbility.Context = featureAbility.getContext(); 221context.requestPermissionsFromUser( 222 ['com.example.permission1', 223 'com.example.permission2', 224 'com.example.permission3', 225 'com.example.permission4', 226 'com.example.permission5'], 227 1, 228 (error, data) => { 229 if (error && error.code !== 0) { 230 console.error(`requestPermissionsFromUser fail, error: ${JSON.stringify(error)}`); 231 } else { 232 console.log(`requestPermissionsFromUser success, data: ${JSON.stringify(data)}`); 233 } 234 } 235); 236``` 237 238 239## Context.requestPermissionsFromUser<sup>7+</sup> 240 241requestPermissionsFromUser(permissions: Array\<string>, requestCode: number): Promise\<PermissionRequestResult> 242 243Requests certain permissions from the system. This API uses a promise to return the result. 244 245**System capability**: SystemCapability.Ability.AbilityRuntime.Core 246 247**Parameters** 248 249| Name | Type | Mandatory | Description | 250| -------------- | ------------------- | ----- | -------------------------------------------- | 251| permissions | Array\<string> | Yes | Permissions to request. This parameter cannot be **null**. | 252| requestCode | number | Yes | Request code to be passed to [PermissionRequestResult](#permissionrequestresult7).| 253 254**Return value** 255 256| Type | Description | 257| ------------------------------------------------------------- | ---------------- | 258| Promise\<[PermissionRequestResult](#permissionrequestresult7)> | Promise used to return the permission request result.| 259 260**Example** 261 262<!--code_no_check_fa--> 263```ts 264import featureAbility from '@ohos.ability.featureAbility'; 265 266let context: featureAbility.Context = featureAbility.getContext(); 267context.requestPermissionsFromUser( 268 ['com.example.permission1', 269 'com.example.permission2', 270 'com.example.permission3', 271 'com.example.permission4', 272 'com.example.permission5'], 273 1).then((data)=>{ 274 console.info(`requestPermissionsFromUser data: ${JSON.stringify(data)}`); 275 } 276); 277``` 278 279 280 281## Context.getApplicationInfo<sup>7+</sup> 282 283getApplicationInfo(callback: AsyncCallback\<ApplicationInfo>): void 284 285Obtains information about the application. This API uses an asynchronous callback to return the result. 286 287**System capability**: SystemCapability.Ability.AbilityRuntime.Core 288 289**Parameters** 290 291| Name | Type | Mandatory | Description | 292| -------- | ------------------------------- | ---- | ------------ | 293| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | Yes | Callback used to return the application information.| 294 295**Example** 296 297<!--code_no_check_fa--> 298```ts 299import featureAbility from '@ohos.ability.featureAbility'; 300 301let context: featureAbility.Context = featureAbility.getContext(); 302context.getApplicationInfo((error, data) => { 303 if (error && error.code !== 0) { 304 console.error(`getApplicationInfo fail, error: ${JSON.stringify(error)}`); 305 } else { 306 console.log(`getApplicationInfo success, data: ${JSON.stringify(data)}`); 307 } 308}); 309``` 310 311 312 313## Context.getApplicationInfo<sup>7+</sup> 314 315getApplicationInfo(): Promise\<ApplicationInfo> 316 317Obtains information about the application. This API uses a promise to return the result. 318 319**System capability**: SystemCapability.Ability.AbilityRuntime.Core 320 321**Return value** 322 323| Type | Description | 324| ------------------------- | --------- | 325| Promise\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Promise used to return the application information.| 326 327**Example** 328 329<!--code_no_check_fa--> 330```ts 331import featureAbility from '@ohos.ability.featureAbility'; 332 333let context: featureAbility.Context = featureAbility.getContext(); 334context.getApplicationInfo().then((data) => { 335 console.info(`getApplicationInfo data: ${JSON.stringify(data)}`); 336}); 337``` 338 339 340 341## Context.getBundleName<sup>7+</sup> 342 343getBundleName(callback: AsyncCallback\<string>): void 344 345Obtains the bundle name of this ability. This API uses an asynchronous callback to return the result. 346 347**System capability**: SystemCapability.Ability.AbilityRuntime.Core 348 349**Parameters** 350 351| Name | Type | Mandatory | Description | 352| -------- | ---------------------- | ---- | ------------------ | 353| callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name.| 354 355**Example** 356 357<!--code_no_check_fa--> 358```ts 359import featureAbility from '@ohos.ability.featureAbility'; 360 361let context: featureAbility.Context = featureAbility.getContext(); 362context.getBundleName((error, data) => { 363 if (error && error.code !== 0) { 364 console.error(`getBundleName fail, error: ${JSON.stringify(error)}`); 365 } else { 366 console.log(`getBundleName success, data: ${JSON.stringify(data)}`); 367 } 368}); 369``` 370 371 372 373## Context.getBundleName<sup>7+</sup> 374 375getBundleName(): Promise\<string> 376 377Obtains the bundle name of this ability. This API uses a promise to return the result. 378 379**System capability**: SystemCapability.Ability.AbilityRuntime.Core 380 381**Return value** 382 383| Type | Description | 384| ---------------- | ---------------- | 385| Promise\<string> | Promise used to return the bundle name.| 386 387**Example** 388 389<!--code_no_check_fa--> 390```ts 391import featureAbility from '@ohos.ability.featureAbility'; 392 393let context: featureAbility.Context = featureAbility.getContext(); 394context.getBundleName().then((data) => { 395 console.info(`getBundleName data: ${JSON.stringify(data)}`); 396}); 397``` 398 399## Context.getDisplayOrientation<sup>7+</sup> 400 401getDisplayOrientation(callback: AsyncCallback\<bundle.DisplayOrientation>): void 402 403Obtains the display orientation of this ability. This API uses an asynchronous callback to return the result. 404 405**System capability**: SystemCapability.Ability.AbilityRuntime.Core 406 407**Parameters** 408 409| Name | Type | Mandatory| Description | 410| -------- | ------------------------------------------------------------ | ---- | ------------------ | 411| callback | AsyncCallback\<[bundle.DisplayOrientation](js-apis-bundleManager.md#displayorientation)> | Yes | Callback used to return the display orientation.| 412 413**Example** 414 415<!--code_no_check_fa--> 416```ts 417import featureAbility from '@ohos.ability.featureAbility'; 418 419let context: featureAbility.Context = featureAbility.getContext(); 420context.getDisplayOrientation((error, data) => { 421 if (error && error.code !== 0) { 422 console.error(`getDisplayOrientation fail, error: ${JSON.stringify(error)}`); 423 } else { 424 console.log(`getDisplayOrientation success, data: ${JSON.stringify(data)}`); 425 } 426}); 427``` 428 429## Context.getDisplayOrientation<sup>7+</sup> 430 431getDisplayOrientation(): Promise\<bundle.DisplayOrientation> 432 433Obtains the display orientation of this ability. This API uses a promise to return the result. 434 435**System capability**: SystemCapability.Ability.AbilityRuntime.Core 436 437**Return value** 438 439| Type | Description | 440| ---------------------------------------- | --------- | 441| Promise\<[bundle.DisplayOrientation](js-apis-bundleManager.md#displayorientation)> | Promise used to return the display orientation.| 442 443**Example** 444 445<!--code_no_check_fa--> 446```ts 447import featureAbility from '@ohos.ability.featureAbility'; 448 449let context: featureAbility.Context = featureAbility.getContext(); 450context.getDisplayOrientation().then((data) => { 451 console.info(`getDisplayOrientation data: ${JSON.stringify(data)}`); 452}); 453``` 454 455## Context.getExternalCacheDir<sup>(deprecated)</sup> 456 457getExternalCacheDir(callback: AsyncCallback\<string>): void 458 459Obtains the external cache directory of the application. This API uses an asynchronous callback to return the result. 460 461> **NOTE** 462> 463> This API is deprecated since API version 7. 464 465**System capability**: SystemCapability.Ability.AbilityRuntime.Core 466 467**Parameters** 468 469| Name | Type | Mandatory | Description | 470| -------- | ---------------------- | ---- | ------------------ | 471| callback | AsyncCallback\<string> | Yes | Callback used to return the absolute path of the cache directory.| 472 473**Example** 474 475<!--code_no_check_fa--> 476```ts 477import featureAbility from '@ohos.ability.featureAbility'; 478 479let context: featureAbility.Context = featureAbility.getContext(); 480context.getExternalCacheDir((error, data) => { 481 if (error && error.code !== 0) { 482 console.error(`getExternalCacheDir fail, error: ${JSON.stringify(error)}`); 483 } else { 484 console.log(`getExternalCacheDir success, data: ${JSON.stringify(data)}`); 485 } 486}); 487``` 488 489## Context.getExternalCacheDir<sup>(deprecated)</sup> 490 491getExternalCacheDir(): Promise\<string> 492 493Obtains the external cache directory of the application. This API uses a promise to return the result. 494 495> **NOTE** 496> 497> This API is deprecated since API version 7. 498 499**System capability**: SystemCapability.Ability.AbilityRuntime.Core 500 501**Return value** 502 503| Type | Description | 504| ---------------- | ---------------- | 505| Promise\<string> | Promise used to return the absolute path of the cache directory.| 506 507**Example** 508 509<!--code_no_check_fa--> 510```ts 511import featureAbility from '@ohos.ability.featureAbility'; 512 513let context: featureAbility.Context = featureAbility.getContext(); 514context.getExternalCacheDir().then((data) => { 515 console.info(`getExternalCacheDir data: ${JSON.stringify(data)}`); 516}); 517``` 518 519## Context.setDisplayOrientation<sup>7+</sup> 520 521setDisplayOrientation(orientation: bundle.DisplayOrientation, callback: AsyncCallback\<void>): void 522 523Sets the display orientation for this ability. This API uses an asynchronous callback to return the result. 524 525**System capability**: SystemCapability.Ability.AbilityRuntime.Core 526 527**Parameters** 528 529| Name | Type | Mandatory | Description | 530| ----------- | ---------------------------------------- | ---- | ------------ | 531| orientation | [bundle.DisplayOrientation](js-apis-bundleManager.md#displayorientation) | Yes | Display orientation to set.| 532| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**. Otherwise, **err** is an error object. | 533 534**Example** 535 536<!--code_no_check_fa--> 537```ts 538import featureAbility from '@ohos.ability.featureAbility'; 539import bundleManager from '@ohos.bundle'; 540 541let context: featureAbility.Context = featureAbility.getContext(); 542let orientation = bundleManager.DisplayOrientation.LANDSCAPE; 543context.setDisplayOrientation(orientation, (error) => { 544 console.error(`setDisplayOrientation fail, error: ${JSON.stringify(error)}`); 545}); 546``` 547 548## Context.setDisplayOrientation<sup>7+</sup> 549 550setDisplayOrientation(orientation: bundle.DisplayOrientation): Promise\<void> 551 552Sets the display orientation for this ability. This API uses a promise to return the result. 553 554**System capability**: SystemCapability.Ability.AbilityRuntime.Core 555 556**Parameters** 557 558| Name | Type | Mandatory | Description | 559| ---------------------------------------- | ---------------------------------------- | ---- | ------------ | 560| orientation | [bundle.DisplayOrientation](js-apis-bundleManager.md#displayorientation) | Yes | Callback used to return the display orientation. | 561 562**Return value** 563 564| Type | Description | 565| -------------- | ---------------- | 566| Promise\<void> | Promise that returns no value.| 567 568**Example** 569 570<!--code_no_check_fa--> 571```ts 572import featureAbility from '@ohos.ability.featureAbility'; 573import bundleManager from '@ohos.bundle'; 574 575let context: featureAbility.Context = featureAbility.getContext(); 576let orientation = bundleManager.DisplayOrientation.UNSPECIFIED; 577context.setDisplayOrientation(orientation).then((data) => { 578 console.info(`setDisplayOrientation data: ${JSON.stringify(data)}`); 579}); 580``` 581 582## Context.setShowOnLockScreen<sup>(deprecated)</sup> 583 584setShowOnLockScreen(show: boolean, callback: AsyncCallback\<void>): void 585 586Sets 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. 587 588> **NOTE** 589> 590> This API is deprecated since API version 9. You are advised to use **window.setShowOnLockScreen**, which is a system API. 591 592**System capability**: SystemCapability.Ability.AbilityRuntime.Core 593 594**Parameters** 595 596| Name | Type | Mandatory | Description | 597| -------- | -------------------- | ---- | ---------------------------------------- | 598| 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.| 599| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**. Otherwise, **err** is an error object. | 600 601**Example** 602 603<!--code_no_check_fa--> 604```ts 605import featureAbility from '@ohos.ability.featureAbility'; 606 607let context: featureAbility.Context = featureAbility.getContext(); 608let show = true; 609context.setShowOnLockScreen(show, (error) => { 610 console.error(`setShowOnLockScreen fail, error: ${JSON.stringify(error)}`); 611}); 612``` 613 614## Context.setShowOnLockScreen<sup>(deprecated)</sup> 615 616setShowOnLockScreen(show: boolean): Promise\<void> 617 618Sets 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. 619 620> **NOTE** 621> 622> This API is deprecated since API version 9. You are advised to use **window.setShowOnLockScreen**, which is a system API. 623 624**System capability**: SystemCapability.Ability.AbilityRuntime.Core 625 626**Parameters** 627 628| Name | Type | Mandatory | Description | 629| ---- | ------- | ---- | ---------------------------------------- | 630| 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.| 631 632**Return value** 633 634| Type | Description | 635| -------------- | --------------- | 636| Promise\<void> | Promise that returns no value.| 637 638**Example** 639 640<!--code_no_check_fa--> 641```ts 642import featureAbility from '@ohos.ability.featureAbility'; 643 644let context: featureAbility.Context = featureAbility.getContext(); 645let show = true; 646context.setShowOnLockScreen(show).then((data) => { 647 console.info(`setShowOnLockScreen data: ${JSON.stringify(data)}`); 648}); 649``` 650 651## Context.setWakeUpScreen<sup>(deprecated)</sup> 652 653setWakeUpScreen(wakeUp: boolean, callback: AsyncCallback\<void>): void 654 655Sets whether to wake up the screen when this feature is restored. This API uses an asynchronous callback to return the result. 656 657> **NOTE** 658> 659> This API is supported since API version 7 and deprecated since API version 12. Its substitute, **window.setWakeUpScreen**, is available only to system applications. 660 661**System capability**: SystemCapability.Ability.AbilityRuntime.Core 662 663**Parameters** 664 665| Name | Type | Mandatory | Description | 666| -------- | -------------------- | ---- | --------------------------------- | 667| wakeUp | boolean | Yes | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite.| 668| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**. Otherwise, **err** is an error object. | 669 670**Example** 671 672<!--code_no_check_fa--> 673```ts 674import featureAbility from '@ohos.ability.featureAbility'; 675 676let context: featureAbility.Context = featureAbility.getContext(); 677let wakeUp = true; 678context.setWakeUpScreen(wakeUp, (error) => { 679 console.error(`setWakeUpScreen fail, error: ${JSON.stringify(error)}`); 680}); 681``` 682 683## Context.setWakeUpScreen<sup>(deprecated)</sup> 684 685setWakeUpScreen(wakeUp: boolean): Promise\<void> 686 687Sets whether to wake up the screen when this feature is restored. This API uses a promise to return the result. 688 689> **NOTE** 690> 691> This API is supported since API version 7 and deprecated since API version 12. Its substitute **window.setWakeUpScreen** is available only to system applications. 692 693**System capability**: SystemCapability.Ability.AbilityRuntime.Core 694 695**Parameters** 696 697| Name | Type | Mandatory | Description | 698| ------ | ------- | ---- | --------------------------------- | 699| wakeUp | boolean | Yes | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite.| 700 701**Return value** 702 703| Type | Description | 704| -------------- | --------------- | 705| Promise\<void> | Promise that returns no value.| 706 707**Example** 708 709<!--code_no_check_fa--> 710```ts 711import featureAbility from '@ohos.ability.featureAbility'; 712 713let context: featureAbility.Context = featureAbility.getContext(); 714let wakeUp = true; 715context.setWakeUpScreen(wakeUp).then((data) => { 716 console.info(`setWakeUpScreen data: ${JSON.stringify(data)}`); 717}); 718``` 719 720 721 722 723## Context.getProcessInfo<sup>7+</sup> 724 725getProcessInfo(callback: AsyncCallback\<ProcessInfo>): void 726 727Obtains information about the current process, including the PID and process name. This API uses an asynchronous callback to return the result. 728 729**System capability**: SystemCapability.Ability.AbilityRuntime.Core 730 731**Parameters** 732 733| Name | Type | Mandatory | Description | 734| -------- | --------------------------- | ---- | ---------- | 735| callback | AsyncCallback\<[ProcessInfo](js-apis-inner-app-processInfo.md)> | Yes | Callback used to return the process information.| 736 737**Example** 738 739<!--code_no_check_fa--> 740```ts 741import featureAbility from '@ohos.ability.featureAbility'; 742 743let context: featureAbility.Context = featureAbility.getContext(); 744context.getProcessInfo((error, data) => { 745 if (error && error.code !== 0) { 746 console.error(`getProcessInfo fail, error: ${JSON.stringify(error)}`); 747 } else { 748 console.log(`getProcessInfo success, data: ${JSON.stringify(data)}`); 749 } 750}); 751``` 752 753 754 755## Context.getProcessInfo<sup>7+</sup> 756 757getProcessInfo(): Promise\<ProcessInfo> 758 759Obtains information about the current process, including the PID and process name. This API uses a promise to return the result. 760 761**System capability**: SystemCapability.Ability.AbilityRuntime.Core 762 763**Return value** 764 765| Type | Description | 766| --------------------- | ------- | 767| Promise\<[ProcessInfo](js-apis-inner-app-processInfo.md)> | Promise used to return the process information.| 768 769**Example** 770 771<!--code_no_check_fa--> 772```ts 773import featureAbility from '@ohos.ability.featureAbility'; 774 775let context: featureAbility.Context = featureAbility.getContext(); 776context.getProcessInfo().then((data) => { 777 console.info(`getProcessInfo data: ${JSON.stringify(data)}`); 778}); 779``` 780 781 782 783## Context.getElementName<sup>7+</sup> 784 785getElementName(callback: AsyncCallback\<ElementName>): void 786 787Obtains the element name of this ability. This API uses an asynchronous callback to return the result. 788 789This API is available only to Page abilities. 790 791**System capability**: SystemCapability.Ability.AbilityRuntime.Core 792 793**Parameters** 794 795| Name | Type | Mandatory | Description | 796| -------- | --------------------------- | ---- | -------------------------------------- | 797| callback | AsyncCallback\<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | Callback used to return the element name, which is an **ohos.bundleManager.ElementName** object.| 798 799**Example** 800 801<!--code_no_check_fa--> 802```ts 803import featureAbility from '@ohos.ability.featureAbility'; 804 805let context: featureAbility.Context = featureAbility.getContext(); 806context.getElementName((error, data) => { 807 if (error && error.code !== 0) { 808 console.error(`getElementName fail, error: ${JSON.stringify(error)}`); 809 } else { 810 console.log(`getElementName success, data: ${JSON.stringify(data)}`); 811 } 812}); 813``` 814 815 816 817## Context.getElementName<sup>7+</sup> 818 819getElementName(): Promise\<ElementName> 820 821Obtains the element name of this ability. This API uses a promise to return the result. 822 823This API is available only to Page abilities. 824 825**System capability**: SystemCapability.Ability.AbilityRuntime.Core 826 827**Return value** 828 829| Type | Description | 830| --------------------- | ------------------------------------ | 831| Promise\<[ElementName](js-apis-bundleManager-elementName.md)> | Promise used to return the element name, which is an **ohos.bundleManager.ElementName** object.| 832 833**Example** 834 835<!--code_no_check_fa--> 836```ts 837import featureAbility from '@ohos.ability.featureAbility'; 838 839let context: featureAbility.Context = featureAbility.getContext(); 840context.getElementName().then((data) => { 841 console.info(`getElementName data: ${JSON.stringify(data)}`); 842}); 843``` 844 845## Context.getProcessName<sup>7+</sup> 846 847getProcessName(callback: AsyncCallback\<string>): void 848 849Obtains the name of the current process. This API uses an asynchronous callback to return the result. 850 851**System capability**: SystemCapability.Ability.AbilityRuntime.Core 852 853**Parameters** 854 855| Name | Type | Mandatory | Description | 856| -------- | ---------------------- | ---- | ---------- | 857| callback | AsyncCallback\<string> | Yes | Callback used to return the process name.| 858 859**Example** 860 861<!--code_no_check_fa--> 862```ts 863import featureAbility from '@ohos.ability.featureAbility'; 864 865let context: featureAbility.Context = featureAbility.getContext(); 866context.getProcessName((error, data) => { 867 if (error && error.code !== 0) { 868 console.error(`getProcessName fail, error: ${JSON.stringify(error)}`); 869 } else { 870 console.log(`getProcessName success, data: ${JSON.stringify(data)}`); 871 } 872}); 873``` 874 875 876 877## Context.getProcessName<sup>7+</sup> 878 879getProcessName(): Promise\<string> 880 881Obtains the name of the current process. This API uses a promise to return the result. 882 883**System capability**: SystemCapability.Ability.AbilityRuntime.Core 884 885**Return value** 886 887| Type | Description | 888| ---------------- | ---------- | 889| Promise\<string> | Promise used to return the process name.| 890 891**Example** 892 893<!--code_no_check_fa--> 894```ts 895import featureAbility from '@ohos.ability.featureAbility'; 896 897let context: featureAbility.Context = featureAbility.getContext(); 898context.getProcessName().then((data) => { 899 console.info(`getProcessName data: ${JSON.stringify(data)}`); 900}); 901``` 902 903 904 905## Context.getCallingBundle<sup>7+</sup> 906 907getCallingBundle(callback: AsyncCallback\<string>): void 908 909Obtains the bundle name of the caller ability. This API uses an asynchronous callback to return the result. 910 911**System capability**: SystemCapability.Ability.AbilityRuntime.Core 912 913**Parameters** 914 915| Name | Type | Mandatory | Description | 916| -------- | ---------------------- | ---- | ---------------- | 917| callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name.| 918 919**Example** 920 921<!--code_no_check_fa--> 922```ts 923import featureAbility from '@ohos.ability.featureAbility'; 924 925let context: featureAbility.Context = featureAbility.getContext(); 926context.getCallingBundle((error, data) => { 927 if (error && error.code !== 0) { 928 console.error(`getCallingBundle fail, error: ${JSON.stringify(error)}`); 929 } else { 930 console.log(`getCallingBundle success, data: ${JSON.stringify(data)}`); 931 } 932}); 933``` 934 935 936 937## Context.getCallingBundle<sup>7+</sup> 938 939getCallingBundle(): Promise\<string> 940 941Obtains the bundle name of the caller ability. This API uses a promise to return the result. 942 943**System capability**: SystemCapability.Ability.AbilityRuntime.Core 944 945**Return value** 946 947| Type | Description | 948| ---------------- | -------------- | 949| Promise\<string> | Promise used to return the bundle name.| 950 951**Example** 952 953<!--code_no_check_fa--> 954```ts 955import featureAbility from '@ohos.ability.featureAbility'; 956 957let context: featureAbility.Context = featureAbility.getContext(); 958context.getCallingBundle().then((data) => { 959 console.info(`getCallingBundle data: ${JSON.stringify(data)}`); 960}); 961``` 962 963## Context.getCacheDir 964 965getCacheDir(callback: AsyncCallback\<string>): void 966 967Obtains the cache directory of the application in the internal storage. This API uses an asynchronous callback to return the result. 968 969**System capability**: SystemCapability.Ability.AbilityRuntime.Core 970 971**Parameters** 972 973| Name | Type | Mandatory | Description | 974| -------- | ---------------------- | ---- | --------------- | 975| callback | AsyncCallback\<string> | Yes | Callback used to return the cache directory.| 976 977**Example** 978 979<!--code_no_check_fa--> 980```ts 981import featureAbility from '@ohos.ability.featureAbility'; 982 983let context: featureAbility.Context = featureAbility.getContext(); 984context.getCacheDir((error, data) => { 985 if (error && error.code !== 0) { 986 console.error(`getCacheDir fail, error: ${JSON.stringify(error)}`); 987 } else { 988 console.log(`getCacheDir success, data: ${JSON.stringify(data)}`); 989 } 990}); 991``` 992 993## Context.getCacheDir 994 995getCacheDir(): Promise\<string> 996 997Obtains the cache directory of the application in the internal storage. This API uses a promise to return the result. 998 999**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1000 1001**Return value** 1002 1003| Type | Description | 1004| ---------------- | --------------- | 1005| Promise\<string> | Promise used to return the cache directory.| 1006 1007**Example** 1008 1009<!--code_no_check_fa--> 1010```ts 1011import featureAbility from '@ohos.ability.featureAbility'; 1012 1013let context: featureAbility.Context = featureAbility.getContext(); 1014context.getCacheDir().then((data) => { 1015 console.info(`getCacheDir data: ${JSON.stringify(data)}`); 1016}); 1017``` 1018 1019## Context.getFilesDir 1020 1021getFilesDir(callback: AsyncCallback\<string>): void 1022 1023Obtains the file directory of the application in the internal storage. This API uses an asynchronous callback to return the result. 1024 1025**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1026 1027**Parameters** 1028 1029| Name | Type | Mandatory | Description | 1030| -------- | ---------------------- | ---- | ------------------- | 1031| callback | AsyncCallback\<string> | Yes | Callback used to return the file directory.| 1032 1033**Example** 1034 1035<!--code_no_check_fa--> 1036```ts 1037import featureAbility from '@ohos.ability.featureAbility'; 1038 1039let context: featureAbility.Context = featureAbility.getContext(); 1040context.getFilesDir((error, data) => { 1041 if (error && error.code !== 0) { 1042 console.error(`getFilesDir fail, error: ${JSON.stringify(error)}`); 1043 } else { 1044 console.log(`getFilesDir success, data: ${JSON.stringify(data)}`); 1045 } 1046}); 1047``` 1048 1049## Context.getFilesDir 1050 1051getFilesDir(): Promise\<string> 1052 1053Obtains the file directory of the application in the internal storage. This API uses a promise to return the result. 1054 1055**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1056 1057**Return value** 1058 1059| Type | Description | 1060| ---------------- | ------------------- | 1061| Promise\<string> | Promise used to return the file directory.| 1062 1063**Example** 1064 1065<!--code_no_check_fa--> 1066```ts 1067import featureAbility from '@ohos.ability.featureAbility'; 1068 1069let context: featureAbility.Context = featureAbility.getContext(); 1070context.getFilesDir().then((data) => { 1071 console.info(`getFilesDir data: ${JSON.stringify(data)}`); 1072}); 1073``` 1074 1075## Context.getOrCreateDistributedDir<sup>7+</sup> 1076 1077getOrCreateDistributedDir(callback: AsyncCallback\<string>): void 1078 1079Obtains the distributed file path for storing ability or application data files. This API uses an asynchronous callback to return the result. 1080 1081If the distributed file path does not exist, the system will create a path and return the created path. 1082 1083**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1084 1085**Parameters** 1086 1087| Name | Type | Mandatory | Description | 1088| -------- | ---------------------- | ---- | ---------------------------------------- | 1089| callback | AsyncCallback\<string> | Yes | Callback used to return the distributed file path.<br>If the path does not exist, the system will create one and return the created path.| 1090 1091**Example** 1092 1093<!--code_no_check_fa--> 1094```ts 1095import featureAbility from '@ohos.ability.featureAbility'; 1096 1097let context: featureAbility.Context = featureAbility.getContext(); 1098context.getOrCreateDistributedDir((error, data) => { 1099 if (error && error.code !== 0) { 1100 console.error(`getOrCreateDistributedDir fail, error: ${JSON.stringify(error)}`); 1101 } else { 1102 console.log(`getOrCreateDistributedDir success, data: ${JSON.stringify(data)}`); 1103 } 1104}); 1105``` 1106 1107## Context.getOrCreateDistributedDir<sup>7+</sup> 1108 1109getOrCreateDistributedDir(): Promise\<string> 1110 1111Obtains the distributed file path for storing ability or application data files. This API uses a promise to return the result. 1112 1113If the distributed file path does not exist, the system will create a path and return the created path. 1114 1115**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1116 1117**Return value** 1118 1119| Type | Description | 1120| ---------------- | ----------------------------------- | 1121| Promise\<string> | Promise used to return the distributed file path. If this API is called for the first time, a path will be created.| 1122 1123**Example** 1124 1125<!--code_no_check_fa--> 1126```ts 1127import featureAbility from '@ohos.ability.featureAbility'; 1128 1129let context: featureAbility.Context = featureAbility.getContext(); 1130context.getOrCreateDistributedDir().then((data) => { 1131 console.info(`getOrCreateDistributedDir data: ${JSON.stringify(data)}`); 1132}); 1133``` 1134 1135## Context.getAppType<sup>7+</sup> 1136 1137getAppType(callback: AsyncCallback\<string>): void 1138 1139Obtains the application type. This API uses an asynchronous callback to return the result. 1140 1141**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1142 1143**Parameters** 1144 1145| Name | Type | Mandatory | Description | 1146| -------- | ---------------------- | ---- | -------------------------------- | 1147| callback | AsyncCallback\<string> | Yes | Callback used to return the application type.| 1148 1149**Example** 1150 1151<!--code_no_check_fa--> 1152```ts 1153import featureAbility from '@ohos.ability.featureAbility'; 1154 1155let context: featureAbility.Context = featureAbility.getContext(); 1156context.getAppType((error, data) => { 1157 if (error && error.code !== 0) { 1158 console.error(`getAppType fail, error: ${JSON.stringify(error)}`); 1159 } else { 1160 console.log(`getAppType success, data: ${JSON.stringify(data)}`); 1161 } 1162}); 1163``` 1164 1165## Context.getAppType<sup>7+</sup> 1166 1167getAppType(): Promise\<string> 1168 1169Obtains the application type. This API uses a promise to return the result. 1170 1171**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1172 1173**Return value** 1174 1175| Type | Description | 1176| ---------------- | ------------------ | 1177| Promise\<string> | Promise used to return the application type.| 1178 1179**Example** 1180 1181<!--code_no_check_fa--> 1182```ts 1183import featureAbility from '@ohos.ability.featureAbility'; 1184 1185let context: featureAbility.Context = featureAbility.getContext(); 1186context.getAppType().then((data) => { 1187 console.info(`getAppType data: ${JSON.stringify(data)}`); 1188}); 1189``` 1190 1191## Context.getHapModuleInfo<sup>7+</sup> 1192 1193getHapModuleInfo(callback: AsyncCallback\<HapModuleInfo>): void 1194 1195Obtains the module information of the application. This API uses an asynchronous callback to return the result. 1196 1197**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1198 1199**Parameters** 1200 1201| Name | Type | Mandatory | Description | 1202| -------- | ---------------------------------------- | ---- | --------------------------------------- | 1203| callback | AsyncCallback\<[HapModuleInfo](js-apis-bundleManager-hapModuleInfo.md)> | Yes | Callback used to return the module information, which is a **HapModuleInfo** object.| 1204 1205**Example** 1206 1207<!--code_no_check_fa--> 1208```ts 1209import featureAbility from '@ohos.ability.featureAbility'; 1210 1211let context: featureAbility.Context = featureAbility.getContext(); 1212context.getHapModuleInfo((error, data) => { 1213 if (error && error.code !== 0) { 1214 console.error(`getHapModuleInfo fail, error: ${JSON.stringify(error)}`); 1215 } else { 1216 console.log(`getHapModuleInfo success, data: ${JSON.stringify(data)}`); 1217 } 1218}); 1219``` 1220 1221## Context.getHapModuleInfo<sup>7+</sup> 1222 1223getHapModuleInfo(): Promise\<HapModuleInfo> 1224 1225Obtains the module information of the application. This API uses a promise to return the result. 1226 1227**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1228 1229**Return value** 1230 1231| Type | Description | 1232| ---------------------------------------- | ------------------ | 1233| Promise\<[HapModuleInfo](js-apis-bundleManager-hapModuleInfo.md)> | Promise used to return the module information, which is a **HapModuleInfo** object.| 1234 1235**Example** 1236 1237<!--code_no_check_fa--> 1238```ts 1239import featureAbility from '@ohos.ability.featureAbility'; 1240 1241let context: featureAbility.Context = featureAbility.getContext(); 1242context.getHapModuleInfo().then((data) => { 1243 console.info(`getHapModuleInfo data: ${JSON.stringify(data)}`); 1244}); 1245``` 1246 1247## Context.getAppVersionInfo<sup>7+</sup> 1248 1249getAppVersionInfo(callback: AsyncCallback\<AppVersionInfo>): void 1250 1251Obtains the version information of the application. This API uses an asynchronous callback to return the result. 1252 1253**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1254 1255**Parameters** 1256 1257| Name | Type | Mandatory | Description | 1258| -------- | ---------------------------------------- | ---- | ------------------------------ | 1259| callback | AsyncCallback\<[AppVersionInfo](js-apis-inner-app-appVersionInfo.md)> | Yes | Callback used to return the version information.| 1260 1261**Example** 1262 1263<!--code_no_check_fa--> 1264```ts 1265import featureAbility from '@ohos.ability.featureAbility'; 1266 1267let context: featureAbility.Context = featureAbility.getContext(); 1268context.getAppVersionInfo((error, data) => { 1269 if (error && error.code !== 0) { 1270 console.error(`getAppVersionInfo fail, error: ${JSON.stringify(error)}`); 1271 } else { 1272 console.log(`getAppVersionInfo success, data: ${JSON.stringify(data)}`); 1273 } 1274}); 1275``` 1276 1277## Context.getAppVersionInfo<sup>7+</sup> 1278 1279getAppVersionInfo(): Promise\<AppVersionInfo> 1280 1281Obtains the version information of the application. This API uses a promise to return the result. 1282 1283**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1284 1285**Return value** 1286 1287| Type | Description | 1288| ---------------------------------------- | --------- | 1289| Promise\<[AppVersionInfo](js-apis-inner-app-appVersionInfo.md)> | Promise used to return the version information.| 1290 1291**Example** 1292 1293<!--code_no_check_fa--> 1294```ts 1295import featureAbility from '@ohos.ability.featureAbility'; 1296 1297let context: featureAbility.Context = featureAbility.getContext(); 1298context.getAppVersionInfo().then((data) => { 1299 console.info(`getAppVersionInfo data: ${JSON.stringify(data)}`); 1300}); 1301``` 1302 1303## Context.getAbilityInfo<sup>7+</sup> 1304 1305getAbilityInfo(callback: AsyncCallback\<AbilityInfo>): void 1306 1307Obtains information about this ability. This API uses an asynchronous callback to return the result. 1308 1309**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1310 1311**Parameters** 1312 1313| Name | Type | Mandatory | Description | 1314| -------- | ---------------------------------------- | ---- | --------------------------------------- | 1315| callback | AsyncCallback\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)> | Yes | Callback used to return the ability information.| 1316 1317**Example** 1318 1319<!--code_no_check_fa--> 1320```ts 1321import featureAbility from '@ohos.ability.featureAbility'; 1322 1323let context: featureAbility.Context = featureAbility.getContext(); 1324context.getAbilityInfo((error, data) => { 1325 if (error && error.code !== 0) { 1326 console.error(`getAbilityInfo fail, error: ${JSON.stringify(error)}`); 1327 } else { 1328 console.log(`getAbilityInfo success, data: ${JSON.stringify(data)}`); 1329 } 1330}); 1331``` 1332 1333## Context.getAbilityInfo<sup>7+</sup> 1334 1335getAbilityInfo(): Promise\<AbilityInfo> 1336 1337Obtains information about this ability. This API uses a promise to return the result. 1338 1339**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1340 1341**Return value** 1342 1343| Type | Description | 1344| ---------------------------------------- | ------------------ | 1345| Promise\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)> | Promise used to return the ability information.| 1346 1347**Example** 1348 1349<!--code_no_check_fa--> 1350```ts 1351import featureAbility from '@ohos.ability.featureAbility'; 1352 1353let context: featureAbility.Context = featureAbility.getContext(); 1354context.getAbilityInfo().then((data) => { 1355 console.info(`getAbilityInfo data: ${JSON.stringify(data)}`); 1356}); 1357``` 1358 1359## Context.getApplicationContext<sup>7+</sup> 1360 1361getApplicationContext(): Context 1362 1363Obtains the context of the application. 1364 1365**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1366 1367**Return value** 1368 1369| Type | Description | 1370| ------- | ---------- | 1371| Context | Application context.| 1372 1373**Example** 1374 1375<!--code_no_check_fa--> 1376```ts 1377import featureAbility from '@ohos.ability.featureAbility'; 1378 1379let context: featureAbility.Context = featureAbility.getContext().getApplicationContext(); 1380``` 1381 1382## Context.isUpdatingConfigurations<sup>7+</sup> 1383 1384isUpdatingConfigurations(callback: AsyncCallback\<boolean>): void 1385 1386Checks whether the configuration of this ability is being updated. This API uses an asynchronous callback to return the result. 1387 1388**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1389 1390**Parameters** 1391 1392| Name | Type | Mandatory | Description | 1393| -------- | ----------------------- | ---- | ----------------------------- | 1394| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the configuration of the ability is being updated, and **false** means the opposite.| 1395 1396**Example** 1397 1398<!--code_no_check_fa--> 1399```ts 1400import featureAbility from '@ohos.ability.featureAbility'; 1401 1402let context: featureAbility.Context = featureAbility.getContext(); 1403context.isUpdatingConfigurations((error, data) => { 1404 if (error && error.code !== 0) { 1405 console.error(`isUpdatingConfigurations fail, error: ${JSON.stringify(error)}`); 1406 } else { 1407 console.log(`isUpdatingConfigurations success, data: ${JSON.stringify(data)}`); 1408 } 1409}); 1410``` 1411 1412## Context.isUpdatingConfigurations<sup>7+</sup> 1413 1414isUpdatingConfigurations(): Promise\<boolean> 1415 1416Checks whether the configuration of this ability is being updated. This API uses a promise to return the result. 1417 1418**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1419 1420**Return value** 1421 1422| Type | Description | 1423| ----------------- | ----------------------------- | 1424| Promise\<boolean> | Promise used to return the result. The value **true** means that the configuration of the ability is being updated, and **false** means the opposite.| 1425 1426**Example** 1427 1428<!--code_no_check_fa--> 1429```ts 1430import featureAbility from '@ohos.ability.featureAbility'; 1431 1432let context: featureAbility.Context = featureAbility.getContext(); 1433context.isUpdatingConfigurations().then((data) => { 1434 console.info(`isUpdatingConfigurations data: ${JSON.stringify(data)}`); 1435}); 1436``` 1437 1438## Context.printDrawnCompleted<sup>7+</sup> 1439 1440printDrawnCompleted(callback: AsyncCallback\<void>): void 1441 1442Notifies the system of the time required to draw this page function. This API uses an asynchronous callback to return the result. 1443 1444**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1445 1446**Parameters** 1447 1448| Name | Type | Mandatory | Description | 1449| -------- | -------------------- | ---- | ----------- | 1450| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the notification is successful, **err** is **undefined**. Otherwise, **err** is an error object.| 1451 1452**Example** 1453 1454<!--code_no_check_fa--> 1455```ts 1456import featureAbility from '@ohos.ability.featureAbility'; 1457 1458let context: featureAbility.Context = featureAbility.getContext(); 1459context.printDrawnCompleted((err) => { 1460 console.error(`printDrawnCompleted err: ${JSON.stringify(err)}`); 1461}); 1462``` 1463 1464## Context.printDrawnCompleted<sup>7+</sup> 1465 1466printDrawnCompleted(): Promise\<void> 1467 1468Notifies the system of the time required to draw this page function. This API uses a promise to return the result. 1469 1470**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1471 1472**Return value** 1473 1474| Type | Description | 1475| -------------- | --------------- | 1476| Promise\<void> | Promise that returns no value.| 1477 1478**Example** 1479 1480<!--code_no_check_fa--> 1481```ts 1482import featureAbility from '@ohos.ability.featureAbility'; 1483 1484let context: featureAbility.Context = featureAbility.getContext(); 1485context.printDrawnCompleted().then((data) => { 1486 console.info(`printDrawnCompleted data: ${JSON.stringify(data)}`); 1487}); 1488``` 1489 1490 1491## PermissionOptions<sup>7+</sup> 1492 1493**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1494 1495| Name | Type | Mandatory | Description | 1496| ---- | ------ | ---- | ----- | 1497| pid |number | No | Process ID.| 1498| uid |number | No | User ID.| 1499 1500## PermissionRequestResult<sup>7+</sup> 1501 1502**System capability**: SystemCapability.Ability.AbilityRuntime.Core 1503 1504| Name | Type | Mandatory | Description | 1505| ----------- |-------------- | ---- | ---------- | 1506| requestCode | number | Yes | Request code passed.| 1507| permissions | Array\<string> | Yes | Permissions requested. | 1508| authResults | Array\<number> | Yes | Permission request result. | 1509