ps | grep u0_ | awk '{print $9 "#"}'
am force-stop %outputX
> To chose the task I want to kill, I need a scene with a button for each running task.
> I could do it with a normal scene and fill this up with command buttons, which I label as the running task and kill with them each task.
> Or is there other maybe better ways instead of WebView and Javascript?
A simple menu element in the scene will put the names in a scrollable menu and a tap on the menu item will give you the name in the local variable %tap_label
You can use a comma separated variable or a variable array to populate the menu.
Now this work like this. I have a task and a scene both named TaskKill
The task:
Taskkill (169)
A1: Run Shell [ Command:ps | grep u0_ | awk '{print $9 "#"}' Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In: Store Result In: ]
A2: Variable Search Replace [ Variable:%output Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A3: Variable Split [ Name:%output Splitter:# Delete Base:Off ]
A4: Show Scene [ Name:TaskKill Display As:Dialog Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:Off Continue Task Immediately:Off ]
A5: If [ %process Set ]
A6: Variable Search Replace [ Variable:%process Search::.* Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A7: Run Shell [ Command:am force-stop %process Timeout (Seconds):5 Use Root:On Store Output In:%output Store Errors In:%error Store Result In: Continue Task After Error:On ]
A8: Popup [ Title: Text:am wirft einen Fehler:
%error Background Image: Layout:PopupFullVerySmallFont Timeout (Seconds):60 Show Over Keyguard:Off ] If [ %error Set ]
A9: Destroy Scene [ Name:TaskKill ]
A10: Else
A11: Destroy Scene [ Name:TaskKill ]
A12: End If
This is the scene:
Scene: TaskKill
P:1080x1920 L:-1x-1
Orientation: System
Background Colour: #FF000000
Action Bar Style: System
Title: TaskKill
Subtitle:
Icon: null
Tab Labels:
Element: Menu1/Menu
Geometry:
P:0,0 1080x1920 L:0,390 1080x494
Content:
Source: Variable Array
Variable: %output
Selection Mode: None
Item Layout: Builtin Item Layout
Horizontal Space: 0
Vertical Space: 0
Events:
ItemClick: 264
ItemLongClick: 267
The next thing would be a search in the top of the menu where I could filter the processes. But think that I won't do this work.
Thanks
Frank
On Oct 17, 2015 5:09 PM, "francwalter"
> The next thing would be a search in the top of the menu where I could filter the processes. But think that I won't do this work.
What type of sort. I have some existing tasks that will sort the menu as you type in text. IE start typing 'd' you get all items starting with d then type 'o' get all items starting with 'do' then type 'g' then the search will switch to all items containing the word 'dog' any where in the text. Let me know if you are interested.
> I use the Label name (package-name) to kill the process, for this I need the package name not the app name. As there is with the Test App action no way to go from App Name back to the package-name I am stuck here
A few ways to do that. You can create duplicate arrays so the package name in one array has the same array index number as the app name in the other. Then instead of using %tap_label use %tap_index
I will pull out my sort task and post it when I get some time...
> Yes exactly this I want! I am interested :)
> Could you post it?
Ok, here is a test project with a basic menu and the sort task. Import the project and run the 'Test task' task with the play button. Type your search into the text edit box. The menu uses a comma separated variable to fill populate the menu.
Feel free to post back with any questions.
> Ok, here is a test project
The best way to get info on any actions or variables you are not familiar with is to use the menu / search tasker feature.
If you do use this in your project you will need to change the ' duplicate array' approach I mentioned earlier. You would still make the same duplicate arrays only go back to using %tap_label then use the array search feature
//
%arr(#?b/c)
A comma-separated list of the array indices (lowest to highest) with matching values, or 0 if none match (2,3 in the example)
//
To find the correct index number for the array with just the names then use that as the index number in the array containing the package names.
> Now I go for the replace the package name to humans name and do this as you mentioned.
> Will take a bit…
Just to clarify that a bit. you should end up with the 2 similar arrays and then set a comma separated "variable" (not variable array) for the menu Items. I would have to go back and re-test but for some reason I think when you use a 'variable array' for the menu items the menu does not update when the array is modified. However it will update when using a comma separated "variable" just use a
action / variable set : %newvar. TO: %var_array(:)
This will give you the comma separated variable.
Then after the item is selected you will just need the test the %tap_label against the array (using the array search I mentioned) Containing the names to get the correct index number to use in the package array.
Simple aye... ? :)
> Now I go for the replace the package name to humans name and do this as you mentioned.
> Will take a bit…Just to clarify that a bit. you should end up with the 2 similar arrays and then set a comma separated "variable" (not variable array) for the menu Items. I would have to go back and re-test but for some reason I think when you use a 'variable array' for the menu items the menu does not update when the array is modified.
However it will update when using a comma separated "variable" just use a
action / variable set : %newvar. TO: %var_array(:)
This will give you the comma separated variable.Then after the item is selected you will just need the test the %tap_label against the array (using the array search I mentioned) Containing the names to get the correct index number to use in the package array.
Taskkill (169)
Abort Existing Task
A1: Run Shell [ Command:ps | grep u0_ | awk '{print $9 ","}' Timeout (Seconds):0 Use Root:On Store Output In:%Menu_data_start Store Errors In: Store Result In: ]
A2: Variable Search Replace [ Variable:%Menu_data_start Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A3: Variable Set [ Name:%Menu_data To:%Menu_data_start Do Maths:Off Append:Off ]
A4: Show Scene [ Name:TaskKill Display As:Activity, Full Window, No Bar Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:Off Continue Task Immediately:Off ]
A5: Flash [ Text:TaskKill beendet. Long:Off ]
A6: Destroy Scene [ Name:TaskKill ]
SortList (277)
Abort Existing Task
A1: Variable Clear [ Name:%fileslista Pattern Matching:Off ]
A2: Variable Set [ Name:%search To:%par1 Do Maths:Off Append:Off ]
A3: Variable Convert [ Name:%search Function:To Lower Case Store Result In: ]
A4: Variable Set [ Name:%search To:+ Do Maths:Off Append:Off ] If [ %search ~ . | %search ~ \%new_val ]
<skip stop>
A5: Test Variable [ Type:Length Data:%search Store Result In:%varlength ]
A6: Variable Set [ Name:%field_data To:%Menu_data_start Do Maths:Off Append:Off ]
<start loop>
A7: Anchor
A8: Variable Split [ Name:%field_data Splitter:, Delete Base:Off ]
A9: Variable Set [ Name:%matches To:%field_data(#?%search*) Do Maths:Off Append:Off ] If [ %varlength < 3 ]
A10: Variable Set [ Name:%matches To:%field_data(#?*%search*) Do Maths:Off Append:Off ] If [ %varlength > 2 ]
A11: If [ %matches ~ 0 ]
A12: Variable Set [ Name:%fileslista To:No Matches Do Maths:Off Append:Off ]
A13: Goto [ Type:Action Label Number:1 Label:skip loop ]
A14: End If
A15: Variable Split [ Name:%matches Splitter:, Delete Base:Off ]
A16: For [ Variable:%item Items:%matches(:) ]
A17: Variable Set [ Name:%fileslista To:%field_data(%item), Do Maths:Off Append:On ]
A18: End For
A19: Stop [ With Error:Off Task: ] If [ %fileslista ~ *fileslista* ]
<skip loop>
A20: Variable Set [ Name:%Menu_data To:%fileslista Do Maths:Off Append:Off ]
A21: Variable Clear [ Name:%fileslista Pattern Matching:Off ]
A22: Array Clear [ Name:%fileslista ]
Scene: TaskKill
P:1080x1920 L:-1x-1
Orientation: System
Background Colour: #FF000000
Action Bar Style: System
Title: TaskKill
Subtitle:
Icon: null
Tab Labels:
Element: Menu_Tasks/Menu
Geometry:
P:0,185 1080x1735 L:0,390 1080x494
Content:
Source: Variable
Variable: %Menu_data
Selection Mode: Single
Item Layout: Builtin Item Layout
Horizontal Space: 1
Vertical Space: 1
Events:
ItemClick: 285
ItemLongClick: 286
Items:
1. Label: de.thecode.android.tazreader
Element: Btn_Help/Button
Geometry:
P:2,1710 149x150 L:2,1770 149x150
Content:
Label:
Label Size: 16
Label Width Scale %: 100
Label Colour: #FF000000
Font:
Position: Centre
Icon: hd_action_help
Events:
Click: 287
Element: Btn_Close/Button
Geometry:
P:927,1710 149x150 L:931,1770 149x150
Content:
Label:
Label Size: 16
Label Width Scale %: 100
Label Colour: #FF000000
Font:
Position: Centre
Icon: hd_ab_content_remove
Events:
Click: 288
Element: Btn_Keep/Button
Geometry:
P:930,0 150x150 L:930,0 150x150
Content:
Label:
Label Size: 16
Label Width Scale %: 100
Label Colour: #FF000000
Font:
Position: Centre
Icon: hd_ab_navigation_collapse
Events:
Click: 289
Element: Txt_search/TextEdit
Geometry:
P:1,0 1079x185 L:1,0 1079x185
Content:
Text:
Text Size: 22
Text Width Scale Percent: 100
Text Colour: #FFFFFFFF
Font:
Position: Centre
Input Type: Normal Text
Maximum Characters: 1000
Events:
ValueSelected: 290
> This is the crucial part. I did this, and the task generates a list with the human names, but I discovered the main drawback in this thing: it takes much too long to find all human names of all packages. 10 Seconds for all apps. That is unbearable.
This is most likely because you used a global variable array in your sort loop. You should be using almost all
Local variables and arrays whenever possible. If you convert it to a local array before the process loop it will run much faster.
> Now I have a fast and working task killer and after all, I learned about arrays as well.
Great..
>
> Thank you very much.
Your welcome..
> This is the crucial part. I did this, and the task generates a list with the human names, but I discovered the main drawback in this thing: it takes much too long to find all human names of all packages. 10 Seconds for all apps. That is unbearable.This is most likely because you used a global variable array in your sort loop. You should be using almost all
Local variables and arrays whenever possible. If you convert it to a local array before the process loop it will run much faster.
TestTaskKill (278)
Abort Existing Task
A1: Run Shell [ Command:ps | grep u0_ | awk '{print $9 ","}' Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In: Store Result In: ]
A2: Variable Search Replace [ Variable:%output Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A3: Variable Split [ Name:%output Splitter:, Delete Base:Off ]
A4: For [ Variable:%package Items:%output() ]
A5: Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
A6: Array Push [ Name:%Menu_data_apps Position:1 Value:%appname Fill Spaces:Off ]
A7: End For
> > %Menu_data_apps is a global variable…
>
> for only the results. I thought that would not be the difference, but indeed, it is, a bit at least.
> Instead of 10 seconds it takes 8 seconds.
Huh... must be one of the processes. However now that you are an array expert, you should be able to build your own package name converter. You can make an array that contains the package name and app name which would be populated only when there was a unknown package name. So the first time you ran the app it would take the 8 seconds then it should get faster with each use until you get all the possible package names. So one of the elements would look like this.
%App_names(1) = package name|app name
So you would first test this array to see if it is a known package name, if it is just split %App_names(1) to get the app name, if it is not known then test the app and add the info to the array.
Just a thought..... :)
> Great! Yes, this a good idea! !
> Thanks :)
>
> Ok, I got it in only 6 seconds now :)
> Attached the project.
Not sure if this is what I was thinking..
Here is how i thought it might go. You would create another variable called %All_names and give it a value of a comma ","
Abort Existing Task
-Variable set %all_names TO: %All_names
-Variable split %all_names
A1: Run Shell [ Command:ps | grep u0_ | awk '{print $9 ","}' Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In: Store Result In: ]
A2: Variable Search Replace [ Variable:%output Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A3: Variable Split [ Name:%output Splitter:, Delete Base:Off ]
A4: For [ Variable:%package Items:%output() ]
-Variable set %index TO: %all_names(#?*%package*)
-If %index ~ 0
- Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
- Array Push [ Name:%all_names Position:1 Value:%package|%appname Fill Spaces:Off ]
-Variable set %index TO: 1
-End if
-Variable set %temp TO: %all_names(%index)
-Variable split %temp Splitter: |
-Array Push [ Name:%Menu_data_apps Position:1 Value:%temp(2) Fill Spaces:Off ]
End If
A7: End For
-variable set %All_names TO: %all_names
Every time the task is tun this should populate the array %all_names with the package name|app name of every package name it does not already have. So it will eventually learn all the package and app names and will not have to use the 'test app' action which is slowing everthing down. It saves the local array to a global comma seperated variable at the end of the task and repopulates it at the begining of the task
> > -Variable set %index TO: %all_names(#?*%package*)
> > -If %index ~ 0
> > - Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
> > - Array Push [ Name:%all_names Position:1 Value:%package|%appname Fill Spaces:Off ]
> >
>
> This is the big difference I found: you use one array with both values in each array-value: package|appname (separated with a | )
> I use two arrays with same indexes, so they are corresponding together.
Ok, got it now..
> I looked into my code, when I disable the gathering of new app names (through the test app action) the time is the same.
> In my code the time consuming is not the Test App but mostly the For Next (now).
How are you confirming this? The run log would confirm it an show if there were any errors and if all is running as expected. Menu / more / run log
>
> Do you think that with the gathering into one array the time could be slowed to 3 seconds?
Not sure, but it would be less complex and have less actions.
You are still using several global variables in the for loop. I changed my suggestion to exclude all global variables within the for loop. This should make a difference.
> Abort Existing Task
>
> -Variable set %all_names TO: %All_names
> -Variable split %all_names
>
> A1: Run Shell [ Command:ps | grep u0_ | awk '{print $9 ","}' Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In: Store Result In: ]
>
> A2: Variable Search Replace [ Variable:%output Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
>
> A3: Variable Split [ Name:%output Splitter:, Delete Base:Off ]
> A4: For [ Variable:%package Items:%output() ]
>
> -Variable set %index TO: %all_names(#?*%package*)
> -If %index ~ 0
> - Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
> - Array Push [ Name:%all_names Position:1 Value:%package|%appname Fill Spaces:Off ]
> -Variable set %index TO: 1
> -End if
> -Variable set %temp TO: %all_names(%index)
> -Variable split %temp Splitter: |
> -variable set %menu_data_apps to %temp(2), append on.
> End If
>
> A7: End For
> -variable set %All_names TO: %all_names(:)
-Variable set %Menu_data_app TO: %menu_data_apps
Instead of pushing to array %Menu_data_apps I appened %temp(2), (note the comma) to a local variable . This makes it a comma separated variable that the menu can use directly.
Now there are no global variables in the for loop.
To get the package name after a menu tap do
-Variable set %all_names TO: %All_names
- variable split %all_names
-Variable set %index TO: %all_names(#?*%tap_label*)
- variable set %temp To: %all_names(%index)
- Variable split %temp splitter |
Your package name is now in %temp1
May need some tweeking, but that is the general idea. I believe removing all global variables from the for loop will make a difference. This also removes the need for any parallel arrays.
I have found it is always better to have a global comma separated variable and split it to a local array any time you need to use it then having a global variable array. The action to set a local variable to a global comma separated variable is far less taxing on tasker then preforming any action on a global array.
> > ...
> I looked into my code, when I disable the gathering of new app names (through the test app action) the time is the same.
> In my code the time consuming is not the Test App but mostly the For Next (now).How are you confirming this? The run log would confirm it an show if there were any errors and if all is running as expected. Menu / more / run log
>
20151021 12.46.34 E Start ID0:0.0 TaskService
20151021 12.50.07 E Stop ID0:0.0 TaskService
20151021 12.50.10 E Start ID0:0.0 TaskService
20151021 12.50.11 T Running ID278 TaskKillNames
20151021 12.50.12 A OK ID278.1 TaskKillNames.Var Clear, %Menu_data=%Menu_data
20151021 12.50.12 A OK ID278.2 TaskKillNames.Var Clear, %Menu_data_start=%Menu_data_start
20151021 12.50.12 A OK ID278.3 TaskKillNames.Run Shell, %output=%output
20151021 12.50.12 A OK ID278.4 TaskKillNames.Var Search Replace, %output=com.android.system..
20151021 12.50.12 A OK ID278.5 TaskKillNames.Var Search Replace, %output=com.android.system..
20151021 12.50.12 A OK ID278.6 TaskKillNames.Var Search Replace, %output=com.android.system..
20151021 12.50.12 A OK ID278.7 TaskKillNames.Var Search Replace, %output=com.android.system..
20151021 12.50.12 A OK ID278.8 TaskKillNames.Var Search Replace, %output=com.android.system..
20151021 12.50.12 A OK ID278.9 TaskKillNames.Var Search Replace, %output=com.android.system..
20151021 12.50.12 A OK ID278.10 TaskKillNames.Var Split, %output=com.android.system..
20151021 12.50.12 A OK ID278.11 TaskKillNames.Array Process, %output=com.android.system..
20151021 12.50.12 A OK ID278.12 TaskKillNames.Array Process, %output=com.android.system..
20151021 12.50.12 A OK ID278.13 TaskKillNames.Array Process, %output=com.android.system..
20151021 12.50.12 A OK ID278.14 TaskKillNames.Var Set, %Count_proc=36
20151021 12.50.12 A OK ID278.15 TaskKillNames.For, %package=android.process.ac..
20151021 12.50.13 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK ID278.17 TaskKillNames.If
20151021 12.50.13 A ErrIgnore ID278.18 TaskKillNames.Test App, %appname=%appname
20151021 12.50.13 A OK ID278.19 TaskKillNames.If
20151021 12.50.13 A OK ID278.25 TaskKillNames.End If
20151021 12.50.13 A OK ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK ID278.15 TaskKillNames.For, %package=android.process.me..
20151021 12.50.13 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK ID278.17 TaskKillNames.If
20151021 12.50.13 A ErrIgnore ID278.18 TaskKillNames.Test App, %appname=%appname
20151021 12.50.13 A OK ID278.19 TaskKillNames.If
20151021 12.50.13 A OK ID278.25 TaskKillNames.End If
20151021 12.50.13 A OK ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK ID278.15 TaskKillNames.For, %package=com.amazing_create..
20151021 12.50.13 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK ID278.17 TaskKillNames.If
20151021 12.50.13 A OK ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK ID278.15 TaskKillNames.For, %package=com.anddoes.launcher
20151021 12.50.13 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK ID278.17 TaskKillNames.If
20151021 12.50.13 A OK ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK ID278.15 TaskKillNames.For, %package=com.android.galler..
20151021 12.50.13 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK ID278.17 TaskKillNames.If
20151021 12.50.13 A OK ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK ID278.15 TaskKillNames.For, %package=com.android.incallui
20151021 12.50.13 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK ID278.17 TaskKillNames.If
20151021 12.50.13 A OK ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK ID278.15 TaskKillNames.For, %package=com.android.inputm..
20151021 12.50.13 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK ID278.17 TaskKillNames.If
20151021 12.50.13 A OK ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK ID278.15 TaskKillNames.For, %package=com.android.provid..
20151021 12.50.13 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK ID278.17 TaskKillNames.If
20151021 12.50.13 A OK ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK ID278.15 TaskKillNames.For, %package=com.android.smspush
20151021 12.50.13 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK ID278.17 TaskKillNames.If
20151021 12.50.13 A OK ID278.26 TaskKillNames.End For
20151021 12.50.13 A OK ID278.15 TaskKillNames.For, %package=com.android.systemui
20151021 12.50.13 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.13 A OK ID278.17 TaskKillNames.If
20151021 12.50.14 A OK ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK ID278.15 TaskKillNames.For, %package=com.android.vending
20151021 12.50.14 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK ID278.17 TaskKillNames.If
20151021 12.50.14 A OK ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK ID278.15 TaskKillNames.For, %package=com.appgenix.bizcal
20151021 12.50.14 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK ID278.17 TaskKillNames.If
20151021 12.50.14 A OK ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK ID278.15 TaskKillNames.For, %package=com.cyanogenmod.tr..
20151021 12.50.14 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK ID278.17 TaskKillNames.If
20151021 12.50.14 A OK ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK ID278.15 TaskKillNames.For, %package=com.fjsoft.myphone..
20151021 12.50.14 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK ID278.17 TaskKillNames.If
20151021 12.50.14 A OK ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK ID278.15 TaskKillNames.For, %package=com.fsck.k9
20151021 12.50.14 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK ID278.17 TaskKillNames.If
20151021 12.50.14 A OK ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK ID278.15 TaskKillNames.For, %package=com.google.android..
20151021 12.50.14 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK ID278.17 TaskKillNames.If
20151021 12.50.14 A OK ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK ID278.15 TaskKillNames.For, %package=com.google.android..
20151021 12.50.14 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK ID278.17 TaskKillNames.If
20151021 12.50.14 A OK ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK ID278.15 TaskKillNames.For, %package=com.google.android..
20151021 12.50.14 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK ID278.17 TaskKillNames.If
20151021 12.50.14 A ErrIgnore ID278.18 TaskKillNames.Test App, %appname=%appname
20151021 12.50.14 A OK ID278.19 TaskKillNames.If
20151021 12.50.14 A OK ID278.25 TaskKillNames.End If
20151021 12.50.14 A OK ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK ID278.15 TaskKillNames.For, %package=com.google.android..
20151021 12.50.14 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK ID278.17 TaskKillNames.If
20151021 12.50.14 A ErrIgnore ID278.18 TaskKillNames.Test App, %appname=%appname
20151021 12.50.14 A OK ID278.19 TaskKillNames.If
20151021 12.50.14 A OK ID278.25 TaskKillNames.End If
20151021 12.50.14 A OK ID278.26 TaskKillNames.End For
20151021 12.50.14 A OK ID278.15 TaskKillNames.For, %package=com.google.process..
20151021 12.50.14 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.14 A OK ID278.17 TaskKillNames.If
20151021 12.50.15 A ErrIgnore ID278.18 TaskKillNames.Test App, %appname=%appname
20151021 12.50.15 A OK ID278.19 TaskKillNames.If
20151021 12.50.15 A OK ID278.25 TaskKillNames.End If
20151021 12.50.15 A OK ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK ID278.15 TaskKillNames.For, %package=com.joaomgcd.autoa..
20151021 12.50.15 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK ID278.17 TaskKillNames.If
20151021 12.50.15 A OK ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK ID278.15 TaskKillNames.For, %package=com.joaomgcd.autor..
20151021 12.50.15 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK ID278.17 TaskKillNames.If
20151021 12.50.15 A OK ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK ID278.15 TaskKillNames.For, %package=com.keramidas.Tita..
20151021 12.50.15 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK ID278.17 TaskKillNames.If
20151021 12.50.15 A OK ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK ID278.15 TaskKillNames.For, %package=com.nuance.swype.dtc
20151021 12.50.15 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK ID278.17 TaskKillNames.If
20151021 12.50.15 A OK ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK ID278.15 TaskKillNames.For, %package=com.schiztech.swapps
20151021 12.50.15 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK ID278.17 TaskKillNames.If
20151021 12.50.15 A OK ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK ID278.15 TaskKillNames.For, %package=com.skvalex.callre..
20151021 12.50.15 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK ID278.17 TaskKillNames.If
20151021 12.50.15 A OK ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK ID278.15 TaskKillNames.For, %package=com.whatsapp
20151021 12.50.15 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK ID278.17 TaskKillNames.If
20151021 12.50.15 A OK ID278.26 TaskKillNames.End For
20151021 12.50.15 A OK ID278.15 TaskKillNames.For, %package=de.robv.android.xp..
20151021 12.50.15 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.15 A OK ID278.17 TaskKillNames.If
20151021 12.50.15 A OK ID278.26 TaskKillNames.End For
20151021 12.50.16 A OK ID278.15 TaskKillNames.For, %package=dev.ukanth.ufirewa..
20151021 12.50.16 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.16 A OK ID278.17 TaskKillNames.If
20151021 12.50.16 A OK ID278.26 TaskKillNames.End For
20151021 12.50.16 A OK ID278.15 TaskKillNames.For, %package=eu.chainfire.supersu
20151021 12.50.16 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.16 A OK ID278.17 TaskKillNames.If
20151021 12.50.16 A OK ID278.26 TaskKillNames.End For
20151021 12.50.16 A OK ID278.15 TaskKillNames.For, %package=mobi.conduction.sw..
20151021 12.50.16 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.16 A OK ID278.17 TaskKillNames.If
20151021 12.50.16 A OK ID278.26 TaskKillNames.End For
20151021 12.50.16 A OK ID278.15 TaskKillNames.For, %package=net.dinglisch.andr..
20151021 12.50.16 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.16 A OK ID278.17 TaskKillNames.If
20151021 12.50.16 A OK ID278.26 TaskKillNames.End For
20151021 12.50.16 A OK ID278.15 TaskKillNames.For, %package=org.cyanogenmod.au..
20151021 12.50.16 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.16 A OK ID278.17 TaskKillNames.If
20151021 12.50.16 A OK ID278.26 TaskKillNames.End For
20151021 12.50.16 A OK ID278.15 TaskKillNames.For, %package=org.cyanogenmod.pr..
20151021 12.50.16 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.16 A OK ID278.17 TaskKillNames.If
20151021 12.50.16 A OK ID278.26 TaskKillNames.End For
20151021 12.50.16 A OK ID278.15 TaskKillNames.For, %package=org.cyanogenmod.th..
20151021 12.50.16 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.17 A OK ID278.17 TaskKillNames.If
20151021 12.50.17 A OK ID278.26 TaskKillNames.End For
20151021 12.50.17 A OK ID278.15 TaskKillNames.For, %package=owncloud.pro
20151021 12.50.17 A OK ID278.16 TaskKillNames.Var Clear, %appname=%appname
20151021 12.50.17 A OK ID278.17 TaskKillNames.If
20151021 12.50.17 A OK ID278.26 TaskKillNames.End For
20151021 12.50.17 A OK ID278.15 TaskKillNames.For, %package=%package
20151021 12.50.17 A OK ID278.27 TaskKillNames.Var Clear, %Menu_data=%Menu_data
20151021 12.50.17 A OK ID278.28 TaskKillNames.Var Clear, %Menu_data_start=%Menu_data_start
20151021 12.50.17 A OK ID278.29 TaskKillNames.Var Set, %Menu_data_start=Google App,Google ..
20151021 12.50.17 A OK ID278.30 TaskKillNames.Var Set, %Menu_data=Google App,Google ..
20151021 12.50.17 A OK ID278.31 TaskKillNames.Show Scene
20151021 12.50.21 A OK ID278.32 TaskKillNames.Destroy Scene
20151021 12.50.21 A OK ID278.33 TaskKillNames.Flash
20151021 12.50.21 A OK ID278.34 TaskKillNames.Var Clear, %Menu_data=%Menu_data
20151021 12.50.21 A OK ID278.35 TaskKillNames.Var Clear, %Menu_data_start=%Menu_data_start
20151021 12.50.21 T ExitOK ID278 TaskKillNames
20151021 12.50.22 E Stop ID0:0.0 TaskService
I have found it is always better to have a global comma separated variable and split it to a local array any time you need to use it then having a global variable array. The action to set a local variable to a global comma separated variable is far less taxing on tasker then preforming any action on a global array.
TaskKillNames (278)
Abort Existing Task
A1: Flash [ Text:TaskKillNames wird gestartet, bitte warten... Long:Off ]
A2: Variable Set [ Name:%apps_package To:%Apps_package Do Maths:Off Append:Off ]
A3: Variable Split [ Name:%apps_package Splitter:, Delete Base:Off ]
A4: Variable Set [ Name:%apps_name To:%Apps_name Do Maths:Off Append:Off ]
A5: Variable Split [ Name:%apps_name Splitter:, Delete Base:Off ]
A6: Variable Clear [ Name:%Menu_data Pattern Matching:Off ]
A7: Variable Clear [ Name:%Menu_data_start Pattern Matching:Off ]
A8: Run Shell [ Command:ps | grep u0_ | awk '{print $9 ","}' Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In: Store Result In: ]
A9: Variable Search Replace [ Variable:%output Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A10: Variable Search Replace [ Variable:%output Search:,su, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With:, ]
A11: Variable Search Replace [ Variable:%output Search:,su, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With:, ]
A12: Variable Search Replace [ Variable:%output Search:,[^,]*/[^,]*, Ignore Case:On Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With:, ]
A13: Variable Search Replace [ Variable:%output Search:,[^,]*:[^,]*, Ignore Case:On Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With:, ]
A14: Variable Search Replace [ Variable:%output Search:,([^,]*):[^,]*, Ignore Case:On Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With:,$1, ]
A15: Variable Split [ Name:%output Splitter:, Delete Base:Off ]
A16: Array Process [ Variable:%output Type:Remove Duplicates ]
A17: Array Process [ Variable:%output Type:Sort Alpha ]
A18: Array Process [ Variable:%output Type:Squash ]
A19: Variable Clear [ Name:%appname Pattern Matching:Off ]
A20: For [ Variable:%package Items:%output() ]
A21: Variable Set [ Name:%index To:%apps_package(#?%package) Do Maths:On Append:Off ]
A22: If [ %index = 0 ]
A23: Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
A24: If [ %appname Set ]
A25: If [ %apps_name(#?%appname) = 0 ]
A26: Array Push [ Name:%apps_package Position:1 Value:%package Fill Spaces:Off ]
A27: Array Push [ Name:%apps_name Position:1 Value:%appname Fill Spaces:Off ]
A28: Variable Set [ Name:%apps To:%appname, Do Maths:Off Append:On ]
A29: End If
A30: End If
A31: Else
A32: Variable Set [ Name:%apps To:%apps_name(%index), Do Maths:Off Append:On ]
A33: End If
A34: End For
A35: Variable Clear [ Name:%Menu_data Pattern Matching:Off ]
A36: Variable Clear [ Name:%Menu_data_start Pattern Matching:Off ]
A37: Variable Set [ Name:%Menu_data To:%apps Do Maths:Off Append:Off ]
A38: Variable Set [ Name:%Menu_data_start To:%apps Do Maths:Off Append:Off ]
A39: Variable Set [ Name:%Apps_package To:%apps_package() Do Maths:Off Append:Off ]
A40: Variable Set [ Name:%Apps_name To:%apps_name() Do Maths:Off Append:Off ]
A41: Variable Split [ Name:%apps Splitter:, Delete Base:Off ]
A42: Variable Set [ Name:%Count_proc To:%apps(#)/%output(#)/%apps_name(#) Do Maths:Off Append:Off ]
A43: Show Scene [ Name:TaskKillNames Display As:Activity, Full Window, No Bar Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:Off Continue Task Immediately:Off ]
A44: Destroy Scene [ Name:TaskKillNames ]
A45: Flash [ Text:TaskKill beendet. Long:Off ]
A46: Variable Clear [ Name:%Menu_data Pattern Matching:Off ]
A47: Variable Clear [ Name:%Menu_data_start Pattern Matching:Off ]
> I have the impression that the slow processing the if action is.
I have doing some testing and may be on to something. Here is my test task that takes 7 sec on my antique.
If I disable every thing in the for loop except action A13
A13: Variable Set [ Name:%index To:%all_names(#?*%package*) Do Maths:Off Append:Off ]
Then it still takes 7 seconds.
If I just put a IF statement in the loop like
IF. %all_names ~ *Package*
To do the test it runs in 2 seconds. So if we use a simple match for the test we would need figure out the proper regex that will retrieve %package|%appname from the comma separated variable %all_names. This could ne done in action / variable search and replace / save matches in.
I am not a regex guy (hopefully you are) and it will take me some time to get this. But this could be the answer.
Get Names 2 (333)
A1: Vibrate [ Time:200 ]
A2: Variable Set [ Name:%all_names To:%All_names Do Maths:Off Append:Off ]
A3: Variable Split [ Name:%all_names Splitter:, Delete Base:Off ]
A4: Run Shell [ Command:ps | grep u0_ | awk '{print $9 ","}' Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In: Store Result In: ]
A5: Variable Search Replace [ Variable:%output Search:,([^,]*):[^,]*, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A6: Variable Search Replace [ Variable:%output Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A7: Variable Search Replace [ Variable:%output Search:,su, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A8: Variable Search Replace [ Variable:%output Search:,[^,]*/[^,]*, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A9: Variable Search Replace [ Variable:%output Search:,[^,]*:[^,]*, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A10: Variable Split [ Name:%output Splitter:, Delete Base:Off ]
A11: Array Process [ Variable:%output Type:Remove Duplicates ]
A12: For [ Variable:%package Items:%output(:) ]
A13: Variable Set [ Name:%index To:%all_names(#?*%package*) Do Maths:Off Append:Off ]
A14: If [ %index ~ 0 ]
A15: Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
A16: Array Push [ Name:%all_names Position:1 Value:%package|%appname Fill Spaces:On ]
A17: Variable Set [ Name:%index To:1 Do Maths:On Append:Off ]
A18: End If
A19: Variable Set [ Name:%temp To:%all_names(%index) Do Maths:Off Append:Off ]
A20: Variable Split [ Name:%temp Splitter:| Delete Base:Off ]
A21: Variable Set [ Name:%menu_data_apps To:%temp2, Do Maths:Off Append:On ]
A22: End For
A23: Vibrate [ Time:200 ]
A24: Array Process [ Variable:%all_names Type:Remove Duplicates ]
A25: Variable Set [ Name:%Menu_data_apps To:%menu_data_apps Do Maths:Off Append:Off ]
A26: Variable Set [ Name:%All_names To:%all_names(:) Do Maths:Off Append:Off ]
> ...
I am not a regex guy (hopefully you are) and it will take me some time to get this. But this could be the answer.
> So just this would be something like:
> ([^|]*%package[^|]*)\|([^|]*%appname[^|]*),
Yup, that it going, Thanks...
>
Here is the latest. It seems to be working without error and only takes 3 sec on my device. I have included my entire project on this issue.
Get Names 2 (333)
A1: Vibrate [ Time:200 ]
A2: Variable Set [ Name:%all_names To:%All_names Do Maths:Off Append:Off ] If [ %All_names !~ \%All_names ]
A3: Run Shell [ Command:ps | grep u0_ | awk '{print $9 ","}' Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In: Store Result In: ]
A4: Variable Search Replace [ Variable:%output Search:,([^,]*):[^,]*, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A5: Variable Search Replace [ Variable:%output Search:\s Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A6: Variable Search Replace [ Variable:%output Search:,su, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A7: Variable Search Replace [ Variable:%output Search:,[^,]*/[^,]*, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A8: Variable Search Replace [ Variable:%output Search:,[^,]*:[^,]*, Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A9: Variable Split [ Name:%output Splitter:, Delete Base:Off ]
A10: Array Process [ Variable:%output Type:Remove Duplicates ]
A11: For [ Variable:%package Items:%output(:) ]
A12: Variable Add [ Name:%count Value:1 Wrap Around:0 ]
A13: If [ %all_names !~ *%package* ]
A14: Test App [ Type:Package Name Data:%package Store Result In:%appname Continue Task After Error:On ]
A15: Goto [ Type:Top of Loop Number:1 Label: ] If [ %appname ~ \%appname ]
A16: Variable Set [ Name:%all_names To:,%package|%appname Do Maths:Off Append:On ]
A17: End If
A18: Variable Search Replace [ Variable:%all_names Search:([^|]*%package[^|]*)\|([^|]*,) Ignore Case:On Multi-Line:On One Match Only:On Store Matches In:%temp Replace Matches:Off Replace With: ]
A19: Variable Search Replace [ Variable:%temp1 Search:([^|]*%package[^|]*)\| Ignore Case:On Multi-Line:On One Match Only:On Store Matches In: Replace Matches:On Replace With: ] If [ %temp1 Set ]
A20: Variable Set [ Name:%menu_data_apps To:,%temp1 Do Maths:Off Append:On ]
A21: End For
A22: Vibrate [ Time:200 ]
A23: Flash [ Text:%count Long:On ]
A24: Variable Set [ Name:%Menu_data_apps To:%menu_data_apps Do Maths:Off Append:Off ]
A25: Variable Set [ Name:%All_names To:%all_names Do Maths:Off Append:Off ]
A26: Perform Task [ Name:Run Test Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ]