!1486 add JS api of powermanager subsystem

Merge pull request !1486 from hujun211/master
This commit is contained in:
openharmony_ci 2022-04-18 04:04:06 +00:00 committed by Gitee
commit 58feaaa84f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 204 additions and 0 deletions

View File

@ -71,6 +71,40 @@ declare namespace batteryInfo {
*/
const isBatteryPresent: boolean;
/**
* Obtain the battery capacity level of a device.
* @since 9
*/
const batteryCapacityLevel: BatteryCapacityLevel;
/**
* Estimate the remaining time to fully charge, in ms.
* @since 9
*/
const estimatedRemainingChargeTime: number;
/**
* Battery total energy of the current device, in mAh.
* @since 9
* @systemapi
*/
const totalEnergy: number;
/**
* Battery immediate current of the current device, in mA.
* @since 9
* @systemapi
*/
const nowCurrent: number;
/**
* Battery remaining energy of the current device, in mAh.
* @since 9
* @systemapi
*/
const remainingEnergy: number;
/**
* Indicates the charger type of a device.
*
@ -167,6 +201,109 @@ declare namespace batteryInfo {
*/
DEAD
}
/**
* Indicates the battery capacity level a device.
*
* @syscap SystemCapability.PowerManager.BatteryManager.Core
* @since 9
*/
export enum BatteryCapacityLevel {
/**
* The battery is in unknow capacity level.
* @since 9
*/
LEVEL_NONE,
/**
* The battery is in full capacity level.
* @since 9
*/
LEVEL_FULL,
/**
* The battery is in high capacity level.
* @since 9
*/
LEVEL_HIGH,
/**
* The battery is in normal capacity level.
* @since 9
*/
LEVEL_NORMAL,
/**
* The battery is in low capacity level.
* @since 9
*/
LEVEL_LOW,
/**
* The battery is in critical low capacity level.
* @since 9
*/
LEVEL_CRITICAL
}
/**
* Etra key code of common event COMMON_EVENT_BATTERY_CHANGED.
*
* @syscap SystemCapability.PowerManager.BatteryManager.Core
* @since 9
*/
export enum CommonEventBatteryChangedCode {
/**
* Extra code of state of charge (SoC).
* @since 9
*/
EXTRA_SOC = 0,
/**
* Extra code of voltage.
* @since 9
*/
EXTRA_VOLTAGE,
/**
* Extra code of temperature.
* @since 9
*/
EXTRA_TEMPERATURE,
/**
* Extra code of healthState.
* @since 9
*/
EXTRA_HEALTH_STATE,
/**
* Extra code of pluggedType.
* @since 9
*/
EXTRA_PLUGGED_TYPE,
/**
* Extra code of maxCurrent.
* @since 9
*/
EXTRA_MAX_CURRENT,
/**
* Extra code of maxVoltage.
* @since 9
*/
EXTRA_MAX_VOLTAGE,
/**
* Extra code of chargeState.
* @since 9
*/
EXTRA_CHARGE_STATE,
/**
* Extra code of chargeCounter.
* @since 9
*/
EXTRA_CHARGE_COUNTER,
/**
* Extra code of if battery is present.
* @since 9
*/
EXTRA_PRESENT,
/**
* Extra code of technology.
* @since 9
*/
EXTRA_TECHNOLOGY
}
}
export default batteryInfo;

67
api/@ohos.power.d.ts vendored
View File

@ -54,6 +54,73 @@ declare namespace power {
*/
function isScreenOn(callback: AsyncCallback<boolean>): void;
function isScreenOn(): Promise<boolean>;
/**
* Try to wakeup the device and let screen on.
*
* @param detail Indicates the detail information who request wakeup.
* @systemapi
* @since 9
*/
function wakeupDevice(detail: string): void;
/**
* Try to suspend the device and let screen off.
*
* @systemapi
* @since 9
*/
function suspendDevice(): void;
/**
* Get the power mode of the device.
*
* @return Returns the power mode {@link DevicePowerMode} of current device .
* @permission ohos.permission.POWER_OPTIMIZATION
* @since 9
*/
function getPowerMode(callback: AsyncCallback<DevicePowerMode>): void;
function getPowerMode(): Promise<DevicePowerMode>;
/**
* To set the power mode of current device.
*
* @param mode Indicates power mode {@link DevicePowerMode} to set.
* @permission ohos.permission.POWER_OPTIMIZATION
* @systemapi
* @since 9
*/
function setPowerMode(mode: DevicePowerMode, callback: AsyncCallback<void>): void;
function setPowerMode(mode: DevicePowerMode): Promise<void>;
/**
* Indicates the power mode of a device.
*
* @syscap SystemCapability.PowerManager.PowerManager.Core
* @since 9
*/
export enum DevicePowerMode {
/**
* Performance power mode
* @since 9
*/
MODE_PERFORMANCE,
/**
* Normal power mode
* @since 9
*/
MODE_NORMAL,
/**
* Power save mode
* @since 9
*/
MODE_POWER_SAVE,
/**
* Extreme power save mode
* @since 9
*/
MODE_EXTREME_POWER_SAVE
}
}
export default power;