ssaqua / ProximityService

Android service for turning off the display using the proximity sensor
Apache License 2.0
35 stars 11 forks source link

stops working properly sometimes #3

Open fuloating opened 6 years ago

fuloating commented 6 years ago

For some reason this app is not working as intended sometimes, like for example now for the past 4 days or so.

The symptoms 1: I start the service as usual and all seems right, but when I move my finger over the sensor area, the screen stays on as if the service is not running.

The installed app section shows 0kb for cache and data, so I can't clear those. I tried uninstaling and reinstalling app, and rebooting my Xiaomi Redmi Note 3+ running android 5.1.1 and MIUI version 8.0.6.0. but is not helping.

The symptoms 2: Before symptoms 1 problem started to occur 4 days ago, the sensor worked normally until the following happened when I started the service: I moved my finger on top of the sensor, the screen went dark, but when I removed my finger from it, it would stay dark. Pressing the "lock screen" button on side of the phone multiple times finally awakes the screen eventually. This thing repeated multiple times until I had to stop the service. Next time I started the service the "symptoms 1" behaviour started to happen.

This cycle has happened earlier too, maybe twice, and I don't know what had made it work again. Maybe after I have installed updates from play store, or some system upgrade has happened it has started to work again. However now it is once again not working, and without knowing how to fix it, I might have to be without this app once again for weeks or even a month, until it suddenly start to work again...

ssaqua commented 6 years ago

This is difficult for me to diagnose since I can't reproduce the issue and don't have access to multiple kinds of devices for testing. Do you experience the same issues when interacting with the proximity sensor during phone calls?

JakubJagoda commented 6 years ago

I started seeing what OP here described as "symptom 1" after the most recent update (2.0.1). After running Proximity Service and using it for a couple of minutes (and starting new apps in the meantime), Proximity Service stops working - the notification says it's running, but putting a finger over the sensor does nothing and the only solution was to run it again (not by restarting from the notification, but explicitely from the main screen). It happens on exact same phone and OS as OP described.

But I think I found a solution for this, at least I haven't seen this behavior since I applied the fix. I assumed this is caused by the MIUI's optimalization strategy against background apps activity, which is turned on by default for all apps. Here's what I did:

And voila, this will "lock" your app and automatically set it to unlimited activity in the background. Since I did this, I haven't seen the "symptom 1". Try it, it might help.

Best regards

ssaqua commented 6 years ago

Thanks for the workaround info!

The service runs as a foreground service to reduce the possibility of the system killing the service. I may need to revisit this idea and instead make it more compatible with being restarted by the system.

ssaqua commented 5 years ago

Info for manufacturer specific workarounds against aggressive battery optimization: https://dontkillmyapp.com/