-
Notifications
You must be signed in to change notification settings - Fork 615
Fix Android Connectivity Monitor (v2) #1045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
11ca8a5
did the thing
448311d
comment fixes
403f91f
Merge branch 'master' into bc/reconnect
00568be
resolved comments
c865827
Merge branch 'bc/reconnect' of github.com:firebase/firebase-android-s…
d714378
just kidding, had to update more comments and remove unused vars
55e8f46
fix onlinestatetracker constructor
d202893
continue, make spec tests pass
411ed9d
resolve comments: comments, code ordering, rename to connectivity_att…
1519a40
Merge branch 'master' into bc/reconnect
5bce0a0
separate online_state_timeout from connectivity_attempt_timeout
ba515b7
update comments
110fdc3
Merge branch 'master' into bc/reconnect
c9cafd5
Merge branch 'master' into bc/reconnect
b77e02e
update comments
31d0ad8
working with logging comments for future debugging
8b2ad17
ready for review
af9ed48
Merge branch 'master' into bc/reconnect-grpc
1cca6a4
resolve michael comments with runBidi, has comments
86b4733
working in grpc exclusively with logs
873d83d
remove logs
d321316
remove markChannelIdle()
a5dba09
change close() from protected to private
51fac1c
added logging, fixed comments
595046f
fix backoff maxDelay, add comments, some renaming
a3fc304
Merge branch 'master' into bc/reconnect-grpc
36e448f
comment fixes and always clear connectivity timer
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -29,15 +29,22 @@ public class ExponentialBackoff { | |
|
||
public static final double DEFAULT_BACKOFF_FACTOR = 1.5; | ||
|
||
/** Maximum backoff time in milliseconds */ | ||
public static final long DEFAULT_BACKOFF_MAX_DELAY_MS = 60 * 1000; | ||
|
||
private final AsyncQueue queue; | ||
private final TimerId timerId; | ||
private final long initialDelayMs; | ||
private final double backoffFactor; | ||
|
||
private long maxDelayMs; | ||
/** The maximum backoff time in milliseconds. */ | ||
private final long maxDelayMs; | ||
|
||
/** | ||
* The maximum backoff time used when calculating the next backoff. This value can be changed for | ||
* a single backoffAndRun call, after which it resets to maxDelayMs. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
*/ | ||
private long nextMaxDelayMs; | ||
|
||
private long currentBaseMs; | ||
private long lastAttemptTime; | ||
private DelayedTask timerTask; | ||
|
@@ -71,6 +78,7 @@ public ExponentialBackoff( | |
this.initialDelayMs = initialDelayMs; | ||
this.backoffFactor = backoffFactor; | ||
this.maxDelayMs = maxDelayMs; | ||
this.nextMaxDelayMs = maxDelayMs; | ||
this.lastAttemptTime = new Date().getTime(); | ||
|
||
reset(); | ||
|
@@ -100,7 +108,7 @@ public void reset() { | |
* Resets the backoff delay to the maximum delay (e.g. for use after a RESOURCE_EXHAUSTED error). | ||
*/ | ||
public void resetToMax() { | ||
currentBaseMs = maxDelayMs; | ||
currentBaseMs = nextMaxDelayMs; | ||
} | ||
|
||
/** | ||
|
@@ -110,7 +118,7 @@ public void resetToMax() { | |
* @param newMax The temporary maximum delay to set. | ||
*/ | ||
public void setTemporaryMaxDelay(long newMax) { | ||
maxDelayMs = newMax; | ||
nextMaxDelayMs = newMax; | ||
} | ||
|
||
/** | ||
|
@@ -158,12 +166,12 @@ public void backoffAndRun(Runnable task) { | |
currentBaseMs = (long) (currentBaseMs * backoffFactor); | ||
if (currentBaseMs < initialDelayMs) { | ||
currentBaseMs = initialDelayMs; | ||
} else if (currentBaseMs > maxDelayMs) { | ||
currentBaseMs = maxDelayMs; | ||
} else if (currentBaseMs > nextMaxDelayMs) { | ||
currentBaseMs = nextMaxDelayMs; | ||
} | ||
|
||
// Reset max delay to the default. | ||
maxDelayMs = DEFAULT_BACKOFF_MAX_DELAY_MS; | ||
nextMaxDelayMs = maxDelayMs; | ||
} | ||
|
||
public void cancel() { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.