Falcosc / locus-addon-tasker

Locus Maps API useable as Tasker Plugin
GNU General Public License v3.0
9 stars 2 forks source link

Problem with Locus_Screenlock_on_Display_Off #8

Closed jarstr closed 5 years ago

jarstr commented 5 years ago

Very usefull feature! Now I switch it on every time I use Locus while walking (with phone in my pocket, not mounted on bicycle handlebar).

(To be honest I think it should be just part of Locus itself, with button to activate/deactivate in "Quick settings" panel - every person who eg. lost his track recording because of random clicks in Locus made in his pocket after unlocking screen because eg. receiving sms, should find this feature extremelly usefull.)

But I've observed, that sometimes this feature does not work :-( Especially in airplane mode (offline). In airplane mode, in most cases lock is not activated, sometimes activates after few seconds delay.

Tested on Android 8.0.0, Samsung S7.

Falcosc commented 5 years ago

For that reason this is not part of Locus maps because actions executed after display off are a bit unstable and chance of failing is specific to android device and version. And it will get worse with each new Android version because power saving gets more aggressive.

In summary, this feature does sometimes not work because android is skipping this intent due to power saving concerns. This action has to be done as fast as possible before device sleep does kick in. Based on check interval and other variables this action is sometimes executed too late.

I can put a warning into example description. How often does it not work with Android 8? And do you have other android versions with same issue?

jarstr commented 5 years ago

How often? I've just checked it again (switched phone into airline mode) and problem appears immediately.

I've checked it only on my phone (Tasker is a paid app).

Falcosc commented 5 years ago

Interesting, maybe the power saving is more aggressive if it is in airplane mode. Sometimes Android does restore the stopped action, in this case it will happen with some delay. But in most cases it will abort the old actions to save even more power.

You can't change this behavior and it is very difficult to find out which part of the process is failing. Is Tasker getting screen changes too late? Is locus unable to listen to intents because of android power saving features or are both the problem. Sometimes Tasker and sometimes Locus.

You could create more work around like checking display state in a loop and if you detect display off you store this information and wait for display on event. If you detect a screen on state you can fire screen lock intents because no power savings are enabled if screen is online.

The example is unreliable because on some devices you can't listen to display off events or you can't fire intents to applications if display is off or applications are not allowed to receive intents if display is off.