Macro gets triggered but doesn't do action.

Status
Not open for further replies.

CornflaX

New member
Hey there,
I got a macro that puts my media volume to 0, if I open one of my games.
I've got a new phone with android 12 and the macro's not working anymore.

I can see, that it gets triggered, because it says 0 min ago.
And if I test the action (Volume change: media = 0%), that also works.

I gave all the permissions for MacroDroid, as well as no battery optimization and data/app-usage.

Only constraint is "headphones not connected" but already tested without it.

What am I missing?
 

Attachments

  • Screenshot_2022-04-30-11-45-20-95_2e840d222d67ef3caca3a1c67d71d48f.jpg
    Screenshot_2022-04-30-11-45-20-95_2e840d222d67ef3caca3a1c67d71d48f.jpg
    330.6 KB · Views: 11

Pseudocyclic

Well-known member
What happens if you set the Volume Change action to a different value, for example 50%?

What happens if you set the trigger to MacroDroid opening instead of your game?
 

CornflaX

New member
Different value no difference.

But it works, if I include MacroDroid to the application list.
Also tried with other apps, but despite being triggered there's no effect.
 

FrameXX

Well-known member
Seems like the tablet won't let macrodroid update volume from background. I think I translated string in MacroDroid translation about new option to update volume from foreground so it's possible this will be included in next update, but maybe I am lying.

There are 2 things I think you could try.

You could try putting the update clipboard action before the volume change action, which will force MacroDroid into foreground for a little while and maybe help.

Or you could use the volume down action and repeat it 15 times in loop. This could also work.

I think I translated string in MacroDroid translation about new option to update volume from foreground so it's possible this will be included in next update, but maybe I am lying.
I am now 90% sure I was lying.
 
Last edited:

CornflaX

New member
sick, it actually works.
Refresh clipboard didn't, but the loop does :D
Here's the final macro:
 

Attachments

  • Screenshot_2022-04-30-21-32-27-86_2e840d222d67ef3caca3a1c67d71d48f.jpg
    Screenshot_2022-04-30-21-32-27-86_2e840d222d67ef3caca3a1c67d71d48f.jpg
    403.4 KB · Views: 24

CornflaX

New member
I'm sorry but, someone already gave me a working solution.
It seems like you only read "refresh clipboard doesn't work" or I don't know...
 
Depends on what version of Android you have. My version covers of them all and is well documented (a future developer can work on the code and realize the intent of the code, which leads to lower maintenance costs and bugs.
 
Did you even look at my code. It is very relevant to the conversation. I I've been a professional software engineer for 40 years, coding longer than that.

If you don't understand why my note is relevant than you're just a bully and I'm giving up MacroDroid for Dart and Flutter.
 
All you angry folks while you're mad at me, go ahead and have a good laugh.

One of the points I was trying to make is this:
Although the code may work on your phone, it will work on a decreasing number of phones and tablets.

Due to a bug in newer versions of Android, your code will also instantiate another version of itself, therefore, if you don't have a way programmatically to deal with this, all of your variables will change to unexpected values.

I was trying to show you good programming techniques, instead you say, "works for me", or get angry with me.

Did you even look at the code snippet that took me effort to post? You might learn something.

I'm done trying to help bullies.
 

FrameXX

Well-known member
Don't take it too seriously. No one's angry at you. Next time I will be careful with using angry emoticon reaction.

Although the code may work on your phone, it will work on a decreasing number of phones and tablets.

Althought I understand your good intentions to make the macro work for more devices (even thought that's something OP doesn't need), I think you didn't read the original post carefully. In your screenshot you are trying to get clipboard content on Android 10+ and 9-, however we are trying to change the audio volume from foreground instead of background (not save clipboard content into a variable nor anything related to clipboard content) and this issue is problem of different manufacturers rather than different Android SDK versions.
 
Don't take it too seriously. No one's angry at you. Next time I will be careful with using angry emoticon reaction.



Althought I understand your good intentions to make the macro work for more devices (even thought that's something OP doesn't need), I think you didn't read the original post carefully. In your screenshot you are trying to get clipboard content on Android 10+ and 9-, however we are trying to change the audio volume from foreground instead of background (not save clipboard content into a variable nor anything related to clipboard content) and this issue is problem of different manufacturers rather than different Android SDK versions.
Hyrum’s Law
If you are maintaining a project that is used by other engineers, the most important lesson about “it works” versus “it is maintainable” is what we’ve come to call Hyrum’s Law: With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody. In our experience, this axiom is a dominant factor in any discussion of changing software over time. It is conceptually akin to entropy: discussions of change and maintenance over time must be aware of Hyrum’s Law8 just as discussions of efficiency or thermodynamics must be mindful of entropy. Just because entropy never decreases doesn’t mean we shouldn’t try to be efficient. Just because Hyrum’s Law will apply when maintaining software doesn’t mean we can’t plan for it or try to better understand it. We can mitigate it, but we know that it can never be eradicated. Hyrum’s Law represents the practical knowledge that—even with the best of intentions, the best engineers, and solid practices for code review—we cannot assume perfect adherence to published contracts or best practices. As an API owner, you will gain some flexibility and freedom by being clear about interface promises, but in practice, the complexity and difficulty of a given change also depends on how useful a user finds some observable behavior of your API. If users cannot depend on such things, your API will be easy to change. Given enough time and enough users, even the most innocuous change will break something;9 your analysis of the value of that change must incorporate the difficulty in investigating, identifying, and resolving those breakages.

8 To his credit, Hyrum tried really hard to humbly call this “The Law of Implicit Dependencies,” but “Hyrum’s Law” is the shorthand that most people at Google have settled on. 9 See “Workflow,” an xkcd comic. 8 | Chapter 1: What Is Software Engineering?

Example:
Hash Ordering Consider the example of hash iteration ordering. If we insert five elements into a hash-based set, in what order do we get them out?
>>> for i in {"apple", "banana", "carrot", "durian", "eggplant"}:
print(i)

durian carrot apple eggplant banana

Most programmers know that hash tables are non-obviously ordered. Few know the specifics of whether the particular hash table they are using is intending to provide that particular ordering forever. This might seem unremarkable, but over the past decade or two, the computing industry’s experience using such types has evolved: • Hash flooding10 attacks provide an increased incentive for nondeterministic hash iteration. • Potential efficiency gains from research into improved hash algorithms or hash containers require changes to hash iteration order. • Per Hyrum’s Law, programmers will write programs that depend on the order in which a hash table is traversed, if they have the ability to do so. As a result, if you ask any expert “Can I assume a particular output sequence for my hash container?” that expert will presumably say “No.” By and large that is correct, but perhaps simplistic. A more nuanced answer is, “If your code is short-lived, with no changes to your hardware, language runtime, or choice of data structure, such an assumption is fine. If you don’t know how long your code will live, or you cannot promise that nothing you depend upon will ever change, such an assumption is incorrect.” Moreover, even if your own implementation does not depend on hash container order, it might be used by other code that implicitly creates such a dependency. For example, if your library serializes values into a Remote Procedure Call (RPC) response, the RPC caller might wind up depending on the order of those values. This is a very basic example of the difference between “it works” and “it is correct.” For a short-lived program, depending on the iteration order of your containers will not cause any technical problems. For a software engineering project, on the other hand, such reliance on a defined order is a risk—given enough time, something will.

10 A type of Denial-of-Service (DoS) attack in which an untrusted user knows the structure of a hash table and the hash function and provides data in such a way as to degrade the algorithmic performance of operations on the table.

Time and Change

Make it valuable to change that iteration order. That value can manifest in a number of ways, be it efficiency, security, or merely future-proofing the data structure to allow for future changes. When that value becomes clear, you will need to weigh the tradeoffs between that value and the pain of breaking your developers or customers. Some languages specifically randomize hash ordering between library versions or even between execution of the same program in an attempt to prevent dependencies. But even this still allows for some Hyrum’s Law surprises: there is code that uses hash iteration ordering as an inefficient random-number generator. Removing such randomness now would break those users. Just as entropy increases in every thermodynamic system, Hyrum’s Law applies to every observable behavior. Thinking over the differences between code written with a “works now” and a “works indefinitely” mentality, we can extract some clear relationships. Looking at code as an artifact with a (highly) variable lifetime requirement, we can begin to categorize programming styles: code that depends on brittle and unpublished features of its dependencies is likely to be described as “hacky” or “clever,” whereas code that follows best practices and has planned for the future is more likely to be described as “clean” and “maintainable.” Both have their purposes, but which one you select depends crucially on the expected life span of the code in question. We’ve taken to saying, “It’s programming if ‘clever’ is a compliment, but it’s software engineering if ‘clever’ is an accusation.”

From "Software Engineering at Google" Chapter 1
 
Hyrum’s Law
If you are maintaining a project that is used by other engineers, the most important lesson about “it works” versus “it is maintainable” is what we’ve come to call Hyrum’s Law: With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody. In our experience, this axiom is a dominant factor in any discussion of changing software over time. It is conceptually akin to entropy: discussions of change and maintenance over time must be aware of Hyrum’s Law8 just as discussions of efficiency or thermodynamics must be mindful of entropy. Just because entropy never decreases doesn’t mean we shouldn’t try to be efficient. Just because Hyrum’s Law will apply when maintaining software doesn’t mean we can’t plan for it or try to better understand it. We can mitigate it, but we know that it can never be eradicated. Hyrum’s Law represents the practical knowledge that—even with the best of intentions, the best engineers, and solid practices for code review—we cannot assume perfect adherence to published contracts or best practices. As an API owner, you will gain some flexibility and freedom by being clear about interface promises, but in practice, the complexity and difficulty of a given change also depends on how useful a user finds some observable behavior of your API. If users cannot depend on such things, your API will be easy to change. Given enough time and enough users, even the most innocuous change will break something;9 your analysis of the value of that change must incorporate the difficulty in investigating, identifying, and resolving those breakages.

8 To his credit, Hyrum tried really hard to humbly call this “The Law of Implicit Dependencies,” but “Hyrum’s Law” is the shorthand that most people at Google have settled on. 9 See “Workflow,” an xkcd comic. 8 | Chapter 1: What Is Software Engineering?

Example:
Hash Ordering Consider the example of hash iteration ordering. If we insert five elements into a hash-based set, in what order do we get them out?
>>> for i in {"apple", "banana", "carrot", "durian", "eggplant"}:
print(i)

durian carrot apple eggplant banana

Most programmers know that hash tables are non-obviously ordered. Few know the specifics of whether the particular hash table they are using is intending to provide that particular ordering forever. This might seem unremarkable, but over the past decade or two, the computing industry’s experience using such types has evolved: • Hash flooding10 attacks provide an increased incentive for nondeterministic hash iteration. • Potential efficiency gains from research into improved hash algorithms or hash containers require changes to hash iteration order. • Per Hyrum’s Law, programmers will write programs that depend on the order in which a hash table is traversed, if they have the ability to do so. As a result, if you ask any expert “Can I assume a particular output sequence for my hash container?” that expert will presumably say “No.” By and large that is correct, but perhaps simplistic. A more nuanced answer is, “If your code is short-lived, with no changes to your hardware, language runtime, or choice of data structure, such an assumption is fine. If you don’t know how long your code will live, or you cannot promise that nothing you depend upon will ever change, such an assumption is incorrect.” Moreover, even if your own implementation does not depend on hash container order, it might be used by other code that implicitly creates such a dependency. For example, if your library serializes values into a Remote Procedure Call (RPC) response, the RPC caller might wind up depending on the order of those values. This is a very basic example of the difference between “it works” and “it is correct.” For a short-lived program, depending on the iteration order of your containers will not cause any technical problems. For a software engineering project, on the other hand, such reliance on a defined order is a risk—given enough time, something will.

10 A type of Denial-of-Service (DoS) attack in which an untrusted user knows the structure of a hash table and the hash function and provides data in such a way as to degrade the algorithmic performance of operations on the table.

Time and Change

Make it valuable to change that iteration order. That value can manifest in a number of ways, be it efficiency, security, or merely future-proofing the data structure to allow for future changes. When that value becomes clear, you will need to weigh the tradeoffs between that value and the pain of breaking your developers or customers. Some languages specifically randomize hash ordering between library versions or even between execution of the same program in an attempt to prevent dependencies. But even this still allows for some Hyrum’s Law surprises: there is code that uses hash iteration ordering as an inefficient random-number generator. Removing such randomness now would break those users. Just as entropy increases in every thermodynamic system, Hyrum’s Law applies to every observable behavior. Thinking over the differences between code written with a “works now” and a “works indefinitely” mentality, we can extract some clear relationships. Looking at code as an artifact with a (highly) variable lifetime requirement, we can begin to categorize programming styles: code that depends on brittle and unpublished features of its dependencies is likely to be described as “hacky” or “clever,” whereas code that follows best practices and has planned for the future is more likely to be described as “clean” and “maintainable.” Both have their purposes, but which one you select depends crucially on the expected life span of the code in question. We’ve taken to saying, “It’s programming if ‘clever’ is a compliment, but it’s software engineering if ‘clever’ is an accusation.”

From "Software Engineering at Google" Chapter 1
I'm done. Thank you all for listening.
 
Status
Not open for further replies.
Top