Find UID of foreground app
Posted: 18 Oct 2014 17:52
Here's a shell script thats finds out the uid of the current foreground app
But it doesnt seem to work with automagic probably because of the {} brackets. And enclosing the command inside '' doesnt seem to work too because ' are being already used in the command. I tried using a combo of App task running and App process runing but I cant get the process name of the current foreground app.
App task running condition might be having a BUG because it always reports automagic activity as the current foreground app (if run from shortcut/gesture). The only way to circumwent is to add a show pause (sleep) between shortcut execution and appt task running condition
Code: Select all
cat /proc/$(pidof $( dumpsys window windows | awk '/mCurrentFocus/ { sub(/\/.*/,""); print $3}' ))/status | awk '/Uid:/ {print $2}'
App task running condition might be having a BUG because it always reports automagic activity as the current foreground app (if run from shortcut/gesture). The only way to circumwent is to add a show pause (sleep) between shortcut execution and appt task running condition