-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Extend VirtualDisplay shadow support down to SDK 28 #9339
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
|
Thanks, I will run some checks to verify that this doesn't cause any compatibility issues. |
robolectric/src/test/java/org/robolectric/shadows/ShadowDisplayManagerGlobalTest.java
Outdated
Show resolved
Hide resolved
|
I am seeing this test failure when running the test in a bazel environment in Android P (28) and Q (29): |
| private VirtualDisplay createVirtualDisplay(Surface surface) { | ||
| VirtualDisplayConfig config = | ||
| new VirtualDisplayConfig.Builder("name", DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_DPI) | ||
| .setSurface(surface) |
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.
The line of code that creates a VirtualDisplayConfig can only be run on SDK >= R.
|
It seems like currently the Robolectric android-all jar from U exists on the runtime classpath when running Robolectric's tests on GitHub, so the VirtualDisplayConfig is coming from Android U android-all jar, even though it doesn't exist in SDK 28 and 29. This is why tests are currently passing in this PR, I filed #9357. |
Thanks, nice catch! Updating ... |
| } | ||
| } | ||
|
|
||
| @TargetApi(R) |
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.
IIRC, AndroidX recommends to use RequiresApi than TargeApi.
194ac08 introduced shadow support for virtual displays but the `IDisplayManager#createVirtualDisplay` proxy signature only works for SDK 30+. This adds a signature for pre-SDK 30.
|
To be clear, I reran the |
|
Thanks! |
194ac08 introduced shadow support for virtual displays but the
IDisplayManager#createVirtualDisplayproxy signature only works for SDK 30+. This adds a signature for pre-SDK 30.Overview
I found when integrating Robo 4.13 that several tests using virtual displays on SDK 28 began failing with:
The root of the issue is that the
createVirtualDisplayproxy was not intercepting due to signature mis-match, but theresizeVirtualDisplayproxy was (andvirtualDisplayIdswas never populated).Proposed Changes
Add a pre-SDK-30 compatible signature for
IDisplayManager#createVirtualDisplayin the proxy. Update the tests to verify from SDK 28 onwards.