Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit abaff5a

Browse files
author
David Roume
committed
[camera]: temporary patch to avoid camera init crash on android 13 caused by a deprecated video profile object
1 parent 1b1d123 commit abaff5a

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

  • packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/resolution

packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/resolution/ResolutionFeature.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,37 @@ public void updateBuilder(CaptureRequest.Builder requestBuilder) {
111111
@VisibleForTesting
112112
static Size computeBestPreviewSize(int cameraId, ResolutionPreset preset)
113113
throws IndexOutOfBoundsException {
114+
// !-------------------------------------------------------
115+
// !--- TEMPORARY PATCH ---
116+
// ! remove the test below to use higher camera resolution
114117
// if (preset.ordinal() > ResolutionPreset.high.ordinal()) {
115118
// preset = ResolutionPreset.high;
116119
// }
117-
if (Build.VERSION.SDK_INT >= 31) {
120+
// !--- END OF TEMPORARY PATCH ---
121+
// !-------------------------------------------------------
122+
123+
// !-------------------------------------------------------
124+
// !--- TEMPORARY PATCH ---
125+
// ! limiting the condition to Build.VERSION.SDK_INT == 31 && Build.VERSION.SDK_INT == 32 only
126+
// ! to avoid crash on Android 13
127+
if (Build.VERSION.SDK_INT >= 31 && Build.VERSION.SDK_INT < 33) {
118128
EncoderProfiles profile =
119129
getBestAvailableCamcorderProfileForResolutionPreset(cameraId, preset);
120130
List<EncoderProfiles.VideoProfile> videoProfiles = profile.getVideoProfiles();
121131
EncoderProfiles.VideoProfile defaultVideoProfile = videoProfiles.get(0);
122-
132+
123133
return new Size(defaultVideoProfile.getWidth(), defaultVideoProfile.getHeight());
134+
// !-----------------
135+
// ! original source
136+
// if (Build.VERSION.SDK_INT >= 31) {
137+
// EncoderProfiles profile =
138+
// getBestAvailableCamcorderProfileForResolutionPreset(cameraId, preset);
139+
// List<EncoderProfiles.VideoProfile> videoProfiles = profile.getVideoProfiles();
140+
// EncoderProfiles.VideoProfile defaultVideoProfile = videoProfiles.get(0);
141+
142+
// return new Size(defaultVideoProfile.getWidth(), defaultVideoProfile.getHeight());
143+
// !--- END OF TEMPORARY PATCH ---
144+
// !-------------------------------------------------------
124145
} else {
125146
@SuppressWarnings("deprecation")
126147
CamcorderProfile profile =

0 commit comments

Comments
 (0)