-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[camera_android] Fix camera android deprecation warning for CamcorderProfile.get() #7062
[camera_android] Fix camera android deprecation warning for CamcorderProfile.get() #7062
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@camsim99 I verified it by running the example app and I don't get any deprecation warnings now. |
test-exempt: configuration change would one way to test this though be to have a test that verifies that building an app with this feature doesn't cause any spurious console output? long-term maybe we could have the |
Greg from 2021 has your back: flutter/flutter#92031 |
Ah interesting. Can we add that flag to the tests in this repo? If we do, before the patch, does it cause the tests for this plugin to fail? If so, that's the ideal way to test it. |
I ran a build of the example app using Without the fix I get the following output (and I assume that the exit code is also non-zero, as VSCode shows a red x in the terminal): (there is additional output relating to
With the fix I get the following output (and VSCode shows a blue dot, so I assume it exited with exit code 0):
What I would do is set up a test that exercises @christopherfujino Could you give me an example that uses And where would I put this kind of test exactly? Since it involves building an APK, its not exactly a regular test. |
On second thought, in https://github.com/flutter/plugins/blob/main/script/tool/lib/src/build_examples_command.dart we already build the examples. @stuartmorgan is there a reason why the |
I wasn't aware that it existed. How does it work exactly? I.e., what constitutes a warning for the purposes of that flag? Is it doing per-platform regexes on the build output? If it works reliably, we can certainly add it; we mostly have this iOS native warnings erroring, and flutter/flutter#91868 tracks doing that for Android (and other platforms as necessary). |
Good question, since
|
Do you still see the warnings in the verbose build output in that case? That behavior may be fundamental to incremental builds, rather than an issue with the flag. |
Turning verbose mode on for the second run did not affect the outcome, still no warnings. Didn't directly relate that to incremental builds, so yes that works as expected then. |
Unfortunately, passing Example:
|
I don't know enough about Android builds to know if that's something we should (or even can?) be fixing in the build. I've added a note about |
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.
Overall, the change looks good, but I just made some changes to this code, so you may have to change something. Let me know after you merge the changes in main
!
@camsim99 So I pulled in your recent changes relating to the preview size, but now I get the deprecation warnings again. I saw that you wrote a comment about a workaround for a bug with Do you have any ideas? Or will this only get fixed once that workaround is removed? |
@navaronbracke Yeah, you're right. It will default to legacy code if the other code doesn't work. Does it work if you remove the annotation? Keeping it there may be the incorrect thing to do actually suppress the warning. |
@@ -144,6 +143,8 @@ static Size computeBestPreviewSize(int cameraId, ResolutionPreset preset) | |||
* @return The best possible {@link android.media.CamcorderProfile} that matches the supplied | |||
* {@link ResolutionPreset}. | |||
*/ | |||
@TargetApi(Build.VERSION_CODES.R) | |||
@SuppressWarnings("deprecation") |
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.
@camsim99 Apparently @TargetApi()
on its own does not silence the deprecation warning? IIRC my original fix (before your changes for that edge case with EncoderProfiles) only added that annotation to get rid of the deprecation warnings, which did work back then. Strange that I did have to add it back here.
@@ -125,8 +125,7 @@ static Size computeBestPreviewSize(int cameraId, ResolutionPreset preset) | |||
} | |||
} | |||
|
|||
@SuppressWarnings("deprecation") | |||
// TODO(camsim99): Suppression is currently safe because legacy code is used as a fallback for SDK >= S. | |||
// TODO(camsim99): Suppression is currently safe because legacy code is used as a fallback for SDK < S. |
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 was probably a typo? You have if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {}
a few lines above.
We've just completed the migration of the plugin code to the flutter/packages repository, as described in https://flutter.dev/go/flutter-plugins-repo-migration, and this repository is now being archived. Unfortunately that means that all in-progress PRs here must be moved to flutter/packages. Please see our instructions for an explanation of how to move your PR, and if you have any issues moving your PR please don't hesitate to reach out in the #hackers-ecosystem channel in Discord. Our apologies that your PR was caught in this one-time transition. We're aware that it's disruptive in the short term, and appreciate your help in getting us to a better long-term state! |
This PR adds a
@TargetApi()
annotation and moves a@SuppressWarnings("deprecation")
annotation to the right place.List which issues are fixed by this PR. You must list at least one issue.
Fixes flutter/flutter#94999
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
N/A
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.