From 0313c74563fff2ecddbc59ea8fedad37505e6e67 Mon Sep 17 00:00:00 2001 From: wangyantian Date: Wed, 23 Apr 2025 21:02:15 +0800 Subject: [PATCH] feat: Power HDI adds OnWakeupWithTag Signed-off-by: wangyantian --- power/bundle.json | 27 ++- power/v1_3/BUILD.gn | 36 +++ power/v1_3/IPowerHdiCallback.idl | 86 +++++++ power/v1_3/IPowerInterface.idl | 285 +++++++++++++++++++++++ power/v1_3/IPowerRunningLockCallback.idl | 64 +++++ power/v1_3/PowerTypes.idl | 95 ++++++++ power/v1_3/RunningLockTypes.idl | 119 ++++++++++ 7 files changed, 711 insertions(+), 1 deletion(-) create mode 100644 power/v1_3/BUILD.gn create mode 100755 power/v1_3/IPowerHdiCallback.idl create mode 100755 power/v1_3/IPowerInterface.idl create mode 100644 power/v1_3/IPowerRunningLockCallback.idl create mode 100755 power/v1_3/PowerTypes.idl create mode 100644 power/v1_3/RunningLockTypes.idl diff --git a/power/bundle.json b/power/bundle.json index 64569607..764f6962 100644 --- a/power/bundle.json +++ b/power/bundle.json @@ -30,7 +30,8 @@ "build": { "sub_component": [ "//drivers/interface/power/v1_0:power_idl_target", - "//drivers/interface/power/v1_2:power_idl_target" + "//drivers/interface/power/v1_2:power_idl_target", + "//drivers/interface/power/v1_3:power_idl_target" ], "test": [ ], @@ -82,6 +83,30 @@ ], "header_base": "//drivers/interface/power" } + }, + { + "name": "//drivers/interface/power/v1_3:libpower_proxy_1.3", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/power" + } + }, + { + "name": "//drivers/interface/power/v1_3:libpower_stub_1.3", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/power" + } + }, + { + "name": "//drivers/interface/power/v1_3:power_idl_headers_1.3", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/power" + } } ] } diff --git a/power/v1_3/BUILD.gn b/power/v1_3/BUILD.gn new file mode 100644 index 00000000..e47efabe --- /dev/null +++ b/power/v1_3/BUILD.gn @@ -0,0 +1,36 @@ +# Copyright (c) 2025 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("//build/config/components/hdi/hdi.gni") +if (defined(ohos_lite)) { + group("libpower_proxy_1.3") { + deps = [] + public_configs = [] + } +} else { + hdi("power") { + module_name = "power_interface_service" + + sources = [ + "IPowerHdiCallback.idl", + "IPowerInterface.idl", + "IPowerRunningLockCallback.idl", + "PowerTypes.idl", + "RunningLockTypes.idl", + ] + + language = "cpp" + subsystem_name = "hdf" + part_name = "drivers_interface_power" + } +} diff --git a/power/v1_3/IPowerHdiCallback.idl b/power/v1_3/IPowerHdiCallback.idl new file mode 100755 index 00000000..3b88e6a0 --- /dev/null +++ b/power/v1_3/IPowerHdiCallback.idl @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2025 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. + */ + +/** + * @addtogroup power + * @{ + * + * @brief Provides APIs for performing hibernation/wakeup operations, subscribing to the hibernation/wakeup status, + * and managing running locks. + * + * After obtaining an object or proxy of this module, the power service can invoke related APIs to perform + * hibernation/wakeup operations, subscribe to the hibernation/wakeup status, and manage running locks. + * + * @since 3.1 + * @version 1.0 + */ + + /** + * @file IPowerHdiCallback.idl + * + * @brief Provides the callbacks of the hibernation/wakeup status. + * + * The power module provides callbacks for the power service to obtain the hibernation/wakeup status. + * + * @since 3.1 + * @version 1.0 + */ + +package ohos.hdi.power.v1_3; + +/** + * @brief Represents the callbacks of the hibernation/wakeup status. + * + * After creating a callback object, the power service can call {@link IPowerInterface} to register a callback to + * subscribe to hibernation/wakeup status changes. + * + * @since 3.1 + * @version 1.0 + */ +[callback] interface IPowerHdiCallback { + /** + * @brief Callback of the hibernation state. + * + * This callback is used to notify the power service when the device enters the hibernation state. + * + * @since 3.1 + * @version 1.0 + */ + OnSuspend(); + + /** + * @brief Callback of the wakeup state. + * + * This callback is used to notify the power service when the device enters the wakeup state. + * + * @since 3.1 + * @version 1.0 + */ + OnWakeup(); + + /** + * @brief Callback of the wakeup state with a tag. + * + * This callback is used to notify the power service when the device enters the wakeup state from different + * suspend tag. + * + * @param suspendTag The suspend tag + * + * @since 6.0 + * @version 1.0 + */ + OnWakeupWithTag([in] int suspendTag); +} +/** @} */ diff --git a/power/v1_3/IPowerInterface.idl b/power/v1_3/IPowerInterface.idl new file mode 100755 index 00000000..973b7858 --- /dev/null +++ b/power/v1_3/IPowerInterface.idl @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2025 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. + */ + +/** + * @addtogroup power + * @{ + * + * @brief Provides APIs for performing hibernation/wakeup operations, subscribing to the hibernation/wakeup status, + * and managing running locks. + * + * After obtaining an object or proxy of this module, the power service can invoke related APIs to perform + * hibernation/wakeup operations, subscribe to the hibernation/wakeup status, and manage running locks. + * + * @since 3.1 + * @version 1.0 + */ + +/** + * @file IPowerInterface.idl + * + * @brief Provides APIs for performing hibernation/wakeup operations, subscribing to the hibernation/wakeup status, + * and managing running locks. + * + * + * + * @since 3.1 + * @version 1.0 + */ + +package ohos.hdi.power.v1_3; + +import ohos.hdi.power.v1_3.IPowerRunningLockCallback; +import ohos.hdi.power.v1_3.IPowerHdiCallback; +import ohos.hdi.power.v1_3.PowerTypes; +import ohos.hdi.power.v1_3.RunningLockTypes; + +/** + * @brief Represents APIs for performing hibernation/wakeup operations, subscribing to the hibernation/wakeup status, + * and managing running locks. + * + * + * + * @since 3.1 + * @version 1.0 + */ +interface IPowerInterface { + /** + * @brief Registers the callback of the hibernation/wakeup status. + * + * @param ipowerHdiCallback Callback to register. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @see IPowerHdiCallback + * + * @since 3.1 + * @version 1.0 + */ + RegisterCallback([in] IPowerHdiCallback ipowerHdiCallback); + + /** + * @brief Suspend a device. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 3.1 + * @version 1.0 + */ + StartSuspend(); + + /** + * @brief Wakes up a device. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 3.1 + * @version 1.0 + */ + StopSuspend(); + + /** + * @brief Forcibly hibernates a device. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 3.1 + * @version 1.0 + */ + ForceSuspend(); + + /** + * @brief Enables the running lock to block device hibernation. + * + * @param name Name of the running lock. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 3.1 + * @version 1.0 + * @deprecated + */ + SuspendBlock([in] String name); + + /** + * @brief Disables the running lock to unblock device hibernation. + * + * @param name Name of the running lock. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 3.1 + * @version 1.0 + * @deprecated + */ + SuspendUnblock([in] String name); + + /** + * @brief Obtains the power dump information. + * + * @param info Power dump information. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 3.1 + * @version 1.0 + */ + PowerDump([out] String info); + + /** + * @brief Holds the running lock to block device hibernation. + * + * @param info Running lock info. + * + * @return Returns HDF_SUCCESS if the operation is successful; returns HDF_FAILED if the + * running lock type conflicts with current lock. + * + * @since 4.0 + * @version 1.0 + */ + HoldRunningLock([in] struct RunningLockInfo info); + + /** + * @brief Unholds the running lock to unblock device hibernation. + * + * @param info Running lock info. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 4.0 + * @version 1.0 + */ + UnholdRunningLock([in] struct RunningLockInfo info); + + /** + * @brief obtain system wakeup reason. + * + * @param info wakeup reason info. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 4.1 + * @version 1.0 + */ + GetWakeupReason([out] String reason); + + /** + * @brief Holds the running lock to block device hibernation. + * + * @param extra Running lock info. + * + * @return Returns HDF_SUCCESS if the operation is successful; returns HDF_FAILED if the + * running lock type conflicts with current lock. + * + * @since 4.1 + * @version 1.0 + * @deprecated + */ + HoldRunningLockExt([in] struct RunningLockInfo info, [in] unsigned long lockid, [in] String bundleName); + + /** + * @brief Unholds the running lock to unblock device hibernation. + * + * @param extra Running lock info. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 4.1 + * @version 1.0 + * @deprecated + */ + UnholdRunningLockExt([in] struct RunningLockInfo info, [in] unsigned long lockid, [in] String bundleName); + + /** + * @brief Registers the callback of the running lock status. + * + * @param iPowerRunningLockCallback Callback to register. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @see IPowerRunningLockCallback + * + * @since 4.1 + * @version 1.0 + * @deprecated + */ + RegisterRunningLockCallback([in] IPowerRunningLockCallback iPowerRunningLockCallback); + + /** + * @brief Unregister the callback of the running lock status. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 4.1 + * @version 1.0 + * @deprecated + */ + UnRegisterRunningLockCallback(); + + /** + * @brief Hibernate the device. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 5.0 + * @version 1.0 + */ + Hibernate(); + + /** + * @brief Set suspend tag before suspend. + * The special sleep mode supported by the kernel and hardware is triggered by setting a special + * suspend tag and then triggering suspend. If the suspend tag is not set, the standard S3 sleep + * mode is triggered when suspend. + * + * @param tag Suspend tag. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 5.0 + * + * @version 1.0 + */ + SetSuspendTag([in] String tag); + + /** + * @brief Set the set-path file value related to the scene name. + * + * @param scene The scene name defined in power config json file. + * + * @param value Value of the set-path file. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 5.0 + * + * @version 1.0 + */ + SetPowerConfig([in] String scene, [in] String value); + + /** + * @brief Get the get-path file value related to the scene name. + * + * @param scene The scene name defined in power config json file. + * + * @param value Value of the get-path file. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 5.0 + * + * @version 1.0 + */ + GetPowerConfig([in] String scene, [out] String value); +} +/** @} */ diff --git a/power/v1_3/IPowerRunningLockCallback.idl b/power/v1_3/IPowerRunningLockCallback.idl new file mode 100644 index 00000000..9c1ae568 --- /dev/null +++ b/power/v1_3/IPowerRunningLockCallback.idl @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 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. + */ + +/** + * @addtogroup power + * @{ + * + * @brief Provides APIs for performing hibernation/wakeup operations, subscribing to the hibernation/wakeup status, + * and managing running locks. + * + * After obtaining an object or proxy of this module, the power service can invoke related APIs to perform + * hibernation/wakeup operations, subscribe to the hibernation/wakeup status, and manage running locks. + * + * @since 3.1 + * @version 1.0 + */ + + /** + * @file IPowerRunningLockCallback.idl + * + * @brief Provides the callbacks of the running lock status. + * + * The power module provides callbacks for the power service to handle the running lock status. + * + * @since 4.1 + * @version 1.1 + */ + +package ohos.hdi.power.v1_3; + +/** + * @brief Represents the callbacks of the running lock status. + * + * After creating a callback object, the power service can call {@link IPowerInterface} to register a callback to + * subscribe to running lock status changes. + * + * @since 4.1 + * @version 1.0 + */ +[callback] interface IPowerRunningLockCallback { + /** + * @brief Callback of running lock state. + * + * This callback is used to notify the power service when the device enters the running lock state. + * + * @since 4.1 + * @version 1.0 + * @deprecated + */ + HandleRunningLockMessage([in] String message); +} +/** @} */ \ No newline at end of file diff --git a/power/v1_3/PowerTypes.idl b/power/v1_3/PowerTypes.idl new file mode 100755 index 00000000..0c830b77 --- /dev/null +++ b/power/v1_3/PowerTypes.idl @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2025 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. + */ + +/** + * @addtogroup power + * @{ + * + * @brief Provides APIs for performing hibernation/wakeup operations, subscribing to the hibernation/wakeup status, + * and managing running locks. + * + * After obtaining an object or proxy of this module, the power service can invoke related APIs to perform + * hibernation/wakeup operations, subscribe to the hibernation/wakeup status, and manage running locks. + * + * @since 3.1 + * @version 1.0 + */ + +/** + * @file PowerTypes.idl + * + * @brief Enumerates data types related to power management. + * + * Such data types include command parameters, callback parameters, and system status. + * + * @since 3.1 + * @version 1.0 + */ + +package ohos.hdi.power.v1_3; + +/** + * @brief Enumerates command parameters for power management. + * + * @since 3.1 + * @version 1.0 + * @deprecated + */ +enum PowerHdfCmd { + /** Command parameter for registering a callback of the power status */ + CMD_REGISTER_CALLBCK = 0, + /** Command parameter for hibernating the device */ + CMD_START_SUSPEND, + /** Command parameter for waking up the device */ + CMD_STOP_SUSPEND, + /** Command parameter for forcibly hibernating the device */ + CMD_FORCE_SUSPEND, + /** Command parameter for opening the running lock */ + CMD_SUSPEND_BLOCK, + /** Command parameter for closing the running lock*/ + CMD_SUSPEND_UNBLOCK, + /** Command parameter for dumping */ + CMD_DUMP, +}; + +/** + * @brief Enumerates command parameters for the power status callback. + * + * @since 3.1 + * @version 1.0 + * @deprecated + */ +enum PowerHdfCallbackCmd { + /** Command parameter for the hibernation callback */ + CMD_ON_SUSPEND = 0, + /** Command parameter for the wakeup callback */ + CMD_ON_WAKEUP, +}; + +/** + * @brief Enumerates the power status. + * + * @since 3.1 + * @version 1.0 + */ +enum PowerHdfState { + /** Awake state */ + AWAKE = 0, + /** Inactive state */ + INACTIVE, + /** Sleep state */ + SLEEP, +}; +/** @} */ diff --git a/power/v1_3/RunningLockTypes.idl b/power/v1_3/RunningLockTypes.idl new file mode 100644 index 00000000..a7054c0c --- /dev/null +++ b/power/v1_3/RunningLockTypes.idl @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2025 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. + */ + +/** + * @addtogroup power + * @{ + * + * @brief Provides APIs for performing hibernation/wakeup operations, subscribing to the hibernation/wakeup status, + * and managing running locks. + * + * After obtaining an object or proxy of this module, the power service can invoke related APIs to perform + * hibernation/wakeup operations, subscribe to the hibernation/wakeup status, and manage running locks. + * + * @since 3.1 + * @version 1.0 + */ + +/** + * @file RunningLockTypes.idl + * + * @brief Enumerates data types related to running lock management. + * + * Such data types include running lock types and running lock information. + * + * @since 4.0 + * @version 1.1 + */ + +package ohos.hdi.power.v1_3; + +/** + * @brief Enumerates base running lock types. + * + * @since 4.0 + * @version 1.1 + */ +enum BaseRunningLockType { + /** + * Running lock for keeping screen on. + */ + RUNNINGLOCK_SCREEN = 0, + /** + * Running lock for keeping the CPU on to finish background tasks. + */ + RUNNINGLOCK_BACKGROUND = 1, + /** + * Running lock for controlling screen on and off by proximity sensor. + */ + RUNNINGLOCK_PROXIMITY_SCREEN_CONTROL = 2, +}; + +/** + * @brief Enumerates running lock types. + * + * @since 4.0 + * @version 1.1 + */ +enum RunningLockType { + /** + * Running lock for keeping background phone tasks to finish. + */ + RUNNINGLOCK_BACKGROUND_PHONE = 3, // RUNNINGLOCK_BACKGROUND | 1 << 1 = 0b00000011 + /** + * Running lock for keeping background notification tasks to finish. + */ + RUNNINGLOCK_BACKGROUND_NOTIFICATION = 5, // RUNNINGLOCK_BACKGROUND | 1 << 2 = 0b00000101 + /** + * Running lock for keeping background audio tasks to finish. + */ + RUNNINGLOCK_BACKGROUND_AUDIO = 9, // RUNNINGLOCK_BACKGROUND | 1 << 3 = 0b00001001 + /** + * Running lock for keeping background sport tasks to finish. + */ + RUNNINGLOCK_BACKGROUND_SPORT = 17, // RUNNINGLOCK_BACKGROUND | 1 << 4 = 0b00010001 + /** + * Running lock for keeping background navigation tasks to finish. + */ + RUNNINGLOCK_BACKGROUND_NAVIGATION = 33, // RUNNINGLOCK_BACKGROUND | 1 << 5 = 0b00100001 + /** + * Running lock for keeping background common tasks to finish. + */ + RUNNINGLOCK_BACKGROUND_TASK = 65, // RUNNINGLOCK_BACKGROUND | 1 << 6 = 0b01000001 + /** + * Reserved running lock type. + */ + RUNNINGLOCK_BUTT +}; + +/** + * @brief Defines the running lock information. + * + * @since 4.0 + * @version 1.1 + */ +struct RunningLockInfo { + /** Name of the running lock. It cannot be null or empty */ + String name; + /** Running lock type */ + enum RunningLockType type; // The default value is RUNNINGLOCK_BACKGROUND_TASK. + /** Timeout duration of the running lock, in ms. A value smaller than 0 means no timeout. */ + int timeoutMs; // The default value is 3000. + /** PID */ + int pid; + /** UID */ + int uid; +}; +/** @} */ -- Gitee