From df1dcca2df51c93d7fa459527c762ba68e01b5a3 Mon Sep 17 00:00:00 2001 From: ShiJie Date: Thu, 10 Mar 2022 05:52:29 -0800 Subject: [PATCH] add: @system.battery.d.ts and @system.brightness.d.ts Signed-off-by: ShiJie Change-Id: I06d6b2514638f269094338050e454900ac5f5940 --- api/@system.battery.d.ts | 70 +++++++++++ api/@system.brightness.d.ts | 226 ++++++++++++++++++++++++++++++++++++ 2 files changed, 296 insertions(+) create mode 100755 api/@system.battery.d.ts create mode 100755 api/@system.brightness.d.ts diff --git a/api/@system.battery.d.ts b/api/@system.battery.d.ts new file mode 100755 index 0000000000..eb9ffea7e1 --- /dev/null +++ b/api/@system.battery.d.ts @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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. + */ + +/** + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 3 + */ + export interface BatteryResponse { + /** + * Whether the battery is being charged. + * @since 3 + */ + charging: boolean; + + /** + * Current battery level, which ranges from 0.00 to 1.00. + * @since 3 + */ + level: number; +} + +/** + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 3 + */ +export interface GetStatusOptions { + /** + * Called when the current charging state and battery level are obtained. + * @since 3 + */ + success?: (data: BatteryResponse) => void; + + /** + * Called when the current charging state and battery level fail to be obtained. + * @since 3 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} + +/** + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 3 + * @import battery from '@system.battery'; + */ +export default class Battery { + /** + * Obtains the current charging state and battery level. + * @param options Options. + * @since 3 + */ + static getStatus(options?: GetStatusOptions): void; +} \ No newline at end of file diff --git a/api/@system.brightness.d.ts b/api/@system.brightness.d.ts new file mode 100755 index 0000000000..6e67325d6f --- /dev/null +++ b/api/@system.brightness.d.ts @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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. + */ + +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + */ +export interface BrightnessResponse { + /** + * Screen brightness, which ranges from 1 to 100. + * @since 3 + */ + value: number; +} + +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + */ +export interface GetBrightnessOptions { + /** + * Called when the current screen brightness is obtained. + * @since 3 + */ + success?: (data: BrightnessResponse) => void; + + /** + * Called when the current screen brightness fails to be obtained. + * @since 3 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} + +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + */ +export interface SetBrightnessOptions { + /** + * Screen brightness. The value is an integer ranging from 1 to 100. + * If the value is less than or equal to 0, value 1 will be used. + * If the value is greater than 100, value 100 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. + * @since 3 + */ + value: number; + + /** + * Called when the setting is successful. + * @since 3 + */ + success?: () => void; + + /** + * Called when the setting fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void +} + +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + */ +export interface BrightnessModeResponse { + /** + * The value can be 0 or 1. + * 0: The screen brightness is manually adjusted. + * 1: The screen brightness is automatically adjusted. + * @since 3 + */ + mode: number; +} + +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + */ +export interface GetBrightnessModeOptions { + /** + * Called when the screen brightness adjustment mode is obtained. + * @since 3 + */ + success?: (data: BrightnessModeResponse) => void; + + /** + * Called when the screen brightness adjustment mode fails to be obtained. + * @since 3 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} + +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + */ +export interface SetBrightnessModeOptions { + /** + * The screen brightness mode. + * 0: The screen brightness is manually adjusted. + * 1: The screen brightness is automatically adjusted. + * @since 3 + */ + mode: number; + + /** + * Called when the setting is successful. + * @since 3 + */ + success?: () => void; + + /** + * Called when the setting fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void +} + +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + */ +export interface SetKeepScreenOnOptions { + /** + * Whether to always keep the screen on. + * @since 3 + */ + keepScreenOn: boolean; + + /** + * Called when the setting is successful. + * @since 3 + */ + success?: () => void; + + /** + * Called when the setting fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void +} + +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + * @import brightness from '@system.brightness'; + */ +export default class Brightness { + /** + * Obtains the current screen brightness. + * @param options Options. + * @since 3 + */ + static getValue(options?: GetBrightnessOptions): void; + + /** + * Sets the screen brightness. + * @param options Options. + * @since 3 + */ + static setValue(options?: SetBrightnessOptions): void; + + /** + * Obtains the screen brightness adjustment mode. + * @param options Options. + * @since 3 + */ + static getMode(options?: GetBrightnessModeOptions): void; + + /** + * Sets the screen brightness adjustment mode. + * @param options Options. + * @since 3 + */ + static setMode(options?: SetBrightnessModeOptions): void; + + /** + * Sets whether to always keey the screen on. + * @param options Options. + * @since 3 + */ + static setKeepScreenOn(options?: SetKeepScreenOnOptions): void; +} \ No newline at end of file -- Gitee