1/* 2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @interface BrightnessResponse 18 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 19 * @since 3 20 * @deprecated since 7 21 */ 22export interface BrightnessResponse { 23 /** 24 * Screen brightness, which ranges from 1 to 255. 25 * 26 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 27 * @since 3 28 * @deprecated since 7 29 */ 30 value: number; 31} 32 33/** 34 * @interface GetBrightnessOptions 35 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 36 * @since 3 37 * @deprecated since 7 38 */ 39export interface GetBrightnessOptions { 40 /** 41 * Called when the current screen brightness is obtained. 42 * 43 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 44 * @since 3 45 * @deprecated since 7 46 */ 47 success?: (data: BrightnessResponse) => void; 48 49 /** 50 * Called when the current screen brightness fails to be obtained. 51 * 52 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 53 * @since 3 54 * @deprecated since 7 55 */ 56 fail?: (data: string, code: number) => void; 57 58 /** 59 * Called when the execution is completed. 60 * 61 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 62 * @since 3 63 * @deprecated since 7 64 */ 65 complete?: () => void; 66} 67 68/** 69 * @interface SetBrightnessOptions 70 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 71 * @since 3 72 * @deprecated since 7 73 */ 74export interface SetBrightnessOptions { 75 /** 76 * Screen brightness. The value is an integer ranging from 1 to 255. 77 * If the value is less than or equal to 0, value 1 will be used. 78 * If the value is greater than 255, value 255 will be used. 79 * If the value contains decimals, the integral part of the value will be used. 80 * For example, if value is 8.1 is set, value 8 will be used. 81 * 82 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 83 * @since 3 84 * @deprecated since 7 85 */ 86 value: number; 87 88 /** 89 * Called when the setting is successful. 90 * 91 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 92 * @since 3 93 * @deprecated since 7 94 */ 95 success?: () => void; 96 97 /** 98 * Called when the setting fails. 99 * 100 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 101 * @since 3 102 * @deprecated since 7 103 */ 104 fail?: (data: string, code: number) => void; 105 106 /** 107 * Called when the execution is completed. 108 * 109 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 110 * @since 3 111 * @deprecated since 7 112 */ 113 complete?: () => void; 114} 115 116/** 117 * @interface BrightnessModeResponse 118 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 119 * @since 3 120 * @deprecated since 7 121 */ 122export interface BrightnessModeResponse { 123 /** 124 * The value can be 0 or 1. 125 * 0: The screen brightness is manually adjusted. 126 * 1: The screen brightness is automatically adjusted. 127 * 128 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 129 * @since 3 130 * @deprecated since 7 131 */ 132 mode: number; 133} 134 135/** 136 * @interface GetBrightnessModeOptions 137 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 138 * @since 3 139 * @deprecated since 7 140 */ 141export interface GetBrightnessModeOptions { 142 /** 143 * Called when the screen brightness adjustment mode is obtained. 144 * 145 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 146 * @since 3 147 * @deprecated since 7 148 */ 149 success?: (data: BrightnessModeResponse) => void; 150 151 /** 152 * Called when the screen brightness adjustment mode fails to be obtained. 153 * 154 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 155 * @since 3 156 * @deprecated since 7 157 */ 158 fail?: (data: string, code: number) => void; 159 160 /** 161 * Called when the execution is completed. 162 * 163 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 164 * @since 3 165 * @deprecated since 7 166 */ 167 complete?: () => void; 168} 169 170/** 171 * @interface SetBrightnessModeOptions 172 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 173 * @since 3 174 * @deprecated since 7 175 */ 176export interface SetBrightnessModeOptions { 177 /** 178 * The screen brightness mode. 179 * 0: The screen brightness is manually adjusted. 180 * 1: The screen brightness is automatically adjusted. 181 * 182 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 183 * @since 3 184 * @deprecated since 7 185 */ 186 mode: number; 187 188 /** 189 * Called when the setting is successful. 190 * 191 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 192 * @since 3 193 * @deprecated since 7 194 */ 195 success?: () => void; 196 197 /** 198 * Called when the setting fails. 199 * 200 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 201 * @since 3 202 * @deprecated since 7 203 */ 204 fail?: (data: string, code: number) => void; 205 206 /** 207 * Called when the execution is completed. 208 * 209 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 210 * @since 3 211 * @deprecated since 7 212 */ 213 complete?: () => void; 214} 215 216/** 217 * @interface SetKeepScreenOnOptions 218 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 219 * @since 3 220 * @deprecated since 7 221 */ 222export interface SetKeepScreenOnOptions { 223 /** 224 * Whether to always keep the screen on. 225 * 226 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 227 * @since 3 228 * @deprecated since 7 229 */ 230 keepScreenOn: boolean; 231 232 /** 233 * Called when the setting is successful. 234 * 235 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 236 * @since 3 237 * @deprecated since 7 238 */ 239 success?: () => void; 240 241 /** 242 * Called when the setting fails. 243 * 244 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 245 * @since 3 246 * @deprecated since 7 247 */ 248 fail?: (data: string, code: number) => void; 249 250 /** 251 * Called when the execution is completed. 252 * 253 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 254 * @since 3 255 * @deprecated since 7 256 */ 257 complete?: () => void; 258} 259 260/** 261 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 262 * @since 3 263 * @deprecated since 7 264 */ 265export default class Brightness { 266 /** 267 * Obtains the current screen brightness. 268 * 269 * @param { GetBrightnessOptions } options Options. 270 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 271 * @since 3 272 * @deprecated since 7 273 */ 274 static getValue(options?: GetBrightnessOptions): void; 275 276 /** 277 * Sets the screen brightness. 278 * 279 * @param { SetBrightnessOptions } options Options. 280 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 281 * @since 3 282 * @deprecated since 7 283 */ 284 static setValue(options?: SetBrightnessOptions): void; 285 286 /** 287 * Obtains the screen brightness adjustment mode. 288 * 289 * @param { GetBrightnessModeOptions } options Options. 290 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 291 * @since 3 292 * @deprecated since 7 293 */ 294 static getMode(options?: GetBrightnessModeOptions): void; 295 296 /** 297 * Sets the screen brightness adjustment mode. 298 * 299 * @param { SetBrightnessModeOptions } options Options. 300 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 301 * @since 3 302 * @deprecated since 7 303 */ 304 static setMode(options?: SetBrightnessModeOptions): void; 305 306 /** 307 * Sets whether to always keep the screen on. 308 * 309 * @param { SetKeepScreenOnOptions } options Options. 310 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 311 * @since 3 312 * @deprecated since 7 313 */ 314 static setKeepScreenOn(options?: SetKeepScreenOnOptions): void; 315} 316