Issue #, if available:
For user initiated disconnects, the app clears the UI buttons by calling resetUI() which in turn calls onCheckedChanged() listener.
The code prevents disconnecting twice by checking for aDevice != NULL. However the callback could be triggered before setting aDevice to NULL and cause a double disconnect.
Description of changes:
Set the callback listener to null so that onCheckedChanged() will not be invoked for resetting the UI.
Set the device to null before disconnect to prevent double disconnect.
Refactor some functions for better readability.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Issue #, if available: For user initiated disconnects, the app clears the UI buttons by calling
resetUI()
which in turn callsonCheckedChanged()
listener. The code prevents disconnecting twice by checking foraDevice != NULL
. However the callback could be triggered before settingaDevice
toNULL
and cause a double disconnect.Description of changes: Set the callback listener to null so that
onCheckedChanged()
will not be invoked for resetting the UI. Set the device to null before disconnect to prevent double disconnect. Refactor some functions for better readability.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.