Skip to content

Add connectivity status check to SpeechPlayer provider#1901

Merged
danesfeder merged 1 commit into
masterfrom
dan-voice-connectivity
Apr 25, 2019
Merged

Add connectivity status check to SpeechPlayer provider#1901
danesfeder merged 1 commit into
masterfrom
dan-voice-connectivity

Conversation

@danesfeder
Copy link
Copy Markdown
Contributor

Description

Closes #1842

  • I have added any issue links
  • I have added all related labels (bug, feature, new API(s), SEMVER, etc.)
  • I have added the appropriate milestone and project boards

Goal

As described in #1842, we rely on failed Voice API requests for our fallback to the AndroidSpeechPlayer or "offline voice". The goal of this PR is to check connection upfront so that we don't worry about the API request or have to deal with the latency of the failed request.

Implementation

Make ConnectivityStatusProvider public so we can share it between the router / voice instruction loader, etc. We should definitely make this internal as soon as the package work lands. I've added a javadoc note TODO as a reminder.

Testing

Please describe the manual tests that you ran to verify your changes

  • I have tested locally (including SNAPSHOT upstream dependencies if needed)
  • I have tested via a test drive, or a simulation/mock location app
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code

@codecov-io
Copy link
Copy Markdown

codecov-io commented Apr 22, 2019

Codecov Report

Merging #1901 into master will increase coverage by 0.1%.
The diff coverage is 79.31%.

@@             Coverage Diff             @@
##             master    #1901     +/-   ##
===========================================
+ Coverage     36.23%   36.33%   +0.1%     
- Complexity     1085     1087      +2     
===========================================
  Files           261      261             
  Lines          8860     8874     +14     
  Branches        668      668             
===========================================
+ Hits           3210     3224     +14     
+ Misses         5360     5358      -2     
- Partials        290      292      +2

Copy link
Copy Markdown
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good so far @danesfeder

I've left some comments to 👀 before merging. Great test coverage ❤️

SpeechPlayerProvider(@NonNull Context context, String language,
boolean voiceLanguageSupported, VoiceInstructionLoader voiceInstructionLoader,
ConnectivityStatusProvider connectivityStatus) {
initialize(context, language, voiceLanguageSupported, voiceInstructionLoader);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be this(context, language, voiceLanguageSupported, voiceInstructionLoader); instead?


private void initMapboxSpeechPlayer(Context context, String language, boolean voiceLanguageSupported,
SpeechListener listener, VoiceInstructionLoader voiceInstructionLoader) {
private void initializeMapboxSpeechPlayer(Context context, String language, boolean voiceLanguageSupported,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding naming consistency here ❤️


private void initAndroidSpeechPlayer(Context context, String language,
SpeechListener listener) {
private void initializeAndroidSpeechPlayer(Context context, String language,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding naming consistency here ❤️

}

public void cacheInstructions(List<String> instructions) {
if (!connectivityStatus.isConnected()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we could move this check up in the stack

and and avoid all the logic / calculations that happen before calling VoiceInstructionLoader#cacheInstructions 🤔

@danesfeder danesfeder force-pushed the dan-voice-connectivity branch 2 times, most recently from d58898d to b43eece Compare April 25, 2019 16:34
Copy link
Copy Markdown
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the feedback @danesfeder

🚢 as soon as CI is ✅

@danesfeder danesfeder force-pushed the dan-voice-connectivity branch from b43eece to bf3d067 Compare April 25, 2019 19:09
@danesfeder danesfeder merged commit 0324e02 into master Apr 25, 2019
@danesfeder danesfeder deleted the dan-voice-connectivity branch April 25, 2019 20:42
@danesfeder danesfeder mentioned this pull request May 1, 2019
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check for device connectivity prior to voice instruction

3 participants