adolfintel / OpenPods

The Free and Open Source app for monitoring your AirPods on Android
https://fdossena.com/?p=openPods/index.frag
GNU General Public License v3.0
977 stars 166 forks source link

Increase time between notification updates #22

Closed niclimcy closed 5 years ago

niclimcy commented 5 years ago

Really please do not merge this, I just created it to open up some discussion about the insane number of updates to the notification battery status.

Correct me if I am wrong, the for loop runs infinitely to check and update the battery status with a sleep time of 1 second. This seems pretty inefficient and battery draining.

Furthermore, there is no need to update the notification every second as the battery levels of the airpods are not exact values but in multiples of 5. This means that the battery levels would remain the same for quite sometime before it changes -- making the update every second irrelevant.

What I have come-up with to reduce the number of updates is very hacky and does not cover a lot of edge cases. I hope that you might have something else in mind to separate the notification updates from the update checks.

adolfintel commented 5 years ago

Well, I've never seen it go above 1% battery usage so it doesn't seem to be a problem. Android also seems to ignore updates completely when the screen is off.

Did you notice anything unusual?

niclimcy commented 5 years ago

I did notice something unusual but it is not to do with battery life. Sometimes openpod does not seem to be able to detect the airpods even though it is connected to bluetooth when waking up the device. Unfortunately I didn't get any logs and it is fairly hard to reproduce.

adolfintel commented 5 years ago

I've seen it happen a few times, when the screen is off the OS ignores BLE messages, and when it wakes up again it doesn't always receive one immediately because the AirPods seem to send them out at random intervals (up to 15 seconds, but usually 1-2)

niclimcy commented 5 years ago

Oh I see. I'll leave this here at the time being. If I think of a better way to do this, I'll get back to it.

adolfintel commented 5 years ago

Ok, I'll close it in a few days if you don't push anything.

niclimcy commented 5 years ago

With the extra logging I just added, I noticed that the connection timeout happens quite frequently. Why is that so?

adolfintel commented 5 years ago

Hmm, it could be specific to your device or OS but you're the first to report it. What are you using?

For reference, the app was developed and tested on a OnePlus 3T with LineageOS 16

niclimcy commented 5 years ago

I'm testing this with a POCO F1 (beryllium) running LineageOS 16

adolfintel commented 5 years ago

It's very strange to say the least, I mean that timeout is 30 seconds and I've never seen more than about 15.

I really don't know what could be causing it. I see you have a lot of lineage repos on your profile, do you maintain that device?

niclimcy commented 5 years ago

Not exactly. I might have to try this on another device.

adolfintel commented 5 years ago

Just an idea, try version 0.7 before gen 2 support was added which added additional BLE filters.

Also, how frequent is this bug?

niclimcy commented 5 years ago

It was showing up like every 100000ms before. I just retested, it didn't happen again. I must have triggered something else.