diff --git a/api/@ohos.batteryInfo.d.ts b/api/@ohos.batteryInfo.d.ts index 05b49542cab99d5f5d03e94aee99683880b67428..1ee587994c63a26d6219bbd1ec2f939c92ae1945 100644 --- a/api/@ohos.batteryInfo.d.ts +++ b/api/@ohos.batteryInfo.d.ts @@ -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; diff --git a/api/@ohos.power.d.ts b/api/@ohos.power.d.ts index 3b7db0d372d0086ee9a1aaafdb2ad92fc3cb5b55..ac894e25d58dcdcd94986361d8d25f78db2c3a2d 100644 --- a/api/@ohos.power.d.ts +++ b/api/@ohos.power.d.ts @@ -54,6 +54,73 @@ declare namespace power { */ function isScreenOn(callback: AsyncCallback): void; function isScreenOn(): Promise; + + /** + * 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): void; + function getPowerMode(): Promise; + + /** + * 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; + function setPowerMode(mode: DevicePowerMode): Promise; + + /** + * 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;