1e41f4b71Sopenharmony_ci# @system.brightness (Screen Brightness) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **brightness** module provides APIs for querying and adjusting the screen brightness and mode. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> - The APIs of this module are no longer maintained since API version 7.<!--Del--> You are advised to use APIs of [@ohos.brightness](js-apis-brightness-sys.md). <!--DelEnd-->The substitute APIs are available only for system applications. 8e41f4b71Sopenharmony_ci> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## Modules to Import 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci```js 15e41f4b71Sopenharmony_ciimport brightness, { BrightnessModeResponse, BrightnessResponse } from '@system.brightness'; 16e41f4b71Sopenharmony_ci``` 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci## brightness.getValue<sup>(deprecated)</sup> 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_cigetValue(options?: GetBrightnessOptions): void 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciObtains the current screen brightness. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**Parameters** 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 30e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 31e41f4b71Sopenharmony_ci| options | [GetBrightnessOptions](#getbrightnessoptionsdeprecated) | No | Options for obtaining the screen brightness. This parameter is optional and is left blank by default.| 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci**Example** 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci ```js 36e41f4b71Sopenharmony_ci brightness.getValue({ 37e41f4b71Sopenharmony_ci success: (data: BrightnessResponse) => { 38e41f4b71Sopenharmony_ci console.log('success get brightness value:' + data.value); 39e41f4b71Sopenharmony_ci }, 40e41f4b71Sopenharmony_ci fail: (data: string, code: number) => { 41e41f4b71Sopenharmony_ci console.error('get brightness fail, code: ' + code + ', data: ' + data); 42e41f4b71Sopenharmony_ci } 43e41f4b71Sopenharmony_ci }); 44e41f4b71Sopenharmony_ci ``` 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci## brightness.setValue<sup>(deprecated)</sup> 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_cisetValue(options?: SetBrightnessOptions): void 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ciSets the screen brightness. 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci**Parameters** 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 58e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 59e41f4b71Sopenharmony_ci| options | [SetBrightnessOptions](#setbrightnessoptionsdeprecated) | No | Options for setting the screen brightness. This parameter is optional and is left blank by default.| 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci**Example** 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci ```js 64e41f4b71Sopenharmony_ci brightness.setValue({ 65e41f4b71Sopenharmony_ci value: 100, 66e41f4b71Sopenharmony_ci success: () => { 67e41f4b71Sopenharmony_ci console.log('handling set brightness success.'); 68e41f4b71Sopenharmony_ci }, 69e41f4b71Sopenharmony_ci fail: (data: string, code: number) => { 70e41f4b71Sopenharmony_ci console.error('handling set brightness value fail, code:' + code + ', data: ' + data); 71e41f4b71Sopenharmony_ci } 72e41f4b71Sopenharmony_ci }); 73e41f4b71Sopenharmony_ci ``` 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ci## brightness.getMode<sup>(deprecated)</sup> 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_cigetMode(options?: GetBrightnessModeOptions): void 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ciObtains the screen brightness adjustment mode. 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci**Parameters** 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 87e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 88e41f4b71Sopenharmony_ci| options | [GetBrightnessModeOptions](#getbrightnessmodeoptionsdeprecated) | No| Options for obtaining the screen brightness mode. This parameter is optional and is left blank by default.| 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci**Example** 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci ```js 93e41f4b71Sopenharmony_ci brightness.getMode({ 94e41f4b71Sopenharmony_ci success: (data: BrightnessModeResponse) => { 95e41f4b71Sopenharmony_ci console.log('success get mode:' + data.mode); 96e41f4b71Sopenharmony_ci }, 97e41f4b71Sopenharmony_ci fail: (data: string, code: number) => { 98e41f4b71Sopenharmony_ci console.error('handling get mode fail, code:' + code + ', data: ' + data); 99e41f4b71Sopenharmony_ci } 100e41f4b71Sopenharmony_ci }); 101e41f4b71Sopenharmony_ci ``` 102e41f4b71Sopenharmony_ci 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci## brightness.setMode<sup>(deprecated)</sup> 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_cisetMode(options?: SetBrightnessModeOptions): void 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ciSets the screen brightness adjustment mode. 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci**Parameters** 113e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 114e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 115e41f4b71Sopenharmony_ci| options | [SetBrightnessModeOptions](#setbrightnessmodeoptionsdeprecated) | No | Options for setting the screen brightness mode. This parameter is optional and is left blank by default.| 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ci**Example** 118e41f4b71Sopenharmony_ci 119e41f4b71Sopenharmony_ci ```js 120e41f4b71Sopenharmony_ci brightness.setMode({ 121e41f4b71Sopenharmony_ci mode: 1, 122e41f4b71Sopenharmony_ci success: () => { 123e41f4b71Sopenharmony_ci console.log('handling set mode success.'); 124e41f4b71Sopenharmony_ci }, 125e41f4b71Sopenharmony_ci fail: (data: string, code: number) => { 126e41f4b71Sopenharmony_ci console.error('handling set mode fail, code:' + code + ', data: ' + data); 127e41f4b71Sopenharmony_ci } 128e41f4b71Sopenharmony_ci }); 129e41f4b71Sopenharmony_ci ``` 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ci## brightness.setKeepScreenOn<sup>(deprecated)</sup> 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_cisetKeepScreenOn(options?: SetKeepScreenOnOptions): void 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci>This API is no longer maintained since API version 7. You are advised to use [window.setWindowKeepScreenOn()](../apis-arkui/js-apis-window.md#setwindowkeepscreenon9). 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ciSets whether to always keep the screen on. Call this API in **onShow()**. 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci**Parameters** 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 145e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 146e41f4b71Sopenharmony_ci| options | [SetKeepScreenOnOptions](#setkeepscreenonoptionsdeprecated) | No| Options for setting the screen to be steady on. This parameter is optional and is left blank by default.| 147e41f4b71Sopenharmony_ci 148e41f4b71Sopenharmony_ci**Example** 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci ```js 151e41f4b71Sopenharmony_ci brightness.setKeepScreenOn({ 152e41f4b71Sopenharmony_ci keepScreenOn: true, 153e41f4b71Sopenharmony_ci success: () => { 154e41f4b71Sopenharmony_ci console.log('handling set keep screen on success.'); 155e41f4b71Sopenharmony_ci }, 156e41f4b71Sopenharmony_ci fail: (data: string, code: number) => { 157e41f4b71Sopenharmony_ci console.error('handling set keep screen on fail, code:' + code + ', data: ' + data); 158e41f4b71Sopenharmony_ci } 159e41f4b71Sopenharmony_ci }); 160e41f4b71Sopenharmony_ci ``` 161e41f4b71Sopenharmony_ci## GetBrightnessOptions<sup>(deprecated)</sup> 162e41f4b71Sopenharmony_ci 163e41f4b71Sopenharmony_ciOptions for obtaining the screen brightness. 164e41f4b71Sopenharmony_ci 165e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite 166e41f4b71Sopenharmony_ci 167e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 168e41f4b71Sopenharmony_ci| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | 169e41f4b71Sopenharmony_ci| success | (data: [BrightnessResponse](#brightnessresponsedeprecated)) => void | No | Called when an API call is successful. **data** is a return value of the [BrightnessResponse](#brightnessresponsedeprecated) type.| 170e41f4b71Sopenharmony_ci| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | 171e41f4b71Sopenharmony_ci| complete | () => void | No | Called when an API call is complete. | 172e41f4b71Sopenharmony_ci 173e41f4b71Sopenharmony_ci## SetBrightnessOptions<sup>(deprecated)</sup> 174e41f4b71Sopenharmony_ci 175e41f4b71Sopenharmony_ciOptions for setting the screen brightness. 176e41f4b71Sopenharmony_ci 177e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite 178e41f4b71Sopenharmony_ci 179e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 180e41f4b71Sopenharmony_ci| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ | 181e41f4b71Sopenharmony_ci| value | number | Yes | Screen brightness. The value is an integer ranging from **1** to **255**.<br>- If the value is less than or equal to **0**, value **1** will be used.<br>- If the value is greater than **255**, value **255** will be used.<br>- If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used.| 182e41f4b71Sopenharmony_ci| success | () => void | No | Called when API call is successful. | 183e41f4b71Sopenharmony_ci| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | 184e41f4b71Sopenharmony_ci| complete | () => void | No | Called when an API call is complete. | 185e41f4b71Sopenharmony_ci 186e41f4b71Sopenharmony_ci## BrightnessResponse<sup>(deprecated)</sup> 187e41f4b71Sopenharmony_ci 188e41f4b71Sopenharmony_ciDefines a response that returns the screen brightness. 189e41f4b71Sopenharmony_ci 190e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite 191e41f4b71Sopenharmony_ci 192e41f4b71Sopenharmony_ci| Name| Type| Readable| Writable| Description| 193e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 194e41f4b71Sopenharmony_ci| value | number | Yes| No| Screen brightness. The value ranges from **1** to **255**.| 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_ci## GetBrightnessModeOptions<sup>(deprecated)</sup> 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_ciDefines the options for obtaining the screen brightness mode. 199e41f4b71Sopenharmony_ci 200e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 203e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 204e41f4b71Sopenharmony_ci| success | (data: [BrightnessModeResponse](#brightnessmoderesponsedeprecated)) => void | No | Called when an API call is successful. **data** is a return value of the [BrightnessModeResponse](#brightnessmoderesponsedeprecated) type.| 205e41f4b71Sopenharmony_ci| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | 206e41f4b71Sopenharmony_ci| complete | () => void | No | Called when an API call is complete. | 207e41f4b71Sopenharmony_ci 208e41f4b71Sopenharmony_ci## SetBrightnessModeOptions<sup>(deprecated)</sup> 209e41f4b71Sopenharmony_ci 210e41f4b71Sopenharmony_ciOptions for setting the screen brightness mode. 211e41f4b71Sopenharmony_ci 212e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite 213e41f4b71Sopenharmony_ci 214e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 215e41f4b71Sopenharmony_ci| -------- | ------------------------------------ | ---- | ------------------------------------------------------ | 216e41f4b71Sopenharmony_ci| mode | number | Yes | The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.| 217e41f4b71Sopenharmony_ci| success | () => void | No | Called when API call is successful. | 218e41f4b71Sopenharmony_ci| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code.| 219e41f4b71Sopenharmony_ci| complete | () => void | No | Called when an API call is complete. | 220e41f4b71Sopenharmony_ci 221e41f4b71Sopenharmony_ci## BrightnessModeResponse<sup>(deprecated)</sup> 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ciDefines a response that returns the screen brightness mode. 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite 226e41f4b71Sopenharmony_ci 227e41f4b71Sopenharmony_ci| Name| Type| Readable| Writable| Description| 228e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 229e41f4b71Sopenharmony_ci| mode | number | Yes| No| The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.| 230e41f4b71Sopenharmony_ci 231e41f4b71Sopenharmony_ci## SetKeepScreenOnOptions<sup>(deprecated)</sup> 232e41f4b71Sopenharmony_ci 233e41f4b71Sopenharmony_ciOptions for setting the screen to be steady on. 234e41f4b71Sopenharmony_ci 235e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite 236e41f4b71Sopenharmony_ci 237e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 238e41f4b71Sopenharmony_ci| ------------ | ------------------------------------ | ---- | ------------------------------------------------------ | 239e41f4b71Sopenharmony_ci| keepScreenOn | boolean | Yes | The value **true** means to keep the screen steady on, and the value **false** indicates the opposite. | 240e41f4b71Sopenharmony_ci| success | () => void | No | Called when API call is successful. | 241e41f4b71Sopenharmony_ci| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code.| 242e41f4b71Sopenharmony_ci| complete | () => void | No | Called when an API call is complete. | 243