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