New Trigger and Constraint: Device Hinge Angle

apollo316

New member
Hello there! I'm a long time listener, first time caller. I've read the posting guidelines and though this is a unique device feature, foldables are a growing part of the Android market and it's a native (far as I can tell) Android API to read device hinge angle, so I felt this merited mention and request.

Devices such as the Samsung Fold/Flip, Moto Razr foldables have a device hinge angle sensor that reports back to the OS the angle state. This allows the OS to turn off the foldable screen when folded closed, and utilize the external-facing display instead. From my tests on the Samsung Z Flip this sensor reports 0 degrees, 90 degrees, and 180 degrees. It does not appear to record any angles more granular than that, but that's 3 useful Triggers or Constraints for MacroDroid automations.




● Why this is needed?​


Using Device Hinge Angle sensor results as a trigger, or constraint, opens a world of other combinations of actions within MacroDroid.
For example:
  1. hinge-angle=0 degrees then turn on power saving, play custom sound, turn off wireless radios, etc.
  2. hinge-angle=90 degrees then turn on tethering, launch camera, turn on flashlight, multi-window, video conference app, etc.
  3. hinge-angle=180 degrees then play custom sound, turn off power saving
Constraints would allow for extra safety in the trigger for device hinge angle. For example:
Trigger:
  • Display turned on
    • Constraint: hinge-angle =/greater than 90 degrees
Actions:
  • Play sound: Custom sound
  • Turn off battery saver
This would result in a custom flip open sound and battery saver turning off, but only when the phone is being flipped open. When the angle=0 degrees and the display turns on for a notification no custom sound would play and battery saver remains enabled, since it's outside the conditions of the macro.
 

Dimlos

Well-known member
My personal opinion is that folding devices are very expensive and not many people have them.
If you can afford such an expensive device, I would like to ask you to upgrade to Pro of course for MD development, and I would also like to ask you to make a donation.
 

apollo316

New member
My personal opinion is that folding devices are very expensive and not many people have them.
If you can afford such an expensive device, I would like to ask you to upgrade to Pro of course for MD development, and I would also like to ask you to make a donation.
I appreciate your input. You are right, these are expensive devices. My company purchased mine for me, and while I don't have statistics on foldable saturation in the marketplace, I can say I'm running into more and more people every day that have one, and I personally know 6 people with them just in my local community. Another 20,800 on r/galaxyzflip.

I developed an automation for the Android app Automate that utilizes the hinge angle sensor to produce custom open/close sounds, but I find MacroDroid to have the far superior UX and is therefore easy to adopt for most users and quite powerful.
For reference here is my script, which has also been featured in a number of youtube videos reviewing Flip phones where the youtubers pointed to using Automate to accomplish the actions: https://www.reddit.com/r/galaxyzflip/comments/pzet2o


I believe requesting a feature so I can further raise awareness of MacroDroid to more users is a very valuable part of supporting development.
Even if it weren't, I've been a Pro member since 7/2016 and been an avid user of MacroDroid since 2014. With my support of MD, and the notable user-base for flip devices, I'm humbly requesting a feature addition I see becoming more popular in the days to come, if not already sought after. This potentially translates to more users aware of and interested in supporting MD by donating or purchasing Pro. If this isn't a viable feature for ArloSoft and team that's understandable. If it is, then I plan to make more macros for the r/galaxyzflip and youtube community to raise awareness of this amazing app.
 
Last edited:

Quidn

Passionate Member
Hello there! I'm a long time listener, first time caller. I've read the posting guidelines and though this is a unique device feature, foldables are a growing part of the Android market and it's a native (far as I can tell) Android API to read device hinge angle, so I felt this merited mention and request.

Devices such as the Samsung Fold/Flip, Moto Razr foldables have a device hinge angle sensor that reports back to the OS the angle state. This allows the OS to turn off the foldable screen when folded closed, and utilize the external-facing display instead. From my tests on the Samsung Z Flip this sensor reports 0 degrees, 90 degrees, and 180 degrees. It does not appear to record any angles more granular than that, but that's 3 useful Triggers or Constraints for MacroDroid automations.




● Why this is needed?​


Using Device Hinge Angle sensor results as a trigger, or constraint, opens a world of other combinations of actions within MacroDroid.
For example:
  1. hinge-angle=0 degrees then turn on power saving, play custom sound, turn off wireless radios, etc.
  2. hinge-angle=90 degrees then turn on tethering, launch camera, turn on flashlight, multi-window, video conference app, etc.
  3. hinge-angle=180 degrees then play custom sound, turn off power saving
Constraints would allow for extra safety in the trigger for device hinge angle. For example:
Trigger:
  • Display turned on
    • Constraint: hinge-angle =/greater than 90 degrees
Actions:
  • Play sound: Custom sound
  • Turn off battery saver
This would result in a custom flip open sound and battery saver turning off, but only when the phone is being flipped open. When the angle=0 degrees and the display turns on for a notification no custom sound would play and battery saver remains enabled, since it's outside the conditions of the macro.

It can be done by pretty easily if you don't use Modes in Modes and Routines.

Trigger below will be immediately fired when a Mode is turned on or off or being switched between another.
Screenshot_20230908_132131_MacroDroid.png

Constraint or condition below will be depends on whether the name of current Mode is matching.
Screenshot_20230908_132231_MacroDroid.png

Using Modes(in Modes and Routines) only for this purpose may sounds unreasonable, but most cases of Modes might replaced by one or combination of Routines and MacroDroid.

However yes, this is just an example of alternative workaround and doesn't mean your request is unnecessary.

Maybe Logcat Entry trigger could be used rather than reading current Mode, but I'm not sure because I don't have any foldable device.


My personal opinion is that folding devices are very expensive and not many people have them.
If you can afford such an expensive device, I would like to ask you to upgrade to Pro of course for MD development, and I would also like to ask you to make a donation.

While you didn't said that OP didn't upgrade to Pro but seems pretty sure to considering as didn't. If so, I wonder how did you consider OP didn't upgrade to Pro.

It is fact that they're relatively more expensive than most of Android phones, but I can't say they are that very expensive to saying like that since they have similar price range compared to iPhone series's.

Anyway I don't think relative price difference is not at all an important point and let me think about to respect your opinion.
 

Snurre

Well-known member
My personal opinion is that folding devices are very expensive and not many people have them.
If you can afford such an expensive device, I would like to ask you to upgrade to Pro of course for MD development, and I would also like to ask you to make a donation.
OMG
 

Quidn

Passionate Member
Unfortunately, from Android 13+ Logcat is not accessible

I'm afraid that's not true.

MacroDroid installed on OneUI 5.1(Android 13) reads Logcat message fine without any problem.

Nevertheless your claim could be almost true if that policy is applied only to newly installed applications after update, because I didn't any test on newly installed MacroDroid.

Could you provide any reference? I can't find someone else mentioned that changing.
 

Endercraft

Moderator (& bug finder :D)
Maybe MacroDroid can still read its own Logcat. I saw this behavior with Termux.

 
Last edited:

Quidn

Passionate Member
Maybe MacroDroid can still read its own Logcat. I saw this behavior with Termux.


I'm not an Android expert and especially to recent versions but not that level of beginner to confuse where the log from. ;)

Screenshot_20230908_171339_Settings.png
mdLogcatEntries-1.pngmdLogcatEntries-2.pngmdLogcatEntries-3.pngmdLogcatEntries-4.pngmdLogcatEntries-5.pngmdLogcatEntries-6.pngmdLogcatEntries-7.pngmdLogcatEntries-8.png
 

Endercraft

Moderator (& bug finder :D)
What MD version are you on ? As far as I know there is no way to bypass this unless your OS lets you or using ADB.
 

Quidn

Passionate Member
What MD version are you on ? As far as I know there is no way to bypass this unless your OS lets you or using ADB.

5.36.8 which stated as the latest version in the Play Store.

Screenshot_20230908_182422_MacroDroid.pngScreenshot_20230908_183003_Settings.jpg
Screenshot_20230908_183038_Google Play Store.png

There is one thing, every time I enabling macro I have to manually allow this. Maybe allowing this would be done automatically by using UI interaction but not tested.

20230908_183816.png
 

Endercraft

Moderator (& bug finder :D)
Yes we are talking about enabling this one time permission. You need the user to be active.. And I'm pretty sure you can't call for granting when app is in background.
 

Quidn

Passionate Member
Yes we are talking about enabling this one time permission. You need the user to be active.. And I'm pretty sure you can't call for granting when app is in background.

I see now.



I just read this which was added a minute after you posted.
But isn't it required only once at the trigger is initializing?

Anyway now I'll assume that it's not possible in practical.

Thank you for feeding the reference and teach me.


Unfortunately, from Android 13+ Logcat is not accessible

I don't want to blaming you and you were correct, but I want to say that wording confused me.

I just focused whether it is accessible or not itself and didn't see other concerns.

Thank you too for correct my assumption.
 

Endercraft

Moderator (& bug finder :D)
If you let the command be active I think it's fine but if it's ever interrupted you have to grant again (depending on when you last granted permission).
 

Dimlos

Well-known member
I know there are a lot of people with different ideas, but I donated because I think it's better for the MD community to donate a small amount than to buy a folding device for $1000.
 

Attachments

  • Donate.jpg
    Donate.jpg
    438.2 KB · Views: 7
  • Receive.jpg
    Receive.jpg
    523.1 KB · Views: 8
  • Mail.jpg
    Mail.jpg
    243.1 KB · Views: 8

Quidn

Passionate Member
If you let the command be active I think it's fine but if it's ever interrupted you have to grant again (depending on when you last granted permission).

You are right.

I stopped to think about this because there must be some practical reason to everyone assume that it's not possible.

Wording below was my conclusion about concerns including above:
Anyway now I'll assume that it's not possible in practical.
 

Snurre

Well-known member
I know there are a lot of people with different ideas, but I donated because I think it's better for the MD community to donate a small amount than to buy a folding device for $1000.
Again, OMG !
What and who do you think you are ? To think you have the privilege to judge people
As far as I know from your posts during time, you have been buying several devices, what did that cost you ? Is that better than buying a phone you really want ?
You posted screenshot of your donation, what shall we do with that? Clap our hands ? Shout hurrah? Tap your shoulder?
I've also donated, but I'm not bragging about it
In Denmark we have a saying, "Fej for din egen dør først", feel free to translate or don't
Have a nice weekend
 

Endercraft

Moderator (& bug finder :D)
As far as I remember last time you had a saying MacroDroidDev closed the thread.. Let's not do that again okay 😂
 

Snurre

Well-known member
As far as I remember last time you had a saying MacroDroidDev closed the thread.. Let's not do that again okay 😂
I can't recall a thread being closed because of my opinion

I'm just saying, this forum is not about personal opinions what devices people like and save money to buy just that, that's it

So correct me if I'm wrong, in my previous post
 

Dimlos

Well-known member
I own many devices but for verification purposes. (Many of them used).

For example, many people use Xiaomi devices, but you can't tell them to buy a Google Pixel, can you?
I go out of my way to buy a Xiaomi device and post a solution, even though the Google Pixel has a lower incidence of problems.

If development resources were focused on folding devices and new features for folding devices were released one after another, would you all pay $1000 for a folding device?

Wouldn't it be better to devote resources to features that will be useful to everyone rather than features that you have to pay $1000 to use?

I have included a screenshot of the donation to prove that it is not just a menu selection. Please don't make accusations.
 
Top