How to capture power off trigger and create an action based on that

Selix

New member
When I press the power off button (long press), I want Macrodroid to prompt for fingerprint/pin or something. I have Samsung s22 with Android 13

Thanks
 

Endercraft

Moderator (& bug finder :D)
You'll have to use the logcat trigger and then use the authenticate user action, probably with UI Interaction to click anywhere to exit the power screen then if the authentication result is successful use the Android shortcut -> power options action (make sure it doesn't go in an infinite authentication loop).
 

Selix

New member
When you say logcat trigger are you referring to logcat message? If so could you please let me know what value I need to put inside component and enter text to match fields? thanks for your help so far

Screenshot_20231203_105225_MacroDroid.jpg
 

Qarboz

Well-known member
When I press the power off button (long press), I want Macrodroid to prompt for fingerprint/pin or something. I have Samsung s22 with Android 13

Thanks
If you need that trigger to prevent reboot or shutdown, be aware that very long press (10-15 sec) still reboots the device and cannot be excluded (acts at the hardware level)
 

Selix

New member
Hi @Endercraft - I was able to capture long press trigger using those two lines marked in blue, it captures long press situation. But i'm not sure how to capture the power off button within the long press situation, could you please look into the other lines within the red box that can specifically detect power off within long press situation?

Thanks
 
Last edited:

Selix

New member
If you need that trigger to prevent reboot or shutdown, be aware that very long press (10-15 sec) still reboots the device and cannot be excluded (acts at the hardware level)
ahh thanks for pointing that out, nevertheless im going to make my phone useless to a thief as much as I can lol
 

Endercraft

Moderator (& bug finder :D)
could you please look into the other lines within the red box that can specifically detect power off within long press situation?
You should try and get these specific lines yourself as often logcat varies across devices and something that works for me might not work for you and the other way around.
 

Selix

New member
You should try and get these specific lines yourself as often logcat varies across devices and something that works for me might not work for you and the other way around.
I have found the line, I can detect long press button as a trigger. Now i'm just struggling with UI Interaction bit, once the long press has been detected, how do i take the user to the home page. im not sure which click option I need to use?
 

hsurB

Well-known member
I have found the line, I can detect long press button as a trigger. Now i'm just struggling with UI Interaction bit, once the long press has been detected, how do i take the user to the home page. im not sure which click option I need to use?

There is action called launch home screen.
There is also one called authenticate user which asks for fingerprint/pin just as you wanted in your first post here
 

hsurB

Well-known member
I've just realised that modes/routines samsung app has button action as trigger if you have routines+ good lock module installed so you could use this as well to overwrite power action.
What is even more important - phone won't turn off even after holding the button for 30seconds and you don't need root or ADB
You can make it for exemple to set screen timeout for the value you use always, cause I don't think there is empty action.
But since you do it for security reasons you have to remember there are other ways to open this menu (from notification panel for exemple) so having this macro in macrodroid as well is a decent idea
 

Attachments

  • Screenshot_20231203_204057_Modes and Routines.png
    Screenshot_20231203_204057_Modes and Routines.png
    169.7 KB · Views: 5
Last edited:
Top