Greenify alternative: Automagic
Moderator: Martin
Re: Greenify alternative: Automagic
Hi Desmanto,
Whhat is the problem in this flows? RecentApps getting and KillApp killing app stored in global_task variable, working but apps continuing to run. Thank you. See flows bellow:
Whhat is the problem in this flows? RecentApps getting and KillApp killing app stored in global_task variable, working but apps continuing to run. Thank you. See flows bellow:
- Attachments
-
- flow_group_AKillRecent_20171221_091643.xml
- (4.8 KiB) Downloaded 931 times
Re: Greenify alternative: Automagic
The code stuck in endless loop, at the sleep(100)
It will actually stopped after 16 minutes 40 seconds, reaching 10,000 iterations limit. You should brace the sleep and killing,
That's why code indentation is very important. Whenever you nested out a new logic branch, it is better to give 2 spaces (per level) for the nested one to make it easier to read (or spot the bug).
You don't need the killing var, it is useless there. Simplify your code as
Increase the sleep time as needed, I think you need more than 100, since glovar will be always slower than local variable
And you don't even need another flow by using global task to loop the list. Try the template loop over list (condensed) and pick the recapps as the list.
At the true branch put your killing command, false branch do nothing.
At my phone grepping using "Recent" didn't give a proper result, it will show all past app. Grepping the "Run" gives the proper result (that's why I use that instead). So I can't help much with the regex, even though it still can be done in Automagic 1.33.0; with extra effort.
Code: Select all
for(app in recapps)
{
killing = true;
global_task = app;
while (killing) //this while() only cover the sleep
sleep(100);
killing = false; //this killing is not in the loop
}
Code: Select all
for(app in recapps)
{
killing = true;
global_task = app;
while (killing) //this while() will cover sleep and killing
{
sleep(100);
killing = false; //this killing is now in the loop
}
}
You don't need the killing var, it is useless there. Simplify your code as
Code: Select all
for(app in recapps)
{
global_task = app;
sleep(100);
}
And you don't even need another flow by using global task to loop the list. Try the template loop over list (condensed) and pick the recapps as the list.
At the true branch put your killing command, false branch do nothing.
At my phone grepping using "Recent" didn't give a proper result, it will show all past app. Grepping the "Run" gives the proper result (that's why I use that instead). So I can't help much with the regex, even though it still can be done in Automagic 1.33.0; with extra effort.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Greenify alternative: Automagic
Is there a trigger defined when the device is actually locked (ex: 5 min after UI: lockScreen() so that the fingerprint works to unlock it) ? I searched string device/lock/state in the trigger section and didn't find any suitable.
Is there an action to pop up app list for selection into a var? what I see are all complicated flows to achieve that.
Is there an action to pop up app list for selection into a var? what I see are all complicated flows to achieve that.
Re: Greenify alternative: Automagic
At mine, using lockScreen(), after the device locked, it can be unlocked immediately using fingerprint. If yours takes 5 minutes afterward, probably you have enabled smart locks from google. Can you try to disable the smart lock first? Or you can try to change the automatically lock after, set to immediately.
AFAIR, Input dialog to choose app directly into variable (to take the app name/packagename) has been requested; but not yet implemented till now. The only available method is what you have found, init the package list and make a list of it to choose in input dialog.
AFAIR, Input dialog to choose app directly into variable (to take the app name/packagename) has been requested; but not yet implemented till now. The only available method is what you have found, init the package list and make a list of it to choose in input dialog.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Greenify alternative: Automagic
Yes, I set smart lock to 5 min because I might open the phone again within 5 min. Having that said, I want flow to kill all the apps outside ignored list take place after device is actually locked, not just screen off.
Sort of like Android assistant app. Wish I can call their api
Sort of like Android assistant app. Wish I can call their api
Re: Greenify alternative: Automagic
Generallly, it is advised not to kill any apps. Android already have the power to put them to sleep. Killing them only use up the CPU resource (and battery) the next time you start them again.
For the locked event, It seems there is no such event. Since the lock happen after 5 minutes, you can simply use trigger Display state off, use sleep 5 minutes and execute the kill task. But this flow should be configured as multi trigger flow with FEP stop. In this same flow, add another trigger screen on and expression to branch to nothing. So basically when screen off, it will wait for 5 minutes. If nothing happen, it will kill the app. If the screen is on during that 5 minutes, the flow triggered and redirected to nothing, essentially stopping the sleep and hence cancel the kill.
But, sleep 5 minutes is quite long, because you will lock and unlock your device many times a day. During sleep, it will wakelock your CPU, draining extra battery. Kinda defeating the original purpose. To make it drain less, you can use other trigger that works like sleep. Use periodic timer set to 5 minutes, add the kill app action and at the end disable itself (set flow state disabled). The flow is disabled by default. At another flow, trigger display state off, enable this periodic timer flow. The first execution of the periodic timer will be the next 5 minutes, so almost the same as sleep 5 minutes, but with no CPU wakelock. After the execution, it disable itself, so the flow only run 1 time everytime it is enabled. For the cancelling, almost the same concept. At another flow Trigger Display state on, disable this periodic timer flow.
For the locked event, It seems there is no such event. Since the lock happen after 5 minutes, you can simply use trigger Display state off, use sleep 5 minutes and execute the kill task. But this flow should be configured as multi trigger flow with FEP stop. In this same flow, add another trigger screen on and expression to branch to nothing. So basically when screen off, it will wait for 5 minutes. If nothing happen, it will kill the app. If the screen is on during that 5 minutes, the flow triggered and redirected to nothing, essentially stopping the sleep and hence cancel the kill.
But, sleep 5 minutes is quite long, because you will lock and unlock your device many times a day. During sleep, it will wakelock your CPU, draining extra battery. Kinda defeating the original purpose. To make it drain less, you can use other trigger that works like sleep. Use periodic timer set to 5 minutes, add the kill app action and at the end disable itself (set flow state disabled). The flow is disabled by default. At another flow, trigger display state off, enable this periodic timer flow. The first execution of the periodic timer will be the next 5 minutes, so almost the same as sleep 5 minutes, but with no CPU wakelock. After the execution, it disable itself, so the flow only run 1 time everytime it is enabled. For the cancelling, almost the same concept. At another flow Trigger Display state on, disable this periodic timer flow.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Greenify alternative: Automagic
OP, @Desmanto, Do you have a working flow now? Ca you share it?Friend1 wrote:Hi Desmanto,
Since RegEx does not return any value, I try to do task termination with split command. I uploaded my flow Can you help me for working flow? Thank you very much.Code: Select all
find = findAll(stdout, 'Run #\\d+: ActivityRecord\\{\\w+ u0 (.*)/.* \\w+\\}', true);
Re: Greenify alternative: Automagic
I just created the flows : 5 minutes app killer
Consists of 2 flows. One is the display on/off trigger, to enable and disable the killer flow. The main flow will use periodic timer at 5 minutes (you can tes at 5 seconds first). At the execution, it will query the recent task using dumpsys, parse the recent app package name. Filter out the whitelist app, in my case, of course Automagic and my launcher, Nova. Then loop kill every app in the recent list. I replace the action with Write text to file to simulate the kill. You can check the content of /storage/emulated/0/Download/kill.txt for the list of apps those are supposed to be killed. After you test it properly, you can replace the element with the kill app.
This flow is just to proof the concept. I still recommend to not kill anything. Nokia's phone now has been known for its worst pie ROM, because of the additional killer app that makes the phone become laggy, drain battery much faster, hot and so many abnormal function.
Consists of 2 flows. One is the display on/off trigger, to enable and disable the killer flow. The main flow will use periodic timer at 5 minutes (you can tes at 5 seconds first). At the execution, it will query the recent task using dumpsys, parse the recent app package name. Filter out the whitelist app, in my case, of course Automagic and my launcher, Nova. Then loop kill every app in the recent list. I replace the action with Write text to file to simulate the kill. You can check the content of /storage/emulated/0/Download/kill.txt for the list of apps those are supposed to be killed. After you test it properly, you can replace the element with the kill app.
This flow is just to proof the concept. I still recommend to not kill anything. Nokia's phone now has been known for its worst pie ROM, because of the additional killer app that makes the phone become laggy, drain battery much faster, hot and so many abnormal function.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Greenify alternative: Automagic
Thanks, I will test out. Mine is zte axon7.
Re: Greenify alternative: Automagic
Term 15 doesn't work on my phone. I also use auto boost from Android assistant.