-
Notifications
You must be signed in to change notification settings - Fork 624
Allow AAB install to be started from a background thread #3348
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
Conversation
@GuardedBy("updateAabLock") | ||
private UpdateTaskImpl cachedUpdateTask; | ||
|
||
@GuardedBy("updateAabLock") | ||
private AppDistributionReleaseInternal aabReleaseInProgress; | ||
|
||
private final Object updateAabLock = new Object(); | ||
private final Context context; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This context reference was unused
Coverage Report 1Affected Products
Test Logs
Notes |
5c74757
to
c7c34e0
Compare
Size Report 1Affected Products
Test Logs
Notes |
firebase-appdistribution/src/test/java/com/google/firebase/appdistribution/TestUtils.java
Show resolved
Hide resolved
@@ -100,7 +95,7 @@ public void updateAppTask_whenOpenConnectionFails_setsNetworkFailure() | |||
when(mockHttpsUrlConnectionFactory.openConnection(TEST_URL)).thenThrow(caughtException); | |||
|
|||
UpdateTask updateTask = aabUpdater.updateAab(TEST_RELEASE_NEWER_AAB_INTERNAL); | |||
testExecutor.awaitTermination(1, TimeUnit.SECONDS); | |||
testExecutor.awaitTermination(100, TimeUnit.MILLISECONDS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there some timeout issue that you changed the waiting from 1 second to 100 ms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to reduce the maximum waiting time of running these tests. 1 second seems like overkill.
firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/TaskUtils.java
Outdated
Show resolved
Hide resolved
// On a background thread, fetch the redirect URL and open it in the Play app | ||
runAsyncInTask(executor, () -> fetchDownloadRedirectUrl(newRelease.getDownloadUrl())) | ||
.onSuccessTask( | ||
executor, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for this chain of tasks we use this executor but we don't do this elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. We actually do this inconsistently. For example ApkUpdater uses its own executor, while TesterSignInManager does not (so callbacks run on the main thread).
In this case since we're already using it for the fetchDownloadRedirectUrl it seemed to make sense to use it everywhere. This also makes testing easier for the reasons we were discussing earlier. Robolectric unit tests run on the main thread, so awaiting Tasks to finish blocks execution of callbacks that also run on the main thread.
I think we should come up with a more consistent approach though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually went ahead and removed these, since it was confusing. Got the tests to pass as well.
firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/AabUpdater.java
Show resolved
Hide resolved
2f35adb
to
2a3725c
Compare
2a3725c
to
27f5ebb
Compare
/test check-changed |
1 similar comment
/test check-changed |
No description provided.