Use front flash instead of led notification

Post your questions and help other users.

Moderator: Martin

wfrcrd
Posts: 116
Joined: 27 May 2015 08:57

Use front flash instead of led notification

Post by wfrcrd » 20 Jan 2019 17:33

I'm trying to build a flow to blink repeatly the front camera flash using the script mentioned in this post from Desmanto (thank you!)

http://automagic4android.com/forum/view ... 287#p11664

but I'm a bit worried about the battery drain:
the only action that I know to pause the flow between one blink and another one is "sleep".
There is some less expensive action to use to perform it?
Thank you !

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Use front flash instead of led notification

Post by Desmanto » 20 Jan 2019 18:33

It seems sleep() is the only way to make it blink. Maybe you can make it blink faster at first and then reduce the blink speed after 10 blinks, by making the sleep much longer.
I hope we can have the blink option directly built-in into the flashlight action, including option to choose the front/back flash.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

wfrcrd
Posts: 116
Joined: 27 May 2015 08:57

Re: Use front flash instead of led notification

Post by wfrcrd » 20 Jan 2019 18:49

I've started with long time between the blinks beacuse the flashlight it's strong and a bit bothering.

I'm not worried about the battery drain when the flash is on, but I'm worried when it's off and the flows
continues.

I should find some way to "pause" the blinking flow triggering the proximity sensor ,
and restart the blink flow when there's nothing near the phone.

wfrcrd
Posts: 116
Joined: 27 May 2015 08:57

Re: Use front flash instead of led notification

Post by wfrcrd » 21 Jan 2019 12:36

So I've made a set of flows to use the front flashlight as a led indicator.
I've tried to stop the blink when something cover the phone using the proximity sensor
and restart it automatically when it's not covered anymore.

It seems working with no huge battery drain but when the phone is covered
for long time and then the cover has been taken off again the blink don't start anymore.

It seems that the proximity sensor is stopped, maybe due to a "deep sleep" or something like that.
I will try to manage it setting a periodic time to keep the proximity sensor awaken,
but it's a uncougth solution, I will let you know.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Use front flash instead of led notification

Post by Desmanto » 21 Jan 2019 17:23

What is the actual usage of the flow? Do you use it to replace the notification LED? Or you simply let it blink just like a beacon to locate your phone?
Without knowing the main purpose, sometimes we can't determine which is the best solution.

If you use it for notification, I would think about a short burst blink at beginning and slowly become less frequent until it takes to long for a single blink. When any notif arrived, the blink return to the more frequent speed; and slowly become less frequent again after some time.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

wfrcrd
Posts: 116
Joined: 27 May 2015 08:57

Re: Use front flash instead of led notification

Post by wfrcrd » 21 Jan 2019 19:00

thank you for the answer Desmanto,
the main pourpose is to sobsitute the led notification wich is weak on my phone.

Yes, the blink pattern do someting similar to waht you said, more frequently at the beginning.
But I have another problem: I've combined the blink with the proximity sensor to avoid the blink
when the phone is in the pocket.
And it works just if the phone stays covered for less than one hour (approx) ,
if it is covered for longer time, when it's discovered the blink don't start again.
I think the proximity sensor go to sleep after a while and don't recognize anymore
the change (covered/unceovered) status of the phone, which should start the blink pattern.
I'm working on it ...

(edit)
maybe this action may solve :Exit Device Idle/Doze Mode
but my phone is not rooted yet , so I must wait

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Use front flash instead of led notification

Post by Desmanto » 22 Jan 2019 18:14

That is probably the best way to achieve it already. For proximity sensor sleep, have you exclude automagic from all battery optimization? Some ROM have the sensor timer block, you have to disable this too. Actually the sensor consume so small battery life that blocking it is not worth it. (but at some phone it may have significant difference).
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

wfrcrd
Posts: 116
Joined: 27 May 2015 08:57

Re: Use front flash instead of led notification

Post by wfrcrd » 25 Feb 2019 16:31

I'm keep trying, before the "deep sleep" problem I've found another one (now the phone is rooted) :
the blinking should stop when "ui present" it's triggered but I've noticed that it stops just when the screen turns on.
The log says that another CAM user is present and cannot perform the torch action (the flash blinkin).
I was asking myself who is this another cam user and finally I think it's the face recognition which starts
when the screen turns on.
Do you know how to avoid this issue, keeping the face recognition on?
Thanks!

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Use front flash instead of led notification

Post by Desmanto » 25 Feb 2019 17:08

There is no way to steal the camera usage from the face recognition function. So the only way to avoid the issue is to pause the flow when the face recognition is active. Probaly the combination of display state on until the user present is triggered. Or you can design your blinking action, add exception connection to it with sleep 10 seconds and loop back to the same action. This means if the blinking part is stopped by any error (face recognition forcefully take the camera access), it will sleep for 10 seconds before trying it again.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

wfrcrd
Posts: 116
Joined: 27 May 2015 08:57

Re: Use front flash instead of led notification

Post by wfrcrd » 26 Feb 2019 14:45

Thank you Desmanto,
I've tried to "disable pm" camera during the blink process but the system re-anable it by itself.

So I prefer to pause the flow instaed of change the blink flow, wich is more complicated to me.
How can I pause and resume the flow?

Thank you!

Post Reply