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**Atomic service API**: This API can be used in atomic services since API version 11.
22
23**System capability**: SystemCapability.Ability.AbilityRuntime.Core
24
25| Name | Value| Description                                                                                                                  |
26|-----| -------- |----------------------------------------------------------------------------------------------------------------------|
27| EL1 | 0 | Device-level encryption. Directories with this encryption level are accessible after the device is powered on.                                                                                                |
28| 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).                                                                                       |
29| 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.|
30| 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 readable and writable in FEB2.0, but not in FEB3.0. When the screen is unlocked, such a file is always 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.       |
31| 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.|
32
33
34## ProcessMode<sup>12+</sup>
35
36Enumerates the process modes. It takes effect only on tablets.
37
38As 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.
39
40**System capability**: SystemCapability.Ability.AbilityRuntime.Core
41
42| Name | Value| Description                                                                                                                  |
43|-----| -------- |----------------------------------------------------------------------------------------------------------------------|
44| 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.                    |
45| 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.                 |
46| 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.                 |
47
48**Example**
49
50  ```ts
51  import { UIAbility, Want, StartOptions, contextConstant } from '@kit.AbilityKit';
52  import { BusinessError } from '@kit.BasicServicesKit';
53
54  export default class EntryAbility extends UIAbility {
55    onForeground() {
56      let want: Want = {
57        deviceId: '',
58        bundleName: 'com.example.myapplication',
59        abilityName: 'MainAbility2'
60      };
61      let options: StartOptions = {
62        processMode: contextConstant.ProcessMode.NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM,
63        startupVisibility: contextConstant.StartupVisibility.STARTUP_HIDE
64      };
65
66      try {
67        this.context.startAbility(want, options, (err: BusinessError) => {
68          if (err.code) {
69            // Process service logic errors.
70            console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
71            return;
72          }
73          // Carry out normal service processing.
74          console.info('startAbility succeed');
75        });
76      } catch (err) {
77        // Process input parameter errors.
78        let code = (err as BusinessError).code;
79        let message = (err as BusinessError).message;
80        console.error(`startAbility failed, code is ${code}, message is ${message}`);
81      }
82    }
83  }
84  ```
85
86## StartupVisibility<sup>12+</sup>
87
88Enumerates the visibility statuses of an ability after it is started. It takes effect only on tablets.
89
90As 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.
91
92**System capability**: SystemCapability.Ability.AbilityRuntime.Core
93
94| Name | Value| Description                                                                                                                  |
95|-----| -------- |----------------------------------------------------------------------------------------------------------------------|
96| 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.       |
97| STARTUP_SHOW | 1 | The target ability is displayed normally after it is started in the new process.    |
98
99**Example**
100
101  See [ContextConstant.ProcessMode](#processmode12).
102