1# @ohos.app.ability.contextConstant (ContextConstant)
2
3The **ContextConstant** module defines context-related enums. Currently, it defines only the enum of encryption levels.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 9. 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 stage model.
10
11## Modules to Import
12
13```ts
14import { contextConstant } from '@kit.AbilityKit';
15```
16
17## AreaMode
18
19Enumerates the data encryption levels.
20
21**System capability**: SystemCapability.Ability.AbilityRuntime.Core
22
23| Name | Value| Description                                                                                                                  |
24|-----| -------- |----------------------------------------------------------------------------------------------------------------------|
25| EL1 | 0 | Device-level encryption. Directories with this encryption level are accessible after the device is powered on.<br>**Atomic service API**: This API can be used in atomic services since API version 11.   |
26| EL2 | 1 | User-level encryption. Directories with this encryption level are accessible only after the device is powered on and the password is entered (for the first time).<br>**Atomic service API**: This API can be used in atomic services since API version 11.      |
27| EL3<sup>11+<sup> | 2 | User-level encryption. The file permissions vary according to their scenarios.<br>- An open file is always readable and writable regardless of whether the screen is locked.<br>- When the screen is locked, a closed file cannot be opened, read, or written. When the screen is unlocked, such a file can be opened, read, and written.<br>- When the screen is locked, a file can be created and then opened and written but not read. When the screen is unlocked, a file can be created and then opened, read, and written.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
28| EL4<sup>11+<sup> | 3 | User-level encryption. The file permissions vary according to their scenarios.<br>- When the screen is locked, an open file is not readable or writable. When the screen is unlocked, such a file is readable and writable.<br>- When the screen is locked, a closed file cannot be opened, read, or written. When the screen is unlocked, such a file can be opened, read, and written.<br>- When the screen is locked, a file cannot be created. When the screen is unlocked, a file can be created and then opened, read, and written.<br>**Atomic service API**: This API can be used in atomic services since API version 11. |
29| EL5<sup>12+<sup> | 4 | Application-level encryption. The file permissions vary according to their scenarios.<br>- An open file is always readable and writable regardless of whether the screen is locked.<br>When the screen is locked, a closed file can be opened, read, and written only if the reserved key is obtained by calling [Access](js-apis-screenLockFileManager.md#screenlockfilemanageracquireaccess). When the screen is unlocked, such a file can be opened, read, and written.<br>A file can be created and then opened, read, and written regardless of whether the screen is locked.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
30
31
32## ProcessMode<sup>12+</sup>
33
34Enumerates the process modes. It takes effect only on tablets.
35
36As a property of [StartOptions](js-apis-app-ability-startOptions.md), **ProcessMode** takes effect only in [UIAbilityContext.startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1) and is used to specify the process mode of the target ability.
37
38**System capability**: SystemCapability.Ability.AbilityRuntime.Core
39
40| Name | Value| Description                                                                                                                  |
41|-----| -------- |----------------------------------------------------------------------------------------------------------------------|
42| NEW_PROCESS_ATTACH_TO_PARENT | 1 | A new process is created, the ability is started on the process, and the process exits along with the parent process.<br>**Constraints**:<br>In this mode, the target ability and caller must be in the same application.                    |
43| NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM | 2 | A new process is created, the ability is started on the process, and the process is bound to the status bar icon.<br>**Constraints**:<br>In this mode, the target ability and caller must be in the same application, and the application must have an icon in the status bar.                 |
44| ATTACH_TO_STATUS_BAR_ITEM | 3 | The ability is started, and the process of the ability is bound to the status bar icon.<br>**Constraints**:<br>In this mode, the target ability and caller must be in the same application, and the application must have an icon in the status bar.                 |
45
46**Example**
47
48  ```ts
49  import { UIAbility, Want, StartOptions, contextConstant } from '@kit.AbilityKit';
50  import { BusinessError } from '@kit.BasicServicesKit';
51
52  export default class EntryAbility extends UIAbility {
53    onForeground() {
54      let want: Want = {
55        deviceId: '',
56        bundleName: 'com.example.myapplication',
57        abilityName: 'MainAbility2'
58      };
59      let options: StartOptions = {
60        processMode: contextConstant.ProcessMode.NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM,
61        startupVisibility: contextConstant.StartupVisibility.STARTUP_HIDE
62      };
63
64      try {
65        this.context.startAbility(want, options, (err: BusinessError) => {
66          if (err.code) {
67            // Process service logic errors.
68            console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
69            return;
70          }
71          // Carry out normal service processing.
72          console.info('startAbility succeed');
73        });
74      } catch (err) {
75        // Process input parameter errors.
76        let code = (err as BusinessError).code;
77        let message = (err as BusinessError).message;
78        console.error(`startAbility failed, code is ${code}, message is ${message}`);
79      }
80    }
81  }
82  ```
83
84## StartupVisibility<sup>12+</sup>
85
86Enumerates the visibility statuses of an ability after it is started. It takes effect only on tablets.
87
88As a property of [StartOptions](js-apis-app-ability-startOptions.md), **StartupVisibility** takes effect only in [UIAbilityContext.startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1) and specifies the visibility of the target ability after it is started.
89
90**System capability**: SystemCapability.Ability.AbilityRuntime.Core
91
92| Name | Value| Description                                                                                                                  |
93|-----| -------- |----------------------------------------------------------------------------------------------------------------------|
94| STARTUP_HIDE | 0 | The target ability is hidden after it is started in the new process. The **onForeground** lifecycle of the ability is not invoked.       |
95| STARTUP_SHOW | 1 | The target ability is displayed normally after it is started in the new process.    |
96
97**Example**
98
99  See [ContextConstant.ProcessMode](#processmode12).
100