How to prevent the power button from putting the device into sleep?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to prevent the power button from putting the device into sleep?

Jump to solution
1,180 Views
dennis3
Contributor V

Our device has a power button the user can turn on/off the device like normal.  In fsl-imx8mq.dtsi this is defined via the snvs_pwrkey node:

     snvs_pwrkey: snvs-powerkey {
      compatible = "fsl,sec-v4.0-pwrkey";
      regmap = <&snvs>;
      interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
      linux,keycode = <KEY_POWER>;
      wakeup-source;
     };

Power functions all work as designed except I have the need to prevent the device from going into a sleep state.  

Power button long press -> show power menu, user can shutdown or reboot (OK)

Power button long press > 5 seconds -> hard shutdown (OK)

Power button short press -> sleep. (wish to disable this)

Power button short press -> wake

Can someone point me to the right layer in Android or Linux where I might change the handler to ignore the short press sleep state?

0 Kudos
1 Solution
1,045 Views
shivanipatel
Senior Contributor II

Hi Dennis Muhlestein,

This is not a i.MX specific rather it is Android supported feature.

To disable the Power button short press sleep functionality, change the value of the variable "config_shortPressOnPowerBehavior" to 0 (zero) in {AOSP}/frameworks/base/core/res/res/values/config.xml file.

Hope this will help you.

Regards,

Shivani

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

2 Replies
1,046 Views
shivanipatel
Senior Contributor II

Hi Dennis Muhlestein,

This is not a i.MX specific rather it is Android supported feature.

To disable the Power button short press sleep functionality, change the value of the variable "config_shortPressOnPowerBehavior" to 0 (zero) in {AOSP}/frameworks/base/core/res/res/values/config.xml file.

Hope this will help you.

Regards,

Shivani

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,045 Views
dennis3
Contributor V

Thank you for this tip.  That's exactly what I was looking for.

0 Kudos