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 * @file 18 * @kit BasicServicesKit 19 */ 20 21/** 22 * @interface BrightnessResponse 23 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 24 * @since 3 25 * @deprecated since 7 26 */ 27export interface BrightnessResponse { 28 /** 29 * Screen brightness, which ranges from 1 to 255. 30 * 31 * @type { number } 32 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 33 * @since 3 34 * @deprecated since 7 35 */ 36 value: number; 37} 38 39/** 40 * @interface GetBrightnessOptions 41 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 42 * @since 3 43 * @deprecated since 7 44 */ 45export interface GetBrightnessOptions { 46 /** 47 * Called when the current screen brightness is obtained. 48 * 49 * @type { ?function } 50 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 51 * @since 3 52 * @deprecated since 7 53 */ 54 success?: (data: BrightnessResponse) => void; 55 56 /** 57 * Called when the current screen brightness fails to be obtained. 58 * 59 * @type { ?function } 60 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 61 * @since 3 62 * @deprecated since 7 63 */ 64 fail?: (data: string, code: number) => void; 65 66 /** 67 * Called when the execution is completed. 68 * 69 * @type { ?function } 70 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 71 * @since 3 72 * @deprecated since 7 73 */ 74 complete?: () => void; 75} 76 77/** 78 * @interface SetBrightnessOptions 79 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 80 * @since 3 81 * @deprecated since 7 82 */ 83export interface SetBrightnessOptions { 84 /** 85 * Screen brightness. The value is an integer ranging from 1 to 255. 86 * If the value is less than or equal to 0, value 1 will be used. 87 * If the value is greater than 255, value 255 will be used. 88 * If the value contains decimals, the integral part of the value will be used. 89 * For example, if value is 8.1 is set, value 8 will be used. 90 * 91 * @type { number } 92 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 93 * @since 3 94 * @deprecated since 7 95 */ 96 value: number; 97 98 /** 99 * Called when the setting is successful. 100 * 101 * @type { ?function } 102 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 103 * @since 3 104 * @deprecated since 7 105 */ 106 success?: () => void; 107 108 /** 109 * Called when the setting fails. 110 * 111 * @type { ?function } 112 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 113 * @since 3 114 * @deprecated since 7 115 */ 116 fail?: (data: string, code: number) => void; 117 118 /** 119 * Called when the execution is completed. 120 * 121 * @type { ?function } 122 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 123 * @since 3 124 * @deprecated since 7 125 */ 126 complete?: () => void; 127} 128 129/** 130 * @interface BrightnessModeResponse 131 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 132 * @since 3 133 * @deprecated since 7 134 */ 135export interface BrightnessModeResponse { 136 /** 137 * The value can be 0 or 1. 138 * 0: The screen brightness is manually adjusted. 139 * 1: The screen brightness is automatically adjusted. 140 * 141 * @type { number } 142 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 143 * @since 3 144 * @deprecated since 7 145 */ 146 mode: number; 147} 148 149/** 150 * @interface GetBrightnessModeOptions 151 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 152 * @since 3 153 * @deprecated since 7 154 */ 155export interface GetBrightnessModeOptions { 156 /** 157 * Called when the screen brightness adjustment mode is obtained. 158 * 159 * @type { ?function } 160 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 161 * @since 3 162 * @deprecated since 7 163 */ 164 success?: (data: BrightnessModeResponse) => void; 165 166 /** 167 * Called when the screen brightness adjustment mode fails to be obtained. 168 * 169 * @type { ?function } 170 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 171 * @since 3 172 * @deprecated since 7 173 */ 174 fail?: (data: string, code: number) => void; 175 176 /** 177 * Called when the execution is completed. 178 * 179 * @type { ?function } 180 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 181 * @since 3 182 * @deprecated since 7 183 */ 184 complete?: () => void; 185} 186 187/** 188 * @interface SetBrightnessModeOptions 189 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 190 * @since 3 191 * @deprecated since 7 192 */ 193export interface SetBrightnessModeOptions { 194 /** 195 * The screen brightness mode. 196 * 0: The screen brightness is manually adjusted. 197 * 1: The screen brightness is automatically adjusted. 198 * 199 * @type { number } 200 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 201 * @since 3 202 * @deprecated since 7 203 */ 204 mode: number; 205 206 /** 207 * Called when the setting is successful. 208 * 209 * @type { ?function } 210 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 211 * @since 3 212 * @deprecated since 7 213 */ 214 success?: () => void; 215 216 /** 217 * Called when the setting fails. 218 * 219 * @type { ?function } 220 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 221 * @since 3 222 * @deprecated since 7 223 */ 224 fail?: (data: string, code: number) => void; 225 226 /** 227 * Called when the execution is completed. 228 * 229 * @type { ?function } 230 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 231 * @since 3 232 * @deprecated since 7 233 */ 234 complete?: () => void; 235} 236 237/** 238 * @interface SetKeepScreenOnOptions 239 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 240 * @since 3 241 * @deprecated since 7 242 */ 243export interface SetKeepScreenOnOptions { 244 /** 245 * Whether to always keep the screen on. 246 * 247 * @type { boolean } 248 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 249 * @since 3 250 * @deprecated since 7 251 */ 252 keepScreenOn: boolean; 253 254 /** 255 * Called when the setting is successful. 256 * 257 * @type { ?function } 258 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 259 * @since 3 260 * @deprecated since 7 261 */ 262 success?: () => void; 263 264 /** 265 * Called when the setting fails. 266 * 267 * @type { ?function } 268 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 269 * @since 3 270 * @deprecated since 7 271 */ 272 fail?: (data: string, code: number) => void; 273 274 /** 275 * Called when the execution is completed. 276 * 277 * @type { ?function } 278 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 279 * @since 3 280 * @deprecated since 7 281 */ 282 complete?: () => void; 283} 284 285/** 286 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 287 * @since 3 288 * @deprecated since 7 289 */ 290export default class Brightness { 291 /** 292 * Obtains the current screen brightness. 293 * 294 * @param { GetBrightnessOptions } options Options. 295 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 296 * @since 3 297 * @deprecated since 7 298 */ 299 static getValue(options?: GetBrightnessOptions): void; 300 301 /** 302 * Sets the screen brightness. 303 * 304 * @param { SetBrightnessOptions } options Options. 305 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 306 * @since 3 307 * @deprecated since 7 308 * @useinstead ohos.brightness/brightness#setValue 309 */ 310 static setValue(options?: SetBrightnessOptions): void; 311 312 /** 313 * Obtains the screen brightness adjustment mode. 314 * 315 * @param { GetBrightnessModeOptions } options Options. 316 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 317 * @since 3 318 * @deprecated since 7 319 */ 320 static getMode(options?: GetBrightnessModeOptions): void; 321 322 /** 323 * Sets the screen brightness adjustment mode. 324 * 325 * @param { SetBrightnessModeOptions } options Options. 326 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 327 * @since 3 328 * @deprecated since 7 329 */ 330 static setMode(options?: SetBrightnessModeOptions): void; 331 332 /** 333 * Sets whether to always keep the screen on. 334 * 335 * @param { SetKeepScreenOnOptions } options Options. 336 * @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite 337 * @since 3 338 * @deprecated since 7 339 * @useinstead ohos.window/Window#setWindowKeepScreenOn 340 */ 341 static setKeepScreenOn(options?: SetKeepScreenOnOptions): void; 342} 343