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 BatteryResponse
|
|
|
|
* @syscap SystemCapability.PowerManager.BatteryManager.Lite
|
2022-03-10 13:52:29 +00:00
|
|
|
* @since 3
|
2022-10-11 06:46:52 +00:00
|
|
|
* @deprecated since 6
|
2022-03-10 13:52:29 +00:00
|
|
|
*/
|
2023-02-21 10:54:48 +00:00
|
|
|
export interface BatteryResponse {
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Whether the battery is being charged.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { boolean }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.BatteryManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 6
|
|
|
|
*/
|
|
|
|
charging: boolean;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Current battery level, which ranges from 0.00 to 1.00.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { number }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.BatteryManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 6
|
|
|
|
*/
|
|
|
|
level: number;
|
2022-03-10 13:52:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-25 11:52:13 +00:00
|
|
|
* @interface GetStatusOptions
|
|
|
|
* @syscap SystemCapability.PowerManager.BatteryManager.Lite
|
2022-03-10 13:52:29 +00:00
|
|
|
* @since 3
|
2022-10-11 06:46:52 +00:00
|
|
|
* @deprecated since 6
|
2022-03-10 13:52:29 +00:00
|
|
|
*/
|
|
|
|
export interface GetStatusOptions {
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the current charging state and battery level are obtained.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.BatteryManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 6
|
|
|
|
*/
|
|
|
|
success?: (data: BatteryResponse) => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Called when the current charging state and battery level fail to be obtained.
|
|
|
|
*
|
2024-07-08 03:54:31 +00:00
|
|
|
* @type { ?function }
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.BatteryManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 6
|
|
|
|
*/
|
|
|
|
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.BatteryManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 6
|
|
|
|
*/
|
|
|
|
complete?: () => void;
|
2022-03-10 13:52:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-25 11:52:13 +00:00
|
|
|
* @syscap SystemCapability.PowerManager.BatteryManager.Lite
|
2022-03-10 13:52:29 +00:00
|
|
|
* @since 3
|
2022-10-11 06:46:52 +00:00
|
|
|
* @deprecated since 6
|
2022-03-10 13:52:29 +00:00
|
|
|
*/
|
|
|
|
export default class Battery {
|
2023-03-21 08:00:55 +00:00
|
|
|
/**
|
|
|
|
* Obtains the current charging state and battery level.
|
|
|
|
*
|
2023-06-25 11:52:13 +00:00
|
|
|
* @param { GetStatusOptions } options Options.
|
|
|
|
* @syscap SystemCapability.PowerManager.BatteryManager.Lite
|
2023-03-21 08:00:55 +00:00
|
|
|
* @since 3
|
|
|
|
* @deprecated since 6
|
|
|
|
*/
|
|
|
|
static getStatus(options?: GetStatusOptions): void;
|
|
|
|
}
|