From 6c8e5f20e886495b4a7f21eca29ce12853c4cfd8 Mon Sep 17 00:00:00 2001 From: 15691852971 Date: Tue, 17 Aug 2021 11:55:25 +0000 Subject: [PATCH] huangshujie@huawei.com Signed-off-by: 15691852971 --- api/phone/@ohos.batteryinfo.d.ts | 78 ++++++++++++++-------- api/phone/@ohos.brightness.d.ts | 5 +- api/phone/@ohos.power.d.ts | 58 +++++++++++++++++ api/phone/@ohos.runninglock.d.ts | 107 +++++++++++++++++++++++++++++++ 4 files changed, 221 insertions(+), 27 deletions(-) mode change 100755 => 100644 api/phone/@ohos.batteryinfo.d.ts mode change 100755 => 100644 api/phone/@ohos.brightness.d.ts create mode 100644 api/phone/@ohos.power.d.ts create mode 100644 api/phone/@ohos.runninglock.d.ts diff --git a/api/phone/@ohos.batteryinfo.d.ts b/api/phone/@ohos.batteryinfo.d.ts old mode 100755 new mode 100644 index 7682dc86b6..e0e4ec4e40 --- a/api/phone/@ohos.batteryinfo.d.ts +++ b/api/phone/@ohos.batteryinfo.d.ts @@ -20,78 +20,96 @@ * voltage, temperature, model, and charger type. * * @SysCap SystemCapability.PowerMgr.BatteryManager - * @devices phone, tablet + * @devices phone, tablet, tv, wearable * @since 6 */ declare namespace batteryInfo { /** * Battery state of charge (SoC) of the current device. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ const batterySOC: number; /** * Battery charging status of the current device. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ const chargingStatus: BatteryChargeState; /** * Battery health state of the current device. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ const healthStatus: BatteryHealthState; /** * Charger type of the current device. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ const pluggedType: BatteryPluggedType; /** * Battery voltage of the current device. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ const voltage: number; /** * Battery technology of the current device. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ const technology: string; /** * Battery temperature of the current device. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ const batteryTemperature: number; + /** + * Battery present state of the current device. + * @devices phone, tablet, tv, wearable + * @since 7 + */ + const isBatteryPresent: boolean; + /** * Indicates the charger type of a device. * * @SysCap SystemCapability.PowerMgr.BatteryManager - * @devices phone, tablet + * @devices phone, tablet, tv, wearable * @since 6 */ export enum BatteryPluggedType { /** * Unknown type - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ NONE, /** * AC charger - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ AC, /** * USB charger - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ USB, /** * Wireless charger - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ WIRELESS } @@ -100,28 +118,32 @@ declare namespace batteryInfo { * Indicates the battery charging status of a device. * * @SysCap SystemCapability.PowerMgr.BatteryManager - * @devices phone, tablet + * @devices phone, tablet, tv, wearable * @since 6 */ export enum BatteryChargeState { /** * Unknown state. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ NONE, /** * The battery is being charged. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ ENABLE, /** * The battery is not being charged. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ DISABLE, /** * The battery is fully charged. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ FULL } @@ -130,38 +152,44 @@ declare namespace batteryInfo { * Indicates the battery health status of a device. * * @SysCap SystemCapability.PowerMgr.BatteryManager - * @devices phone, tablet + * @devices phone, tablet, tv, wearable * @since 6 */ export enum BatteryHealthState { /** * Unknown state. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ UNKNOWN, /** * The battery is in healthy state. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ GOOD, /** * The battery is overheated. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ OVERHEAT, /** * The battery voltage is over high. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ OVERVOLTAGE, /** * The battery temperature is low. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ COLD, /** * The battery is dead. - * @devices phone, tablet + * @devices phone, tablet, tv, wearable + * @since 6 */ DEAD } diff --git a/api/phone/@ohos.brightness.d.ts b/api/phone/@ohos.brightness.d.ts old mode 100755 new mode 100644 index 4784db5762..204ef53743 --- a/api/phone/@ohos.brightness.d.ts +++ b/api/phone/@ohos.brightness.d.ts @@ -20,7 +20,7 @@ import { AsyncCallback } from './basic'; * * @SysCap SystemCapability.PowerMgr.DisplayManager * @devices phone, tablet - * @since 6 + * @since 7 */ declare namespace brightness { /** @@ -29,7 +29,8 @@ declare namespace brightness { * @param value Brightness value, ranging from 0 to 255. * @SysCap SystemCapability.PowerMgr.DisplayManager * @devices phone, tablet - * @since 6 + * @systemapi + * @since 7 */ function setValue(value: number): void; } diff --git a/api/phone/@ohos.power.d.ts b/api/phone/@ohos.power.d.ts new file mode 100644 index 0000000000..9d1d90d188 --- /dev/null +++ b/api/phone/@ohos.power.d.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2021 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. + */ + +import {AsyncCallback} from './basic'; + +/** + * Provides interfaces to manage power. + * + * @SysCap SystemCapability.PowerMgr.PowerManager + * @devices phone, tablet, tv, wearable + * @since 7 + */ +declare namespace power { + /** + * Shuts down the system. + * + *

This method requires the ohos.permission.SHUTDOWN permission. + * + * @param reason Indicates the shutdown reason. + * @systemapi + * @since 7 + */ + function shutdownDevice(reason: string): void; + + /** + * Restarts the system. + * + *

This method requires the ohos.permission.REBOOT permission. + * + * @param reason Indicates the restart reason. For example, "recovery" indicates entering the recovery mode + * after the restart. If the parameter is not specified, the system enters the normal mode after the restart. + * @since 7 + */ + function rebootDevice(reason: string): void; + + /** + * Checks whether the screen of a device is on or off. + * + * @return Returns true if the screen is on; returns false otherwise. + * @since 7 + */ + function isScreenOn(callback: AsyncCallback): void; + function isScreenOn(): Promise; +} +export default power; + diff --git a/api/phone/@ohos.runninglock.d.ts b/api/phone/@ohos.runninglock.d.ts new file mode 100644 index 0000000000..808ea5f13d --- /dev/null +++ b/api/phone/@ohos.runninglock.d.ts @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2021 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. + */ + +import {AsyncCallback} from './basic.d.ts'; + +/** + * Provides a mechanism to prevent the system from hibernating so that the applications can run in the background or + * when the screen is off. + * + *

{@link createRunningLock} can be called to obtain a {@link RunningLock}. + *

{@link lock} can be called to set the lock duration, during which the system will not hibernate. After the + * lock duration times out, the lock is automatically released and the system hibernates if no other {@link + * RunningLock} is set. + * + * @SysCap SystemCapability.PowerMgr.PowerManager + * @devices phone, tablet, tv, wearable + * @since 7 + */ +declare namespace runningLock { + class RunningLock { + /** + * Prevents the system from hibernating and sets the lock duration. + * + * @param timeout Indicates the lock duration (ms). After the lock duration times out, the lock is automatically + * released and the system hibernates if no other {@link RunningLock} is set. + * @since 7 + */ + function lock(timeout: number): void; + + /** + * Checks whether a lock is held or in use. + * + * @return Returns true if the lock is held or in use; returns false if the lock has been released. + * @since 7 + */ + function isUsed(): boolean; + + /** + * Release the {@link RunningLock} that prevents the system from hibernating. + * + * @since 7 + */ + function unlock(): void; + } + + /** + * Enumerates the {@link RunningLock} types. + * + *

Two {@link RunningLock} types are available: {@link BACKGROUND}, and {@link PROXIMITY_SCREEN_CONTROL}. + * {@link BACKGROUND} ensures that applications can run in the background. + * {@link PROXIMITY_SCREEN_CONTROL} determines whether to turn on or off the screen based on the proximity sensor. + * + * @since 7 + */ + export enum RunningLockType { + /** + * Indicates the lock that prevents the system from hibernating. + */ + BACKGROUND = 1, + /** + * Indicates the lock that determines whether to turn on or off the screen based on the proximity sensor. + * For example, during a call, if the proximity sensor detects that the device is moving close to + * the user's ear, the screen turns off; if the proximity sensor detects that the device is moving away + * from the user's ear, the screen turns on. + */ + PROXIMITY_SCREEN_CONTROL + } + + /** + * Checks whether the specified {@link RunningLockType} is supported. + * + * @param type Indicates the specified {@link RunningLockType}. + * @return Returns true if the specified {@link RunningLockType} is supported; + * returns false otherwise. + * @since 7 + */ + function isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback): void; + function isRunningLockTypeSupported(type: RunningLockType): Promise; + /** + * Creates a {@link RunningLock} object. + * + *

This method requires the ohos.permission.RUNNING_LOCK permission. + * + *

The {@link RunningLock} object can be used to perform a lock operation to prevent the system from hibernating. + * + * @param name Indicates the {@link RunningLock} name. A recommended name consists of the package or class name and + * a suffix. + * @param type Indicates the {@link RunningLockType}. + * @return Returns the {@link RunningLock} object. + * @since 7 + */ + function createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback): void; + function createRunningLock(name: string, type: RunningLockType): Promise; +} +export default runningLock; -- Gitee