You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-19Lines changed: 32 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
##
5
5
6
6
7
-
### Contents:
7
+
### Contents
8
8
-[Project Details](#Project-Details)
9
9
-[How Project Works](#How-Project-Works)
10
10
-[Activity States And Transitions](#Activity-States-And-Transitions)
@@ -16,12 +16,14 @@
16
16
-[Current Features](#Current-Features)
17
17
-[Planned Features](#Planned-Features)
18
18
-[Issues](#Issues)
19
-
-[Worthy of Note](#Worthy-of-Note)
19
+
-[Worthy Of Note](#Worthy-Of-Note)
20
+
-[FAQs And FUQs](#FAQs-And-FUQs)
20
21
-[Changelog](#Changelog)
22
+
-[Contributions](#Contributions)
21
23
##
22
24
23
25
24
-
### Project Details:
26
+
### Project Details
25
27
26
28
Each android app has a package name which is a unique name that allows android to differentiate between different apps even if they have the same name. For example, the package name for Tasker is `net.dinglisch.android.taskerm`. Each app can contain different activities inside it which are basically views or screens. For example Tasker has the homescreen activity, the settings activity, task edit activity and so on.
27
29
Activities can be of the following types:
@@ -55,7 +57,7 @@ The `ActivityManager: Displayed` will not be logged for activities which are ret
55
57
The `ActivityTrigger: ActivityTrigger activityPauseTrigger` can be used to reliable detect all activity transitions but since the entry itself does not contain the package and activity name, other ways need to be used to detect what activity is currently in focus. But this creates lots of problems because if the `Logcat Entry` Profile entry task takes too long to process an entry, then by the time the turn comes for queued tasks, the package and/or activity might have already changed for which those Logcat entries were generated for, resulting in false activity transitions being calculated.
56
58
57
59
Currently two ways are used to detect which activity is currently in focus:
58
-
- For non-root users the `GetCurrentAppAndActivity` function of the `Tasker Function` action is used, but the value returned by it is sometimes that of a previous activity since Tasker does not receive/calculate the new value fast enough and a wait action is required of `0.5-1s` before running it. The exact time of the `Wait` action at runtime will vary depending on other same priority tasks running in tasker or the device load itself and may even vary for different devices, and so activity transitions may not always be accurate.
60
+
- For non-root users the `GetCurrentAppAndActivity` function of the `Tasker Function` action is used, but the value returned by it is sometimes that of a previous activity since Tasker does not receive/calculate the new value fast enough and a wait action is required of `0.5-1s` before running it. The exact time of the `Wait` action at runtime will vary depending on other same priority tasks running in tasker or the device load itself and may even vary for different devices, and so activity transitions may not always be accurate. The `Tasker Settings` -> `Monitor` -> `App Check Method` if set to `App Usage Stats` may give better results than `Accessibility`.
59
61
- For root users, the `mFocusedActivity` value is extracted from the `dumpsys activity activities` command. This ideally should work for almost every device if not all. This is relatively more reliable for getting the current package and activity value accurately since its updated fast enough and a `Wait` action is not required. The full command to extract `GetCurrentAppAndActivity` value is `dumpsys activity activities | grep mFocusedActivity | sed -E 's/.*ActivityRecord\{[^ ]+ [^ ]+ ([^ ]+) [^ ]+\}.*/\1/'`.
60
62
61
63
But with both these methods false activity transitions will still occur in cases when the entry task is slow or queued because of higher priority tasks running in tasker and packages and/or activities have already changed. It is best to find device specific Logcat entries for all activity resumes which also contain the package and activity name in the format `package_name/activity_name`. These should normally exist in all devices but will vary depending on device manufacturer and android version. Check the [Finding Device Specific Logcat Entries](###Finding-Device-Specific-Logcat-Entries) section for more info on how to find them.
@@ -73,7 +75,7 @@ The details for fullscreen and immersive modes can be found [here](https://devel
73
75
74
76
Once it is found if the activity is fullscreen or not, then the current activity state is calculated. After this, if the current or previous activity's package name responder tasks are found in the tasker config, then activity transitions are calculated from previous and current activity states and passed to the respective tasks.
75
77
76
-
### How Project Works:
78
+
### How Project Works
77
79
78
80
79
81
**Logcat Entry Profiles**:
@@ -154,26 +156,26 @@ If previous_activity!=current_activity:
154
156
##
155
157
156
158
157
-
### Dependencies:
159
+
### Dependencies
158
160
159
-
- 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.
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.
160
162
##
161
163
162
164
163
-
### Downloads:
165
+
### Downloads
164
166
165
167
Download `Activity State Changes Tasker Project` latest release from [here](https://github.com/Taskomater/Activity-State-Changes-Tasker-Project/releases).
166
168
##
167
169
168
170
169
-
### Install Instructions For Tasker In Android:
171
+
### Install Instructions For Tasker In Android
170
172
171
-
1. Import `Activity_State_Changes.prj.xml` Project file into Tasker.
173
+
1. Import `projects/Activity_State_Changes.prj.xml` Project file into Tasker.
172
174
173
175
##
174
176
175
177
176
-
### Usage:
178
+
### Usage
177
179
178
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.
- Detect if activities enter or leave fullscreen mode
216
218
- Sample tasks for handling activity transitions of some apps
217
219
##
218
220
219
221
220
-
### Planned Features:
222
+
### Planned Features
221
223
222
-
-Not thought of yet.
224
+
-Optimizations to reduce tasks execution times.
223
225
##
224
226
225
227
226
-
### Issues:
228
+
### Issues
227
229
228
230
- Some `package_name/activity_name` might be considered invalid. Currently the hyphen `-` character in activities is considered invalid by the `\p{javaJavaIdentifierPart}` character class of the validation regex for some unknown reason on the devs device. The regex may be changed in future.
229
231
230
232
##
231
233
232
234
233
-
### Worthy of Note:
235
+
### Worthy Of Note
234
236
235
237
- The activity name of activities defined in the `AndroidManifest.xml` of apps may start with a dot, which implies that the package name should automatically be prepended to their name. Depending on the method used to detect the current package and activity, the activity name may not be prepended with the package name and may start with a dot instead. So it is best to use `~` matches instead of `eq` conditional statements in the `project_name Activity State Change Responder` Tasks.
236
238
237
239
- 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.
238
240
239
-
- 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.
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.
240
242
##
241
243
242
244
243
-
### Changelog:
245
+
### FAQs And FUQs
244
246
245
-
Check [CHANGELOG.md](CHANGELOG.md) file for the changelog.
247
+
Check [FAQs_And_FUQs.md](FAQs_And_FUQs.md) file for the **Frequently Asked Questions(FAQs)** and **Frequently Unasked Questions(FUQs)**.
248
+
##
249
+
250
+
### Changelog
251
+
252
+
Check [CHANGELOG.md](CHANGELOG.md) file for the **Changelog**.
0 commit comments