Greenify alternative: Automagic
Moderator: Martin
Greenify alternative: Automagic
Hi,
I want to kill all running user tasks when screen off. Can I use General Broadcast trigger to do this? Please give me a example to get ruuning task list if it's possible. If screen state is on, launch only Automagic if not running or may prevent it from kill. Thanks.
I want to kill all running user tasks when screen off. Can I use General Broadcast trigger to do this? Please give me a example to get ruuning task list if it's possible. If screen state is on, launch only Automagic if not running or may prevent it from kill. Thanks.
Re: Greenify alternative: Automagic
You need to use execute root command (of course need root)
to get the current foreground app. Grab the pid using regex and use
to kill to it. However, It seems the screen should be on to do it.
Dumpsys can be used to get more info about running app. The one I think you should be care about is not the foreground, but background services those probably running all day long without you noticing.
My phone has battery optimizer, which will "kill" any unwhitelisted app after 5 minutes off. Maybe you should find if you have that option too
Code: Select all
dumpsys activity | grep top-activity
Code: Select all
kill {pid}
Dumpsys can be used to get more info about running app. The one I think you should be care about is not the foreground, but background services those probably running all day long without you noticing.
My phone has battery optimizer, which will "kill" any unwhitelisted app after 5 minutes off. Maybe you should find if you have that option too
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
Hi Desmanto,
Thank you for your attention. Can you give me a example for regex usage for parse this output?
Thank you for your attention. Can you give me a example for regex usage for parse this output?
14.12.2017 11:20:25.560 [Flow1] Action 'Execute Root Command: dumpsys -l as root in ' stderr=
14.12.2017 11:20:25.561 [Flow1] Action 'Execute Root Command: dumpsys -l as root in ' exit_code=0
14.12.2017 11:20:25.562 [Flow1] End executing action 'Execute Root Command: dumpsys -l as root in '
14.12.2017 11:20:25.563 [Flow1] Flow continues executing with the next step.
14.12.2017 11:20:25.564 [Flow1] Start executing action 'Script: log({stdout})'
14.12.2017 11:20:25.574 [Flow1] Currently running services:
AAL
BWC
DmAgent
NvRAMAgent
PPLAgent
SurfaceFlinger
accessibility
account
activity
alarm
android.security.keystore
anrmanager
appops
appwidget
assetatlas
audio
audioprofile
backup
battery
batterypropreg
batterystats
bluetooth_manager
bluetooth_profile_manager
clipboard
commontime_management
connectivity
consumer_ir
content
country_detector
cpuinfo
dbinfo
device_policy
devicestoragemonitor
diskstats
display
dreams
drm.drmManager
dropbox
entropy
gfxinfo
hardware
input
input_method
iphonesubinfo
iphonesubinfo2
isms
isms2
kjrnlfb
location
lock_settings
media.VTS
media.audio_flinger
media.audio_policy
media.camera
media.player
media_router
meminfo
memory.dumper
mobile
mount
mtk-agps
mtk-perfservice
mtk.codecservice
netpolicy
netstats
network_management
notification
package
permission
phone
phoneEx
power
procstats
samplingprofiler
scheduling_policy
search
search_engine
sensorservice
serial
servicediscovery
simphonebook
simphonebook2
statusbar
telephony.registry
telephony.registry2
textservices
uimode
updatelock
usagestats
usb
user
user.fb_incallsvc
user.kjournald
user.kjrnlfb
vibrator
wallpaper
wifi
wifip2p
window
Re: Greenify alternative: Automagic
dumpsys -l give not much information about the app. You have to get the package name or the PID as my previous post. Or you can use
which gives more detail. However, most of the services shown are system related. It seems there is no user apps service there. So maybe this is not the proper way.
It seems you only concern about the recent apps only. You can try
This will list all recent running apps, which probably suitable for your needs. See if these are what you need. I am still working on the regex. We can take out the package name and kill it later.
To check the output of the command, just attach a debug dialog after the execute root command. You can check the result of the stdout.
Code: Select all
service list
It seems you only concern about the recent apps only. You can try
Code: Select all
dumpsys activity | grep -i 'run #'
To check the output of the command, just attach a debug dialog after the execute root command. You can check the result of the stdout.
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
Hi Desmanto,
Can i retrieve only recent apps list[/color] by using? For example:
Recent tasks:
* Recent #1: TaskRecord{42627518 #2 A=com.android.shlylauncher2 U=0 sz=1}
* Recent #2: TaskRecord{42c7d2b8 #157 A=com.android.systemui U=0 sz=1}
* Recent #3: TaskRecord{42637e08 #156 A=ch.gridvision.ppam.androidautomagic U=0 sz=0}
* Recent #4: TaskRecord{42a07170 #164 A=com.gbwhatsapp U=0 sz=1}
* Recent #5: TaskRecord{42bbdce8 #162 A=android.task.mms U=0 sz=1}
* Recent #6: TaskRecord{425d1a68 #159 A=android.task.contacts U=0 sz=1}
dumpsys activity command is returning too much data, it is possible to specify this with command parameter (if any).
In other case may need to parse all data line by line to determine recent tasks and use them. Thanks for your suggestions.
Can i retrieve only recent apps list[/color] by using
Code: Select all
dumpsys activity
Recent tasks:
* Recent #1: TaskRecord{42627518 #2 A=com.android.shlylauncher2 U=0 sz=1}
* Recent #2: TaskRecord{42c7d2b8 #157 A=com.android.systemui U=0 sz=1}
* Recent #3: TaskRecord{42637e08 #156 A=ch.gridvision.ppam.androidautomagic U=0 sz=0}
* Recent #4: TaskRecord{42a07170 #164 A=com.gbwhatsapp U=0 sz=1}
* Recent #5: TaskRecord{42bbdce8 #162 A=android.task.mms U=0 sz=1}
* Recent #6: TaskRecord{425d1a68 #159 A=android.task.contacts U=0 sz=1}
dumpsys activity command is returning too much data, it is possible to specify this with command parameter (if any).
In other case may need to parse all data line by line to determine recent tasks and use them. Thanks for your suggestions.
Re: Greenify alternative: Automagic
Use my previous code
the grep will ensure I only grab the line with 'run #'; which in my result is the recent list. If you want to grab the '* Recent #', you can change the grep part
Or maybe try with ': TaskRecord{' too
If you are using as mine, grep the 'run #', you can use the following script to iterate over the recent list and save it to list rec
The result is the list of package name from recent menu in list rec. You can remove the element which contain automagic package name too, or any other app you want to exclude. Then loop over the list to kill each app which is not whitelisted.
Code: Select all
dumpsys activity | grep -i 'run #'
Code: Select all
dumpsys activity | grep -i '* Recent #'
If you are using as mine, grep the 'run #', you can use the following script to iterate over the recent list and save it to list rec
Code: Select all
find = findAll(stdout, 'Run #\\d+: ActivityRecord\\{\\w+ u0 (.*)/.* \\w+\\}', true);
rec = newList();
for(i in find)
addElement(rec, i[1]);
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
Hi Desmanto,
findAll functiun not working on my phone (MTK6592 based, android 4.4.2, rooted). Automagic v1.31 premium. Any other suggestions? Thanks.
findAll functiun not working on my phone (MTK6592 based, android 4.4.2, rooted). Automagic v1.31 premium. Any other suggestions? Thanks.
Re: Greenify alternative: Automagic
findAll() was introduced in Automagic 1.33.0 and extended again to have capturing group in 1.34.0.
Please update your Automagic to the latest version to use the function.
Without regex, it is quite difficult to parse the text properly. Too complicated.
Please update your Automagic to the latest version to use the function.
Without regex, it is quite difficult to parse the text properly. Too complicated.
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
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
Additonal argument true at findAll() only available in 1.34.0. You have to update to that version first.
Without capturing group, we still can use 1.33.0 findAll() + matches() to capture that. But that is deprecated already, since we have stable 1.34.0. (why should we use less effective function).
You flow loop only without storing the variable to new element, thus won't work. Should declared a newList() variable first to store the loop result, as you see at my previous post.
Using my script, the rec will contain something like [com.android.chrome, com.whatsapp, com.teslacoilsw.launcher].
Then using we loop similar to the template - loop over list to loop all element (package name) and kill each of them using Kill App/Kill App Process.
Without capturing group, we still can use 1.33.0 findAll() + matches() to capture that. But that is deprecated already, since we have stable 1.34.0. (why should we use less effective function).
You flow loop only without storing the variable to new element, thus won't work. Should declared a newList() variable first to store the loop result, as you see at my previous post.
Using my script, the rec will contain something like [com.android.chrome, com.whatsapp, com.teslacoilsw.launcher].
Then using we loop similar to the template - loop over list to loop all element (package name) and kill each of them using Kill App/Kill App Process.
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.