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