Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Wear OS error handling on home, check websocket connection st…
…ate (#2261) * Websocket: make connected Job Deferred to get errors - Switch the job used for monitoring whether a connection has been established to use Deferred, which will allow us to get the exception that caused the job to be cancelled (and also makes the code a little easier) * Websocket: add variable for state - Add a variable to the websocket repository to monitor the state of the connection. This will allow the app to respond to handled exceptions. * More Websocket race condition fixes - If multiple outgoing messages are pending before the connection is opened, if we receive an invalid auth message or onFailure callback this will be processed last. The connected job is still 'completed', so it shouldn't return true but return if it was successful. This will ensure that any messages after the first one that triggered the failure, will be ignored until the job is reset. - Set the connection state to authenticating before sending the message, to make sure that we don't accidentally override a very quick response * Handle error states in HomeView - Add a state for the loading progress to the view model in order to be able to update the home view with errors if necessary - If loading the main data failed because of authentication, reset the session like in the phone app and send the user back to onboarding - Fix the app getting stuck on a loading screen, even if everything loaded correctly, if there are no supported entity domains in the response
- Loading branch information
Showing
9 changed files
with
165 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
.../src/main/java/io/homeassistant/companion/android/common/data/websocket/WebSocketState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package io.homeassistant.companion.android.common.data.websocket | ||
|
||
enum class WebSocketState { | ||
AUTHENTICATING, ACTIVE, CLOSED_AUTH, CLOSED_OTHER | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.