From 76f34e2a3ffcefed09887932cea3e4b454f5ac1d Mon Sep 17 00:00:00 2001 From: hxf233333 Date: Tue, 19 Aug 2025 21:27:15 +0800 Subject: [PATCH] feat: add setPowerKeyFilteringStrategy Signed-off-by: hxf233333 --- api/@ohos.power.d.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/api/@ohos.power.d.ts b/api/@ohos.power.d.ts index fbafb0b9dc..901dcd8fef 100644 --- a/api/@ohos.power.d.ts +++ b/api/@ohos.power.d.ts @@ -307,6 +307,21 @@ declare namespace power { */ function refreshActivity(reason: string): void; + /** + * Set the power key filtering strategy. For details, see {@link PowerKeyFilteringStrategy}. + * @permission ohos.permission.POWER_MANAGER + * @param { PowerKeyFilteringStrategy } strategy Indicates the power key filtering strategy {@link PowerKeyFilteringStrategy} to set. + * the PowerKeyFilteringStrategy type is an enumeration class. + * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission + * required to call the API. + * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. + * @throws { BusinessError } 4900101 - Failed to connect to the service. + * @syscap SystemCapability.PowerManager.PowerManager.Core + * @systemapi + * @since 21 + */ + function setPowerKeyFilteringStrategy(strategy: PowerKeyFilteringStrategy): void; + /** * Power mode of a device. * @@ -356,5 +371,29 @@ declare namespace power { */ MODE_CUSTOM_POWER_SAVE = 650 } + + /** + * Filtering strategy of power key. + * + * @enum { int } + * @syscap SystemCapability.PowerManager.PowerManager.Core + * @since 21 + */ + export enum PowerKeyFilteringStrategy { + /** + * Disable long press filtering. + * + * @syscap SystemCapability.PowerManager.PowerManager.Core + * @since 21 + */ + DISABLE_LONG_PRESS_FILTERING = 0, + /** + * Long press filtering once. + * + * @syscap SystemCapability.PowerManager.PowerManager.Core + * @since 21 + */ + LONG_PRESS_FILTERING_ONCE = 1 + } } export default power; \ No newline at end of file -- Gitee