From 80c95d86005eeb3f7bfad30ab50a6972a5c7d3d7 Mon Sep 17 00:00:00 2001 From: hujun211 Date: Fri, 1 Apr 2022 02:34:55 -0700 Subject: [PATCH 1/9] modify js api of powermanger Signed-off-by: hujun211 --- api/@ohos.batteryInfo.d.ts | 104 +++++++++++++++++++++++++++++++++++++ api/@ohos.power.d.ts | 62 ++++++++++++++++++++++ 2 files changed, 166 insertions(+) diff --git a/api/@ohos.batteryInfo.d.ts b/api/@ohos.batteryInfo.d.ts index 05b49542ca..bdce732c35 100644 --- a/api/@ohos.batteryInfo.d.ts +++ b/api/@ohos.batteryInfo.d.ts @@ -71,6 +71,46 @@ declare namespace batteryInfo { */ const isBatteryPresent: boolean; + /** + * Obtain the battery charge level of a device. + * @since 9 + */ + const batteryLevel: BatteryLevel; + + /** + * Estimate the remaining time to fully charge. + * @since 9 + */ + const estimateRemainingChargeTime: number; + + /** + * Battery total energy of the current device. + * @since 9 + * @systemapi + */ + const totalEnergy: number; + + /** + * Battery average current of the current device. + * @since 9 + * @systemapi + */ + const averageCurrent: number; + + /** + * Battery immediate current of the current device. + * @since 9 + * @systemapi + */ + + const nowCurrent: number; + /** + * Battery remaining energy of the current device. + * @since 9 + * @systemapi + */ + const remainingEnergy: number; + /** * Indicates the charger type of a device. * @@ -167,6 +207,70 @@ declare namespace batteryInfo { */ DEAD } + + /** + * Etra key code of common event COMMON_EVENT_BATTERY_CHANGED. + * + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 9 + */ + export enum CommonEventExtraCode { + /** + * Extra code of charge (SoC). + * @since 9 + */ + EXTRA_CODE_SOC = 0, + /** + * Extra code of voltage. + * @since 9 + */ + EXTRA_CODE_VOLTAGE, + /** + * Extra code of temperature. + * @since 9 + */ + EXTRA_CODE_TEMPERATURE, + /** + * Extra code of healthState. + * @since 9 + */ + EXTRA_CODE_HEALTH_STATE, + /** + * Extra code of pluggedType. + * @since 9 + */ + EXTRA_CODE_PLUGGED_TYPE, + /** + * Extra code of maxCurrent. + * @since 9 + */ + EXTRA_CODE_MAX_CURRENT, + /** + * Extra code of maxVoltage. + * @since 9 + */ + EXTRA_CODE_MAX_VOLTAGE, + /** + * Extra code of chargeState. + * @since 9 + */ + EXTRA_CODE_CHARGE_STATE, + /** + * Extra code of chargeCounter. + * @since 9 + */ + EXTRA_CODE_CHARGE_COUNTER, + /** + * Extra code of if battery is present. + * @since 9 + */ + EXTRA_CODE_PRESENT, + /** + * Extra code of technology. + * @since 9 + */ + EXTRA_CODE_TECHNOLOGY + } } export default batteryInfo; diff --git a/api/@ohos.power.d.ts b/api/@ohos.power.d.ts index 3b7db0d372..41b110f109 100644 --- a/api/@ohos.power.d.ts +++ b/api/@ohos.power.d.ts @@ -54,6 +54,68 @@ declare namespace power { */ function isScreenOn(callback: AsyncCallback): void; function isScreenOn(): Promise; + + /** + * Tyr to wakeup the device and let screen on. + * + * @param detail Indicates the detail information who request wakeup. + * @systemapi + * @since 9 + */ + function wakeupDevice(detail: string, callback: AsyncCallback): void; + function wakeupDevice(detail: string): Promise; + + /** + * Tyr 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 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 to set. + * @permission ohos.permission.POWER_OPTIMIZATION + * @since 9 + */ + function setPowerMode(mode: DevicePowerMode, callback: AsyncCallback): void; + function setPowerMode(mode: DevicePowerMode): Promise; + + /** + * Indicates the power mode of a device. + * + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 9 + */ + export enum DevicePowerMode { + /** + * Normal power mode + * @since 9 + */ + NORMAL_MODE, + /** + * Power save mode + * @since 9 + */ + POWER_SAVE_MODE, + /** + * Extreme power save mode + * @since 9 + */ + EXTREME_SAVE_MODE + } } export default power; -- Gitee From 040325fba7abd69655c5fd455db1acb73fecbcf9 Mon Sep 17 00:00:00 2001 From: hujun211 Date: Fri, 1 Apr 2022 19:38:18 -0700 Subject: [PATCH 2/9] modify js api of powermanger Signed-off-by: hujun211 --- api/@ohos.batteryInfo.d.ts | 73 ++++++++++++++++++++++++++++---------- api/@ohos.power.d.ts | 8 ++++- 2 files changed, 61 insertions(+), 20 deletions(-) diff --git a/api/@ohos.batteryInfo.d.ts b/api/@ohos.batteryInfo.d.ts index bdce732c35..ae7d223cda 100644 --- a/api/@ohos.batteryInfo.d.ts +++ b/api/@ohos.batteryInfo.d.ts @@ -72,40 +72,41 @@ declare namespace batteryInfo { const isBatteryPresent: boolean; /** - * Obtain the battery charge level of a device. + * Obtain the battery state level of a device. * @since 9 */ - const batteryLevel: BatteryLevel; + const batteryStateLevel: BatteryStateLevel; /** - * Estimate the remaining time to fully charge. + * Estimate the remaining time to fully charge, in ms. * @since 9 */ const estimateRemainingChargeTime: number; /** - * Battery total energy of the current device. + * Battery total energy of the current device, in mAh. * @since 9 * @systemapi */ const totalEnergy: number; /** - * Battery average current of the current device. + * Battery average current of the current device, in mA. * @since 9 * @systemapi */ const averageCurrent: number; /** - * Battery immediate current of the current device. + * Battery immediate current of the current device, in mA. * @since 9 * @systemapi */ const nowCurrent: number; + /** - * Battery remaining energy of the current device. + * Battery remaining energy of the current device, in mAh. * @since 9 * @systemapi */ @@ -208,68 +209,102 @@ declare namespace batteryInfo { DEAD } + /** + * Indicates the battery charge level status of a device. + * + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 9 + */ + export enum BatteryStateLevel { + /** + * The battery is in unknow level state. + * @since 9 + */ + LEVEL_NONE, + /** + * The battery is in high level state. + * @since 9 + */ + LEVEL_HIGH, + /** + * The battery is in normal level state. + * @since 9 + */ + LEVEL_NORMAL, + /** + * The battery is in low level state. + * @since 9 + */ + LEVEL_LOW, + /** + * The battery is in emergency low level state. + * @since 9 + */ + LEVEL_EMERGENCY + } + /** * Etra key code of common event COMMON_EVENT_BATTERY_CHANGED. * * @syscap SystemCapability.PowerManager.BatteryManager.Core * @since 9 */ - export enum CommonEventExtraCode { + export enum CommonEventBatteryChangedCode { /** * Extra code of charge (SoC). * @since 9 */ - EXTRA_CODE_SOC = 0, + EXTRA_SOC = 0, /** * Extra code of voltage. * @since 9 */ - EXTRA_CODE_VOLTAGE, + EXTRA_VOLTAGE, /** * Extra code of temperature. * @since 9 */ - EXTRA_CODE_TEMPERATURE, + EXTRA_TEMPERATURE, /** * Extra code of healthState. * @since 9 */ - EXTRA_CODE_HEALTH_STATE, + EXTRA_HEALTH_STATE, /** * Extra code of pluggedType. * @since 9 */ - EXTRA_CODE_PLUGGED_TYPE, + EXTRA_PLUGGED_TYPE, /** * Extra code of maxCurrent. * @since 9 */ - EXTRA_CODE_MAX_CURRENT, + EXTRA_MAX_CURRENT, /** * Extra code of maxVoltage. * @since 9 */ - EXTRA_CODE_MAX_VOLTAGE, + EXTRA_MAX_VOLTAGE, /** * Extra code of chargeState. * @since 9 */ - EXTRA_CODE_CHARGE_STATE, + EXTRA_CHARGE_STATE, /** * Extra code of chargeCounter. * @since 9 */ - EXTRA_CODE_CHARGE_COUNTER, + EXTRA_CHARGE_COUNTER, /** * Extra code of if battery is present. * @since 9 */ - EXTRA_CODE_PRESENT, + EXTRA_PRESENT, /** * Extra code of technology. * @since 9 */ - EXTRA_CODE_TECHNOLOGY + EXTRA_TECHNOLOGY } } export default batteryInfo; diff --git a/api/@ohos.power.d.ts b/api/@ohos.power.d.ts index 41b110f109..7b19a3eb8e 100644 --- a/api/@ohos.power.d.ts +++ b/api/@ohos.power.d.ts @@ -56,7 +56,7 @@ declare namespace power { function isScreenOn(): Promise; /** - * Tyr to wakeup the device and let screen on. + * Try to wakeup the device and let screen on. * * @param detail Indicates the detail information who request wakeup. * @systemapi @@ -88,6 +88,7 @@ declare namespace power { * * @param mode Indicates power mode to set. * @permission ohos.permission.POWER_OPTIMIZATION + * @systemapi * @since 9 */ function setPowerMode(mode: DevicePowerMode, callback: AsyncCallback): void; @@ -100,6 +101,11 @@ declare namespace power { * @since 9 */ export enum DevicePowerMode { + /** + * Performance power mode + * @since 9 + */ + PERFORMANCE_MODE, /** * Normal power mode * @since 9 -- Gitee From 60d844199220f6a5e3f0138cfa2fe425d2a30bf0 Mon Sep 17 00:00:00 2001 From: hujun211 Date: Fri, 1 Apr 2022 19:47:43 -0700 Subject: [PATCH 3/9] modify js api of powermanger Signed-off-by: hujun211 --- api/@ohos.power.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/@ohos.power.d.ts b/api/@ohos.power.d.ts index 7b19a3eb8e..49b3c40419 100644 --- a/api/@ohos.power.d.ts +++ b/api/@ohos.power.d.ts @@ -66,7 +66,7 @@ declare namespace power { function wakeupDevice(detail: string): Promise; /** - * Tyr to suspend the device and let screen off. + * Try to suspend the device and let screen off. * * @systemapi * @since 9 @@ -76,7 +76,7 @@ declare namespace power { /** * Get the power mode of the device. * - * @return Returns the power mode of current device. + * @return Returns the power mode {@link DevicePowerMode} of current device . * @permission ohos.permission.POWER_OPTIMIZATION * @since 9 */ @@ -86,7 +86,7 @@ declare namespace power { /** * To set the power mode of current device. * - * @param mode Indicates power mode to set. + * @param mode Indicates power mode {@link DevicePowerMode} to set. * @permission ohos.permission.POWER_OPTIMIZATION * @systemapi * @since 9 -- Gitee From 918125cd2aa9d52f7af60e4a74f1ed234e43a611 Mon Sep 17 00:00:00 2001 From: hujun211 Date: Sat, 2 Apr 2022 01:00:53 -0700 Subject: [PATCH 4/9] modify js api of powermanger Signed-off-by: hujun211 --- api/@ohos.power.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/@ohos.power.d.ts b/api/@ohos.power.d.ts index 49b3c40419..f908ccc2f8 100644 --- a/api/@ohos.power.d.ts +++ b/api/@ohos.power.d.ts @@ -62,8 +62,7 @@ declare namespace power { * @systemapi * @since 9 */ - function wakeupDevice(detail: string, callback: AsyncCallback): void; - function wakeupDevice(detail: string): Promise; + function wakeupDevice(detail: string): void; /** * Try to suspend the device and let screen off. -- Gitee From 0bb736bb8b08968f0c1d42daa34289fea100971a Mon Sep 17 00:00:00 2001 From: hujun211 Date: Tue, 12 Apr 2022 20:12:51 -0700 Subject: [PATCH 5/9] modify js api of powermanger Signed-off-by: hujun211 --- api/@ohos.batteryInfo.d.ts | 2 +- api/@ohos.power.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/@ohos.batteryInfo.d.ts b/api/@ohos.batteryInfo.d.ts index ae7d223cda..4418118a2d 100644 --- a/api/@ohos.batteryInfo.d.ts +++ b/api/@ohos.batteryInfo.d.ts @@ -81,7 +81,7 @@ declare namespace batteryInfo { * Estimate the remaining time to fully charge, in ms. * @since 9 */ - const estimateRemainingChargeTime: number; + const estimatedRemainingChargeTime: number; /** * Battery total energy of the current device, in mAh. diff --git a/api/@ohos.power.d.ts b/api/@ohos.power.d.ts index f908ccc2f8..3c8f79efd7 100644 --- a/api/@ohos.power.d.ts +++ b/api/@ohos.power.d.ts @@ -70,7 +70,7 @@ declare namespace power { * @systemapi * @since 9 */ - function suspendDevice(void); + function suspendDevice(): void; /** * Get the power mode of the device. -- Gitee From 2fb865efd8bfaef0c13bd10a7964a573ba8e5830 Mon Sep 17 00:00:00 2001 From: hujun211 Date: Wed, 13 Apr 2022 21:12:09 -0700 Subject: [PATCH 6/9] modify js api of powermanger Signed-off-by: hujun211 --- api/@ohos.batteryInfo.d.ts | 2 +- api/@ohos.power.d.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/@ohos.batteryInfo.d.ts b/api/@ohos.batteryInfo.d.ts index 4418118a2d..cb9af93eed 100644 --- a/api/@ohos.batteryInfo.d.ts +++ b/api/@ohos.batteryInfo.d.ts @@ -251,7 +251,7 @@ declare namespace batteryInfo { */ export enum CommonEventBatteryChangedCode { /** - * Extra code of charge (SoC). + * Extra code of state of charge (SoC). * @since 9 */ EXTRA_SOC = 0, diff --git a/api/@ohos.power.d.ts b/api/@ohos.power.d.ts index 3c8f79efd7..ac894e25d5 100644 --- a/api/@ohos.power.d.ts +++ b/api/@ohos.power.d.ts @@ -96,7 +96,7 @@ declare namespace power { /** * Indicates the power mode of a device. * - * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @syscap SystemCapability.PowerManager.PowerManager.Core * @since 9 */ export enum DevicePowerMode { @@ -104,22 +104,22 @@ declare namespace power { * Performance power mode * @since 9 */ - PERFORMANCE_MODE, + MODE_PERFORMANCE, /** * Normal power mode * @since 9 */ - NORMAL_MODE, + MODE_NORMAL, /** * Power save mode * @since 9 */ - POWER_SAVE_MODE, + MODE_POWER_SAVE, /** * Extreme power save mode * @since 9 */ - EXTREME_SAVE_MODE + MODE_EXTREME_POWER_SAVE } } export default power; -- Gitee From 55b1871e3801d610da298a3abf48a0fe6c032849 Mon Sep 17 00:00:00 2001 From: hujun211 Date: Fri, 15 Apr 2022 00:39:15 -0700 Subject: [PATCH 7/9] modify js api of powermanger Signed-off-by: hujun211 --- api/@ohos.batteryInfo.d.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/api/@ohos.batteryInfo.d.ts b/api/@ohos.batteryInfo.d.ts index cb9af93eed..3102d8974c 100644 --- a/api/@ohos.batteryInfo.d.ts +++ b/api/@ohos.batteryInfo.d.ts @@ -90,13 +90,6 @@ declare namespace batteryInfo { */ const totalEnergy: number; - /** - * Battery average current of the current device, in mA. - * @since 9 - * @systemapi - */ - const averageCurrent: number; - /** * Battery immediate current of the current device, in mA. * @since 9 -- Gitee From f2aefd8de07782788e21846ca60804fc17d7b312 Mon Sep 17 00:00:00 2001 From: hujun211 Date: Fri, 15 Apr 2022 01:46:08 -0700 Subject: [PATCH 8/9] modify js api of powermanger Signed-off-by: hujun211 --- api/@ohos.batteryInfo.d.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/api/@ohos.batteryInfo.d.ts b/api/@ohos.batteryInfo.d.ts index 3102d8974c..52e652203c 100644 --- a/api/@ohos.batteryInfo.d.ts +++ b/api/@ohos.batteryInfo.d.ts @@ -72,10 +72,10 @@ declare namespace batteryInfo { const isBatteryPresent: boolean; /** - * Obtain the battery state level of a device. + * Obtain the battery capacity level of a device. * @since 9 */ - const batteryStateLevel: BatteryStateLevel; + const batteryCapacityLevel: BatteryCapacityLevel; /** * Estimate the remaining time to fully charge, in ms. @@ -203,37 +203,37 @@ declare namespace batteryInfo { } /** - * Indicates the battery charge level status of a device. + * Indicates the battery capacity level a device. * * @syscap SystemCapability.PowerManager.BatteryManager.Core * @since 9 */ - export enum BatteryStateLevel { + export enum BatteryCapacityLevel { /** - * The battery is in unknow level state. + * The battery is in unknow capacity level. * @since 9 */ LEVEL_NONE, /** - * The battery is in high level state. + * The battery is in full capacity level. * @since 9 */ - LEVEL_HIGH, + LEVEL_FULL, /** - * The battery is in normal level state. + * The battery is in normal capacity level. * @since 9 */ LEVEL_NORMAL, /** - * The battery is in low level state. + * The battery is in low capacity level. * @since 9 */ LEVEL_LOW, /** - * The battery is in emergency low level state. + * The battery is in critical low capacity level. * @since 9 */ - LEVEL_EMERGENCY + LEVEL_CRITICAL } /** -- Gitee From 19df8236b68586d2ed54580e52c66f0b8d95d88f Mon Sep 17 00:00:00 2001 From: hujun211 Date: Fri, 15 Apr 2022 02:29:26 -0700 Subject: [PATCH 9/9] modify js api of powermanger Signed-off-by: hujun211 --- api/@ohos.batteryInfo.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/@ohos.batteryInfo.d.ts b/api/@ohos.batteryInfo.d.ts index 52e652203c..1ee587994c 100644 --- a/api/@ohos.batteryInfo.d.ts +++ b/api/@ohos.batteryInfo.d.ts @@ -219,6 +219,11 @@ declare namespace batteryInfo { * @since 9 */ LEVEL_FULL, + /** + * The battery is in high capacity level. + * @since 9 + */ + LEVEL_HIGH, /** * The battery is in normal capacity level. * @since 9 -- Gitee