This change aims to improve the connection reliability on Even Realities
G1. It has a few changes:
1. Fixed a bug in MultiBLEDeviceSupport where if one devices "fails" to
connect because it is already connected, the other devices would be
skipped over.
2. Take the ConectionMonitor lock in G1 Device support when one of the
devices being disconnected is being handled, this prevents
reconnection or double disconnects overlapping leading to unexpected
state.
3. Add a hack when one side disconnects so that the global state of the
sub devices never passes through NOT_CONNECTED and instead moves
right from CONNECTED to WAITING_FOR_RECONNECT. This prevents the the
doubling of reconnection delay multiple times resulting in full 64
seconds reconnect attempts.
4. When one device disconnects, both BLE queues are now explicitly
disconnected. Previously just the device state was changed, which
meant reconnection was not always reliable.
5. Made the heart beat delay dynamic, when android low power mode kicks
in, the system may only check the timer expiration every 20 seconds.
Previously to get around this, the delay was set to a fixed 8
seconds, but this uses additional power when not in low power mode.
Now the thread will check the system added delay based on the time
since the last heartbeat and will schedule dymaically based on that.
The minimum delay is still 8 seconds, but now when batter saver is
not enabled, the delay will change to 25 seconds.
6. Fixed some nullptr exceptions when handling the device disconnection
when one device is not yet connected.
It seems like I didn't actually redeploy the app to my phone when
testing my previous change, so I was actually testing the old code
(which works with my particular device name). After rebuilding for
sure with the new code, I didn't get the indexOf offsets correct.
This fixes the bug introduced by the previous change.
This change fixes several things:
1. Update the logic for 3 state related functions for MultiBLEDevice
so they now take into account all sub devices.
2. Fix several race condidtions in the initialization logic. This
fixes one lens permenantly not being connected.
3. Add a callback when one of the devicess diconnects to put the
both sides of the lens into WAITING_FOR_RECONNECT state.
4. Decrease the heartbeat sleep to 8 seconds. Since Android Deep sleep
can add upwards to 20 seconds to the sleep time, this means most
heartbeats will be sent every 28 seconds.
5. Fixed a bug in the per-side state when the device was disconnected
without the SideManager object being destroyed which lead to the
full initialization process not being followed on reconnection.