-
Notifications
You must be signed in to change notification settings - Fork 324
Fix(espresso): Fix #2349 #2359
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
Open
Mathias-Boulay
wants to merge
1
commit into
android:main
Choose a base branch
from
Mathias-Boulay:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix(espresso): Fix #2349 #2359
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
|
||
import static java.util.Collections.unmodifiableList; | ||
|
||
import android.app.Application; | ||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.os.Build; | ||
|
@@ -49,6 +50,11 @@ public static void waitForConfigurationChangesOnActivity( | |
if (Build.VERSION.SDK_INT >= 24 && currentActivity.isInMultiWindowMode()) { | ||
return; | ||
} | ||
// If the application is running activities in different processes, activities that aren't | ||
// on the main process may have a different orientation | ||
if (Build.VERSION.SDK_INT >= 28 && !currentActivity.getApplicationInfo().processName.equals(Application.getProcessName())) { | ||
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. currentActivity.getApplicationInfo().processName can be null in Robolectric environments. Consider using Objects.equals |
||
return; | ||
} | ||
|
||
int applicationOrientation = appContext.getResources().getConfiguration().orientation; | ||
if (applicationOrientation != currentActivity.getResources().getConfiguration().orientation) { | ||
|
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.
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'm confused how this statement could ever be true. I'm not familiar with this class but I don't see how it could be called with an Activity from a different process.
Do you have a test that can both repro the problem you are seeing and verify this fixes it?
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.
@brettchabot Yes, as mentioned in #2349, there is this repository: https://github.com/Mathias-Boulay/expresso-issue
Branch
main
: the issue will triggerBranch
fix-included
(newly added for your convenience): the issue won't trigger, as it uses the fixed library.You should be able to use Android Studio Meerkat for both branches to run the only test in the project
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.
OK I think I understand how this fix could work. IIUC currentActivity should always be running in the current process, but it could be possible that the Application's default process is different.
However, doesn't this change run the risk of introducing flakiness? With this change it looks like waitForConfigurationChangesOnActivity will always return immediately if the currentActivity is running in a secondary process.
I suppose it is no different than when the activity is in multi window mode....
I'll import this change internally and run a few more tests. Sorry for the delay in getting this reviewed