Run Shell - improve priority for the foreground app

1,284 views
Skip to first unread message

Fabio Albieri

unread,
Dec 12, 2011, 7:55:18 AM12/12/11
to Tasker
Hi,

I just discovered the magnificent Run Shell (with root) action.
Amazing. Really. Gave me a way to workaround Google Maps battery drain
without renouncing Maps ! See my other post.


Now,
Recently I read the article about "why android will never be as smooth
as iOS". Part of the argument there was about iOS maxing out priority
to the foreground app.

I'd be interested to replicate this, to a much lesser extent, on
Android.

Would you suggest a Tasker solution to
- when screen on, check which app is foreground (active and being used
by user). No more frequent than 15 seconds, just to save battery, or
being sensible to active app switch
- find which priority the active app is running
- lower (prioritize) priority by "some", while preventing it to go
full real-time (saving Android multitasking)


I'd be very curious to try this.
Many thanks to who takes the challenge and shares here !


Fabio

V Oz

unread,
Dec 12, 2011, 8:19:18 AM12/12/11
to tas...@googlegroups.com
Dig to 'nice' command. With OS Monitor I can change nice priority. In shell there is nice command as part of busybox multicall elf. But I can't change priority of tasker from shell. (net.dinglisch.android.tasker)
# nice net.dinglisch.android.tasker
nice: net.dinglisch.android.tasker: No such file or directory

how to re-run package from shell?

V Oz

unread,
Dec 12, 2011, 8:32:12 AM12/12/11
to tas...@googlegroups.com
man says: renice [[-r] priority pids ...] [-g pid]

so.
ps | grep tasker => get PID
renice -11 -p PID

viola

V Oz

unread,
Dec 12, 2011, 8:36:09 AM12/12/11
to tas...@googlegroups.com
renice -10 -p `pidof net.dinglisch.android.tasker`

TomL

unread,
Dec 12, 2011, 8:36:34 AM12/12/11
to tas...@googlegroups.com
The comand is used to run a command at the designated nice level:

% nice +19 this_process_will_be _run_at_low_priority
% nice -19 this_process_will_be _run_at_high_priority

If you want to change the nice level of an existing process, then find the process ID of the process and use the renice command:

% renice +19 12345
% renice -19 12345

You'll need to be root in order to do most of the above.

Tom


Fabio Albieri

unread,
Dec 12, 2011, 8:41:38 AM12/12/11
to Tasker
Thank you both !
So now it's still to know how to find which app is currently the
foreground one...

TomL

unread,
Dec 12, 2011, 8:46:48 AM12/12/11
to tas...@googlegroups.com
I like your idea.  But I think the Android OS already does something like this.  Look at the developer docs here:


Tom

V Oz

unread,
Dec 12, 2011, 8:48:18 AM12/12/11
to tas...@googlegroups.com
I bet You do not need give all foreground apps -15 level. About 5 items in that list.
so, create 5 profiles with App context (or var %WIN). Find what package relates to that app and put in entry task run shell action renice -10 -p `pidof %app_package_name`

Fabio Albieri

unread,
Dec 14, 2011, 4:15:40 AM12/14/11
to Tasker
This would do for, let's say, 5 predefined apps. It may be fine,
altough not exactly what I had in mind.
Also, I forgot a crucial design point: once the foreground, being used
app is no longer, previous priority should be restored (while the new
foreground app receives the prioritization treatment).

V Oz

unread,
Dec 14, 2011, 4:24:46 AM12/14/11
to tas...@googlegroups.com
add an Exit task to App  profiles with renice %prew_priority `pidof app`
Reply all
Reply to author
Forward
0 new messages