• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Power Subsystem Changelog
2
3## cl.powermgr.1 Error Information Return Method Change of APIs
4
5The **power** module uses service logic return values to indicate error information, which does not comply with the API error code specifications of OpenHarmony. Therefore, modification is made in API version 9 and later.
6
7- Power consumption statistics: [@ohos.batteryStatistics](../../../application-dev/reference/apis/js-apis-batteryStatistics.md)
8 - Screen brightness: [@ohos.brightness](../../../application-dev/reference/apis/js-apis-brightness.md)
9 - Power management: [@ohos.power](../../../application-dev/reference/apis/js-apis-power.md)
10 - Runninglock management: [@ohos.runningLock](../../../application-dev/reference/apis/js-apis-runninglock.md)
11 - Thermal management: [@ohos.thermal](../../../application-dev/reference/apis/js-apis-thermal.md)
12
13Asynchronous API: An error message is returned via **AsyncCallback** or the **error** object of **Promise**.
14
15Synchronous API: An error message is returned via an exception.
16
17#### Change Impact
18
19The application developed based on earlier versions needs to adapt the method for returning API error information. Otherwise, the original service logic will be affected.
20
21#### Key API/Component Changes
22
23Error code processing is added for the following APIs:
24  - getBatteryStats(callback: AsyncCallback<Array&lt;BatteryStatsInfo&gt;>): void
25  - getAppPowerValue(uid: number): number
26  - getAppPowerPercent(uid: number): number
27  - getHardwareUnitPowerValue(type: ConsumptionType): number
28  - getHardwareUnitPowerPercent(type: ConsumptionType): number
29  - setValue(value: number): void
30  - shutdown(reason: string): void;
31  - isActive(): boolean
32  - wakeup(detail: string): void
33  - suspend(): void
34  - getPowerMode(): DevicePowerMode
35  - setPowerMode(mode: DevicePowerMode, callback: AsyncCallback&lt;void&gt;): void
36  - setPowerMode(mode: DevicePowerMode): Promise&lt;void&gt;
37  - hold(timeout: number): void
38  - isHolding(): boolean
39  - unhold(): void
40  - isSupported(type: RunningLockType): boolean
41  - isSupported(type: RunningLockType): boolean
42  - create(name: string, type: RunningLockType, callback: AsyncCallback&lt;RunningLock&gt;): void
43  - create(name: string, type: RunningLockType): Promise&lt;RunningLock&gt;
44  - registerThermalLevelCallback(callback: Callback&lt;ThermalLevel&gt;): void
45  - unregisterThermalLevelCallback(callback?: Callback&lt;void&gt;): void
46  - getLevel(): ThermalLevel
47
48#### Adaptation Guide
49
50For details, see the API reference document of each API.
51## cl.powermgr.2 System API Change
52
53#### Change Impact
54
55The application developed based on earlier versions needs to adapt to new API names and the new method for returning API error information. Otherwise, the original service logic will be affected.
56
57#### Key API/Component Changes
58
59| Bundle Name       | Original API                              | New API                        |
60| ----------- | ------------------------------------ | ------------------------------ |
61| @ohos.power | shutdownDevice(reason: string): void | shutdown(reason: string): void |
62| @ohos.power | rebootDevice(reason: string): void   | reboot(reason: string): void   |
63| @ohos.power | wakeupDevice(detail: string): void   | wakeup(detail: string): void   |
64| @ohos.power | suspendDevice(): void                | suspend(): void                |
65
66#### Adaptation Guide
67
68For details, see [@ohos.power](../../../application-dev/reference/apis/js-apis-power.md).
69