Trigger: Device opened/closed

BobW

New member
With the rising popularity of flip and fold phones, please consider adding a trigger to Macrodroid for detecting when the device is opened or closed. This would be useful for any number of uses, such as:
  • Turn off or set inner screen brightness when activated
  • Set specific screen or app to open when activated
  • Play specific sound when activated
Interestingly, Motorola has an open device sound that can be set on or off in the RAZR 40 Ultra (international version of the RAZR+), but not in the U.S. version (RAZR+). However, there is no choice of the actual sound played, nor is there an option for device closed.
 
Last edited:

Snurre

Well-known member
I'm not quite shure, I think I've seen somewhere that it can be used on other than Samsung
The second, you are absolutely right
 

BobW

New member
After doing further digging, I found the Phone app (com.android.phone) has an Intent, "Actions on flip and close". Further, for the RAZR 40 Ultra (and presumably the RAZR 40) there is an activity, com.motorola.phone.settings.FlipOpenCloseSettings.

Means nothing to me, but maybe it offers a hint as to how this feature may be added.
 

BobW

New member
I found a solution! It requires Developer options and ADB, but not root. This is for a Motorola Razr+, but it should also work for Samsung flips and similar, once you capture the appropriate logcat entry.
  • In Developer options, enable "USB debugging" and "Disable adb authorization timeout"; "Wireless debugging" should be OFF. Wireless debugging is fine for the initial capture if that's how you're connected, but it should be disabled once the macro is set.
  • When setting the Trigger in Macrodroid, only Main and System need be checked
Regarding the constraints (see first screenshot), I have them to prevent sound playing if I'm answering a call by flipping open, or transitioning a call from the closed to open state.

NOTE: Since Android 13, you can only grant 1-time access to logcat. So, you'll have to regrant it every time you boot. My phone prompts me automatically, YMMV. It's also a good idea to ensure Macrodroid does not have battery optimization set. I can hardly wait to see what Android 14 has in store for us. 🙁
 

Attachments

  • Screenshot_20231009-180032.png
    Screenshot_20231009-180032.png
    126.5 KB · Views: 10
  • Screenshot_20231009-171854.png
    Screenshot_20231009-171854.png
    165.1 KB · Views: 10
Top