2022-03-10 13:52:29 +00:00
|
|
|
/*
|
2023-06-25 11:52:13 +00:00
|
|
|
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
2022-03-10 13:52:29 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2023-12-11 09:08:03 +00:00
|
|
|
/**
|
|
|
|
* @file
|
2024-01-08 07:25:39 +00:00
|
|
|
* @kit BasicServicesKit
|
2023-12-11 09:08:03 +00:00
|
|
|
*/
|
|
|
|
|
2022-03-10 13:52:29 +00:00
|
|
|
/**
|
2023-06-25 11:52:13 +00:00
|
|
|
* @interface BrightnessResponse
|
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2022-03-10 13:52:29 +00:00
|
|
|
* @since 3
|
2022-10-11 06:46:52 +00:00
|
|
|
* @deprecated since 7
|
2022-03-10 13:52:29 +00:00
|
|
|
*/
|
|
|
|
export interface BrightnessResponse {
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Screen brightness, which ranges from 1 to 255.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { number }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
value: number;
|
2022-03-10 13:52:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-25 11:52:13 +00:00
|
|
|
* @interface GetBrightnessOptions
|
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2022-03-10 13:52:29 +00:00
|
|
|
* @since 3
|
2022-10-11 06:46:52 +00:00
|
|
|
* @deprecated since 7
|
2022-03-10 13:52:29 +00:00
|
|
|
*/
|
|
|
|
export interface GetBrightnessOptions {
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the current screen brightness is obtained.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
success?: (data: BrightnessResponse) => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the current screen brightness fails to be obtained.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
fail?: (data: string, code: number) => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the execution is completed.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
complete?: () => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-25 11:52:13 +00:00
|
|
|
* @interface SetBrightnessOptions
|
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2022-03-10 13:52:29 +00:00
|
|
|
* @since 3
|
2022-10-11 06:46:52 +00:00
|
|
|
* @deprecated since 7
|
2022-03-10 13:52:29 +00:00
|
|
|
*/
|
|
|
|
export interface SetBrightnessOptions {
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Screen brightness. The value is an integer ranging from 1 to 255.
|
|
|
|
* If the value is less than or equal to 0, value 1 will be used.
|
|
|
|
* If the value is greater than 255, value 255 will be used.
|
|
|
|
* If the value contains decimals, the integral part of the value will be used.
|
|
|
|
* For example, if value is 8.1 is set, value 8 will be used.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { number }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
value: number;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the setting is successful.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
success?: () => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the setting fails.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
fail?: (data: string, code: number) => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the execution is completed.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
complete?: () => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-25 11:52:13 +00:00
|
|
|
* @interface BrightnessModeResponse
|
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2022-03-10 13:52:29 +00:00
|
|
|
* @since 3
|
2022-10-11 06:46:52 +00:00
|
|
|
* @deprecated since 7
|
2022-03-10 13:52:29 +00:00
|
|
|
*/
|
|
|
|
export interface BrightnessModeResponse {
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* The value can be 0 or 1.
|
|
|
|
* 0: The screen brightness is manually adjusted.
|
|
|
|
* 1: The screen brightness is automatically adjusted.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { number }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
mode: number;
|
2022-03-10 13:52:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-25 11:52:13 +00:00
|
|
|
* @interface GetBrightnessModeOptions
|
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2022-03-10 13:52:29 +00:00
|
|
|
* @since 3
|
2022-10-11 06:46:52 +00:00
|
|
|
* @deprecated since 7
|
2022-03-10 13:52:29 +00:00
|
|
|
*/
|
|
|
|
export interface GetBrightnessModeOptions {
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the screen brightness adjustment mode is obtained.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
success?: (data: BrightnessModeResponse) => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the screen brightness adjustment mode fails to be obtained.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
fail?: (data: string, code: number) => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the execution is completed.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
complete?: () => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-25 11:52:13 +00:00
|
|
|
* @interface SetBrightnessModeOptions
|
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2022-03-10 13:52:29 +00:00
|
|
|
* @since 3
|
2022-10-11 06:46:52 +00:00
|
|
|
* @deprecated since 7
|
2022-03-10 13:52:29 +00:00
|
|
|
*/
|
|
|
|
export interface SetBrightnessModeOptions {
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* The screen brightness mode.
|
|
|
|
* 0: The screen brightness is manually adjusted.
|
|
|
|
* 1: The screen brightness is automatically adjusted.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { number }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
mode: number;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the setting is successful.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
success?: () => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the setting fails.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
fail?: (data: string, code: number) => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the execution is completed.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
complete?: () => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-25 11:52:13 +00:00
|
|
|
* @interface SetKeepScreenOnOptions
|
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2022-03-10 13:52:29 +00:00
|
|
|
* @since 3
|
2022-10-11 06:46:52 +00:00
|
|
|
* @deprecated since 7
|
2022-03-10 13:52:29 +00:00
|
|
|
*/
|
|
|
|
export interface SetKeepScreenOnOptions {
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Whether to always keep the screen on.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { boolean }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
keepScreenOn: boolean;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the setting is successful.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
success?: () => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the setting fails.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
fail?: (data: string, code: number) => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the execution is completed.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
complete?: () => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2022-03-10 13:52:29 +00:00
|
|
|
* @since 3
|
2022-10-11 06:46:52 +00:00
|
|
|
* @deprecated since 7
|
2022-03-10 13:52:29 +00:00
|
|
|
*/
|
|
|
|
export default class Brightness {
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Obtains the current screen brightness.
|
|
|
|
*
|
2023-06-25 11:52:13 +00:00
|
|
|
* @param { GetBrightnessOptions } options Options.
|
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
static getValue(options?: GetBrightnessOptions): void;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Sets the screen brightness.
|
|
|
|
*
|
2023-06-25 11:52:13 +00:00
|
|
|
* @param { SetBrightnessOptions } options Options.
|
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
static setValue(options?: SetBrightnessOptions): void;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Obtains the screen brightness adjustment mode.
|
|
|
|
*
|
2023-06-25 11:52:13 +00:00
|
|
|
* @param { GetBrightnessModeOptions } options Options.
|
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
static getMode(options?: GetBrightnessModeOptions): void;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Sets the screen brightness adjustment mode.
|
|
|
|
*
|
2023-06-25 11:52:13 +00:00
|
|
|
* @param { SetBrightnessModeOptions } options Options.
|
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
static setMode(options?: SetBrightnessModeOptions): void;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Sets whether to always keep the screen on.
|
|
|
|
*
|
2023-06-25 11:52:13 +00:00
|
|
|
* @param { SetKeepScreenOnOptions } options Options.
|
|
|
|
* @syscap SystemCapability.PowerManager.DisplayPowerManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 7
|
|
|
|
*/
|
|
|
|
static setKeepScreenOn(options?: SetKeepScreenOnOptions): void;
|
|
|
|
}
|