Skip to content

Commit 18bde08

Browse files
Updated README.md
1 parent 7bf246e commit 18bde08

File tree

4 files changed

+46
-15
lines changed

4 files changed

+46
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ All notable changes to this project will be documented in this file.
2020
`-`
2121

2222

23-
## [0.2.0] - 2020-01-12
23+
## [0.2.0] - 2020-01-13
2424

2525
### Added
2626
- Added `Display State` State is `On` to `*Activity Start Monitor` and `*Config Change Monitor` Profiles to save battery when display is off.

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Activity State Changes Tasker Project
22

3-
`Activity State Changes Tasker Project` for android provides a way to detect android app activity state changes like activity changes in the same app or between different ones or if an activity enters or exits the fullscreen mode. This majorly relies on logcat entries detected using the Tasker `Logcat Entry` Profile and requires Tasker to be granted `android.permission.READ_LOGS`.
3+
`Activity State Changes Tasker Project` for android provides a way to detect android app activity state changes like activity changes in the same app or between different ones or if an activity enters or exits the fullscreen mode using the [Tasker App]. This majorly relies on logcat entries detected using the Tasker `Logcat Entry` Profile and requires Tasker to be granted `android.permission.READ_LOGS`.
44
##
55

66

77
### Contents
88
- [Project Details](#Project-Details)
99
- [How Project Works](#How-Project-Works)
1010
- [Activity States And Transitions](#Activity-States-And-Transitions)
11+
- [Compatibility](#Compatibility)
1112
- [Dependencies](#Dependencies)
1213
- [Downloads](#Downloads)
1314
- [Install Instructions For Tasker In Android](#Install-Instructions-For-Tasker-In-Android)
@@ -156,15 +157,21 @@ If previous_activity!=current_activity:
156157
##
157158

158159

160+
### Compatibility
161+
162+
- Android using [Tasker App].
163+
##
164+
165+
159166
### Dependencies
160167

161-
- No specific dependencies other than requires Tasker to be granted `android.permission.READ_LOGS`. Either grant it over adb manually using `pm grant net.dinglisch.android.taskerm android.permission.READ_LOGS` command or use the script in [tasker_package_utils](https://github.com/Taskomater/tasker_package_utils) project which has a few more features.
168+
- No specific dependencies other than requires Tasker to be granted `android.permission.READ_LOGS`. Either grant it over adb manually using `pm grant net.dinglisch.android.taskerm android.permission.READ_LOGS` command or use the script in [tasker_package_utils](https://github.com/Taskomater/tasker_package_utils) project which has a few more features. Root users are automatically granted permissions by Tasker if required.
162169
##
163170

164171

165172
### Downloads
166173

167-
Download `Activity State Changes Tasker Project` latest release from [here](https://github.com/Taskomater/Activity-State-Changes-Tasker-Project/releases).
174+
- [GitHub releases](https://github.com/Taskomater/Activity-State-Changes-Tasker-Project/releases).
168175
##
169176

170177

@@ -177,17 +184,17 @@ Download `Activity State Changes Tasker Project` latest release from [here](http
177184

178185
### Usage
179186

180-
1. Enable the `ActivityTrigger Activity Start Monitor`, `ActivityManager Activity Config Change Monitor`, `Activity State Change Controller Command Monitor` and `Reset Activity State Change Variables On Monitor Start` Profiles if not already action. You may optionally enable the `Custom Activity Start Monitor` Profile instead of the `ActivityTrigger Activity Start Monitor` Profile if you found Activity resume logcat entries for your device. Do not enable both profiles together.
187+
1. Enable the `ActivityTrigger Activity Start Monitor`, `ActivityManager Activity Config Change Monitor`, `Activity State Change Controller Command Monitor` and `Reset Activity State Change Variables On Monitor Start` Profiles if not already enabled. You may optionally enable the `Custom Activity Start Monitor` Profile instead of the `ActivityTrigger Activity Start Monitor` Profile if you found Activity resume logcat entries for your device. Do not enable both profiles together.
181188

182189
2. Optionally enable the use of non-root modes if you are a root user by disabling the `%use_root_mode` Variable Set action in the `Activity State Change Relay` and `Activity State Change Controller` Tasks or change their values from `1`.
183190

184191
3. Enable the `%lc_text` Flash action of the `Activity State Change Relay` Task, the `%enable_debugging` Variable Set action of the `Activity State Change Controller` Task and optionally the `%action\n%%activity_transition` action of the `project_name Activity State Change Responder` Tasks. This should normally give you enough info on what is being run. The Flash actions will of course not be synchronized with what is being run.
185192

186-
4. Change the `Wait` action time in the `Activity State Change Relay` Task for the `ActivityTrigger Activity Start Monitor` Profile conditional statement if you are using non-root mode.
193+
4. Change the `Wait` action time in the `Activity State Change Relay` Task for the `ActivityTrigger Activity Start Monitor` Profile conditional statement if you are using non-root mode. Also use the `App Usage Stats` mode for `Tasker Settings` -> `Monitor` -> `App Check Method` for possibly better results.
187194

188195
5. If the fullscreen mode is not always being detected correctly, try to change the `Wait` action time in the `Wait For User To Hide Status Bar By Tapping Screen*` section of the `Activity State Change Controller` Task. Do not forget to tap the screen once to hide the status bar as soon as you enter a fullscreen activity for which you want to detect fullscreen mode. You may optionally not tap it to prevent the respective `project_name Activity State Change Responder` Task from running the fullscreen actions you defined.
189196

190-
6. Create `project_name Activity State Change Responder` Tasks for each app you want to handle activity transitions for. The tasks may respond appropriately to activity transitions but must not perform long running operations since `Activity State Change Controller` Task will not finish until the called tasks are finished to maintain order and any queued tasks for it task will also be in waiting. Any long running operations that do not require ordered execution can be run inside the called tasks in additional tasks with `%priority - 1` so that the called tasks can return before the additional tasks finish.
197+
6. Create `project_name Activity State Change Responder` Tasks for each app you want to handle activity transitions for. The tasks may respond appropriately to activity transitions but must not perform long running operations since `Activity State Change Controller` Task will not finish until the called tasks are finished to maintain order and any queued tasks for it will also be in waiting. Any long running operations that do not require ordered execution can be run inside the called tasks in additional tasks with `%priority - 1` so that the called tasks can return before the additional tasks finish.
191198

192199
7. If the default `ActivityTrigger Activity Start Monitor` Profile with the `ActivityTrigger activityPauseTrigger` filter is never triggered, then find matching entries for `ActivityTrigger activityResumeTrigger` or other related pause/resume activity entries for your device in the logcat and update the profile. You may optionally find activity resume entries in your logcat that also contain the package and activity name and update the `Custom Activity Start Monitor` Profile with them. In this case you also need to update the `Variable Search Replace` action in the `Custom Activity Start Monitor` Profile conditional actions in the `Activity State Change Relay` Task to extract the package name and activity name from the logcat entries and set them to `%current_package_and_activity` in the format `package_name/activity_name`.
193200

@@ -204,7 +211,7 @@ There are a few ways to find device specific logcat entries for various things.
204211
- If you have root access, then run `logcat | grep -E 'activity|trigger|resume|start|stop|config change|systemuivisibility|statusbar'` in a root shell in termux and then switch to multi-window and then switch between activities to see logcat changes in real time. You can pass any string in a regex to `grep` to filter entries you want to monitor.
205212
- If you do not have root access, you may run the logcat command above over adb. If you are using windows, then `grep` command will not be available, install `cygwin` if required.
206213

207-
To find activity resume entries, adding part of the package or activity name to the filter regex can be helful to narrow down important logcat entries. For LG G5 7.0, the activity resuming entries match the following format:
214+
To find activity resume entries, adding part of the package or activity name to the filter regex can be helpful to narrow down important logcat entries. For LG G5 7.0, the activity resuming entries match the following format:
208215
```
209216
LGImageQualityEnhancementService: activityResuming: package_name/activity_name
210217
```
@@ -238,7 +245,7 @@ LGImageQualityEnhancementService: activityResuming: package_name/activity_name
238245

239246
- You may increase the priority of `Logcat Entry` Profiles to a number higher than the default `5` to make them run as soon as they are trigerred to store the value of the current package and activity if other lower priority tasks are running in Tasker. But note that using `Wait` actions will prevent other tasks from executing until the profile entry tasks are complete and may create sluggish behaviour.
240247

241-
- The dumpsys commands are by default run in `Run Shell` actions with the root toggle enabled. Opening a root shell takes a tiny bit longer than normal non-root shells. If Tasker is installed as a system privileged app and is granted `android.permission.DUMP`, then root shell is not required and the root toggle may be disabled to slightly increase performance. You may use the script in [Tasker Package Utils](https://github.com/Taskomater/tasker_package_utils) project to automatically install tasker as a system privileged app.
248+
- The dumpsys commands are by default run in `Run Shell` actions with the root toggle enabled. Opening a root shell takes a tiny bit longer than normal non-root shells. If Tasker is installed as a system privileged app and is granted `android.permission.DUMP`, then root shell is not required and the root toggle may be disabled to slightly increase performance. You may use the script in [Tasker Package Utils](https://github.com/Taskomater/tasker_package_utils) project to automatically install Tasker as a system privileged app.
242249
##
243250

244251

@@ -259,3 +266,5 @@ Check [CHANGELOG.md](CHANGELOG.md) file for the **Changelog**.
259266
`-`
260267
##
261268

269+
270+
[Tasker App]: https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm

projects/Activity_State_Changes.prj.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Export Info:
44
**Tasker Version:** `5.9.1`
5-
**Timestamp:** `2020-01-12 05.23.07`
5+
**Timestamp:** `2020-01-13 05.28.11`
66

77

88

@@ -110,7 +110,18 @@ This task does not take any parameters or return anything.
110110
```
111111
A task is called by the "Activity State Change Controller Command Monitor" Profile when the %ActivityStateChangeControllerCommand variable is set.
112112
113-
This task first checks if the current_package_and_activity passed is a valid package and activity name in the format "package_name/activity_name". If it is then it checks if the current activity is in fullscreen mode with status bars hidden either by using the dumpsys command's "mTopIsFullscreen" value if root mode is enabled or from the last "*StatusBar: setSystemUiVisibility" logcat entry's "newVal" bit flags. Then it sets the current_activity_state depending on activity_state_change and fullscreen mode. Then it checks if the a "package_name Activity State Change Responder" Task exists in the Tasker config for the current_package_and_activity or previous_package_and_activity. If either of those exists, then it calculates the previous_activity_task_activity_transition_par and current_activity_task_activity_transition_par depending on activity transitions in the transitions table. Then it calls the "previous_package Activity State Change Responder" Task if it exists with the previous_activity as %par1 and previous_activity_task_activity_transition_par as %par2. Then it calls the "current_package Activity State Change Responder" Task if it exists with the current_activity as %par1 and current_activity_task_activity_transition_par as %par2. Those tasks may respond appropriately to activity transitions but must not perform long running operations since this task will not finish until the called tasks are finished to maintain order and any queued tasks for this task will also be in waiting. Any long running operations that do not require ordered execution can be run inside the called tasks in additional tasks with "%priority - 1" so that the called tasks can return before the additional tasks finish.
113+
This task first checks if the current_package_and_activity passed is a valid package and activity name in the format "package_name/activity_name".
114+
115+
Then it checks if the current activity is in fullscreen mode with status bars hidden either by using the dumpsys command's "mTopIsFullscreen" value if root mode is enabled or from the last "*StatusBar: setSystemUiVisibility" logcat entry's "newVal" bit flags. If no entries are found in the logcat for "setSystemUiVisibility", then it is automatically assumed that activity is in non fullscreeen mode.
116+
Then it sets the current_activity_state depending on activity_state_change and fullscreen mode.
117+
118+
Then it checks if the a "package_name Activity State Change Responder" Task exists in the Tasker config for the current_package_and_activity or previous_package_and_activity. If either of those exists, then it calculates the previous_activity_task_activity_transition_par and current_activity_task_activity_transition_par depending on activity transitions in the transitions table.
119+
120+
Then it calls the "previous_package Activity State Change Responder" Task if it exists with the previous_activity as %par1 and previous_activity_task_activity_transition_par as %par2.
121+
122+
Then it calls the "current_package Activity State Change Responder" Task if it exists with the current_activity as %par1 and current_activity_task_activity_transition_par as %par2.
123+
124+
"*Responder" tasks may respond appropriately to activity transitions but must not perform long running operations since this task will not finish until the called tasks are finished to maintain order and any queued tasks for this task will also be in waiting. Any long running operations that do not require ordered execution can be run inside the called tasks in additional tasks with "%priority - 1" so that the called tasks can return before the additional tasks finish.
114125
115126
Check Activity State Changes Project docs to get more info on how this task is called and what it does.
116127

projects/Activity_State_Changes.prj.xml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The text that corresponds to the matched logcat entry</_array_net.dinglisch.a
4242
<Profile sr="prof855" ve="2">
4343
<cdate>1578295763395</cdate>
4444
<clp>true</clp>
45-
<edate>1578787826285</edate>
45+
<edate>1578875237200</edate>
4646
<flags>8</flags>
4747
<id>855</id>
4848
<mid0>839</mid0>
@@ -85,7 +85,7 @@ The text that corresponds to the matched logcat entry&lt;/_array_net.dinglisch.a
8585
<Profile sr="prof863" ve="2">
8686
<cdate>1578401192742</cdate>
8787
<clp>true</clp>
88-
<edate>1578787826880</edate>
88+
<edate>1578875237904</edate>
8989
<flags>8</flags>
9090
<id>863</id>
9191
<limit>true</limit>
@@ -1044,7 +1044,7 @@ This task does not return anything.</label>
10441044
</Task>
10451045
<Task sr="task858">
10461046
<cdate>1576882993943</cdate>
1047-
<edate>1578526650699</edate>
1047+
<edate>1578853830354</edate>
10481048
<id>858</id>
10491049
<nme>Activity State Change Controller</nme>
10501050
<pri>6</pri>
@@ -1053,7 +1053,18 @@ This task does not return anything.</label>
10531053
<code>300</code>
10541054
<label>A task is called by the "Activity State Change Controller Command Monitor" Profile when the %ActivityStateChangeControllerCommand variable is set.
10551055

1056-
This task first checks if the current_package_and_activity passed is a valid package and activity name in the format "package_name/activity_name". If it is then it checks if the current activity is in fullscreen mode with status bars hidden either by using the dumpsys command's "mTopIsFullscreen" value if root mode is enabled or from the last "*StatusBar: setSystemUiVisibility" logcat entry's "newVal" bit flags. Then it sets the current_activity_state depending on activity_state_change and fullscreen mode. Then it checks if the a "package_name Activity State Change Responder" Task exists in the Tasker config for the current_package_and_activity or previous_package_and_activity. If either of those exists, then it calculates the previous_activity_task_activity_transition_par and current_activity_task_activity_transition_par depending on activity transitions in the transitions table. Then it calls the "previous_package Activity State Change Responder" Task if it exists with the previous_activity as %par1 and previous_activity_task_activity_transition_par as %par2. Then it calls the "current_package Activity State Change Responder" Task if it exists with the current_activity as %par1 and current_activity_task_activity_transition_par as %par2. Those tasks may respond appropriately to activity transitions but must not perform long running operations since this task will not finish until the called tasks are finished to maintain order and any queued tasks for this task will also be in waiting. Any long running operations that do not require ordered execution can be run inside the called tasks in additional tasks with "%priority - 1" so that the called tasks can return before the additional tasks finish.
1056+
This task first checks if the current_package_and_activity passed is a valid package and activity name in the format "package_name/activity_name".
1057+
1058+
Then it checks if the current activity is in fullscreen mode with status bars hidden either by using the dumpsys command's "mTopIsFullscreen" value if root mode is enabled or from the last "*StatusBar: setSystemUiVisibility" logcat entry's "newVal" bit flags. If no entries are found in the logcat for "setSystemUiVisibility", then it is automatically assumed that activity is in non fullscreeen mode.
1059+
Then it sets the current_activity_state depending on activity_state_change and fullscreen mode.
1060+
1061+
Then it checks if the a "package_name Activity State Change Responder" Task exists in the Tasker config for the current_package_and_activity or previous_package_and_activity. If either of those exists, then it calculates the previous_activity_task_activity_transition_par and current_activity_task_activity_transition_par depending on activity transitions in the transitions table.
1062+
1063+
Then it calls the "previous_package Activity State Change Responder" Task if it exists with the previous_activity as %par1 and previous_activity_task_activity_transition_par as %par2.
1064+
1065+
Then it calls the "current_package Activity State Change Responder" Task if it exists with the current_activity as %par1 and current_activity_task_activity_transition_par as %par2.
1066+
1067+
"*Responder" tasks may respond appropriately to activity transitions but must not perform long running operations since this task will not finish until the called tasks are finished to maintain order and any queued tasks for this task will also be in waiting. Any long running operations that do not require ordered execution can be run inside the called tasks in additional tasks with "%priority - 1" so that the called tasks can return before the additional tasks finish.
10571068

10581069
Check Activity State Changes Project docs to get more info on how this task is called and what it does.
10591070

0 commit comments

Comments
 (0)