Disable power button locks instantly


shadowz1337

Members
Jan 30, 2014
10
15
Probably won't get my answers here, but thought I'd give it a try anyway.

On most Android ROMs, there's a setting called "power button locks instantly" or "power button locks immediately". If this is setting is on, then when you press the power button your screen will lock and this is regardless of what your screen timeout setting is. Even if you set the screen timeout to 1 minute, pressing the power button will always lock the screen immediately.

In certain situations, I want to disable this behaviour. For example, if I'm at home connected to my home Wifi SSID, then I don't need to have a lockscreen enabled. The problem is that on MIUI, this setting cannot be found at all. It isn't a System/Secure/Global table setting either. And before anyone jumps in to reply, no this isn't the same setting as the "lock_screen_lock_after_timeout" secure setting, which you'll commonly find on XDA or Reddit, etc.

Luckily, you can control the "power button locks instantly" setting by using a MacroDroid/Tasker plugin called Secure Settings. In this plugin, you can configure the "Power Button Lock" setting to be disabled. The plugin can be found here:

If you set "Power Button Lock" to disabled, then it will show this in logcat:

Get lockscreen.power_button_instantly_locks: true
Set 'lockscreen.power_button_instantly_locks' enabled: false, success: true

and if you set "Power Button Lock" to enabled, then it will show this log in logcat:
Get lockscreen.power_button_instantly_locks: true
Set 'lockscreen.power_button_instantly_locks' enabled: true, success: true

I've been using this plugin on MacroDroid and it works perfectly fine. This was on my Redmi Note 9T, running MIUI 12 Android 11. However, I've recently upgraded to Redmi K60 and this is on MIUI 14 Android 13. For some reason, this doesn't work anymore. I can still the same logs in logcat, but my screen is always locked when I press the power button.

I thought perhaps that this doesn't work on Android 13 anymore, so then I tested this on my Poco F1 running a custom Android 13 ROM and it still works. So this leads me to believe that perhaps the latest MIUI has somehow removed this setting (even though we can't even find this setting in any of the MIUI roms).

I then digged a little bit deeper and found this:

In that link, you can look up this "LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS". So then I went into my System folder, extracted framework.jar and then used JadX to decompile it. I did this on both my Redmi Note 9T and Redmi K60 and I compared the differences.

Well, I found no differences. They both have the LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS setting for both the GET and the SET methods.

I'm not a programmer and at this point I just give up. If anybody can shed some light on this, I'd be interested to find out why this doesn't work anymore, or whether there are any other ways to systematically disable/enable the lockscreen.
 
I found my solution. I came across this:

That has a plugin support for either MacroDroid or Tasker. You can install that and enable the Xposed module. The documentation page says it requires EdXposed but that's not true. I'm using LSPosed and it works fine. You then go into the lock screen setting in the app and enable the mod. Then, just use the plugin in Tasker or MacroDroid to configure lock/unlock.
 
  • Like
Reactions: JiaiJ