Disable power button locks instantly?

1,754 views
Skip to first unread message

chaoscreater

unread,
Jul 15, 2023, 10:23:54 AM7/15/23
to Tasker
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:

https://play.google.com/store/apps/details?id=com.intangibleobject.securesettings.plugin&hl=en_NZ&gl=US

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:

https://android.googlesource.com/platform/frameworks/base/+/52c489cd63cca0361f374f7cb392018fabfa8bcc/core/java/com/android/internal/widget/LockPatternUtils.java

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.

chaosc...@gmail.com

unread,
Jul 15, 2023, 10:37:55 AM7/15/23
to tas...@googlegroups.com
OT:

No answer for you, but thought we need to be friends, seeing we're related and all

--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tasker/5851796a-5e0d-4071-885a-c81b90a50fd9n%40googlegroups.com.

aa6vh

unread,
Jul 15, 2023, 11:34:03 AM7/15/23
to Tasker
You could just disable that feature entirely, and then create a new profile that is triggered on a display off, and that has Tasker lock the phone when your certain conditions are met.

You can either check your conditions inside the enter task, or you could enable/disable that profile when you are at home or in other conditions where you do not want to automatically lock.

chaoscreater

unread,
Jul 16, 2023, 6:01:54 AM7/16/23
to Tasker
That's not a good solution, because it means you're giving up fingerprint unlock as well. Fingerprint unlock requires a screen lock of some sort to be configured.

You'll also break the /DATA partition decryption in TWRP, which requires screen lock to be configured. I use TWRP to do Nandroid backups and restore on a regular basis, about 50GB worth. If you don't have a screen lock configured, it messes up the DATA partition decryption.

Anyway, 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.

Reply all
Reply to author
Forward
0 new messages