Skip to content

Commit 7dbb773

Browse files
[various] Scrub pre-Android-API <24 code (#9851)
For all packages that had conditionals to support Android API <24: - Update the min Flutter version to 3.35, which requires API 24 - Remove the conditional logic - Update gradle to require 24. Also scrubs some comments about older verisons from the app-facing package READMEs, where details hadn't yet been moved to implementation packages. Those don't have version changes, since it's not important when this information goes out (as people on older versions of Flutter, and supporting older versions of Android in their apps, will still get compatible versions, they just aren't the versions we are supporting now). Includes autoformat changes, since updating the min Dart SDK opts into some formatter changes. ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 6f979b5 commit 7dbb773

File tree

82 files changed

+1120
-2036
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1120
-2036
lines changed

packages/camera/camera/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## NEXT
22

33
* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.
4+
* Updates README to reflect that only Android API 24+ is supported.
45

56
## 0.11.2
67

packages/camera/camera/README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A Flutter plugin for iOS, Android and Web allowing access to the device cameras.
88

99
| | Android | iOS | Web |
1010
|----------------|---------|-----------|------------------------|
11-
| **Support** | SDK 23+ | iOS 12.0+ | [See `camera_web `][1] |
11+
| **Support** | SDK 24+ | iOS 12.0+ | [See `camera_web `][1] |
1212

1313
## Features
1414

@@ -37,12 +37,6 @@ If editing `Info.plist` as text, add:
3737

3838
### Android
3939

40-
Change the minimum Android sdk version to 23 (or higher) in your `android/app/build.gradle` file.
41-
42-
```groovy
43-
minSdk = 23
44-
```
45-
4640
The endorsed [`camera_android_camerax`][2] implementation of the camera plugin built with CameraX has
4741
better support for more devices than `camera_android`, but has some limitations; please see [this list][3]
4842
for more details. If you wish to use the [`camera_android`][4] implementation of the camera plugin

packages/camera/camera_android/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.10.10+7
2+
3+
* Updates minimum supported SDK version to Flutter 3.35.
4+
* Removes code for supporting API 21-23.
5+
16
## 0.10.10+6
27

38
* Bumps com.android.tools.build:gradle to 8.12.1.

packages/camera/camera_android/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ buildFeatures {
3434
compileSdk = 36
3535

3636
defaultConfig {
37-
minSdkVersion 21
37+
minSdkVersion 24
3838
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3939
}
4040
lintOptions {

packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/Camera.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -891,12 +891,7 @@ public void pauseVideoRecording() {
891891
}
892892

893893
try {
894-
if (SdkCapabilityChecker.supportsVideoPause()) {
895-
mediaRecorder.pause();
896-
} else {
897-
throw new Messages.FlutterError(
898-
"videoRecordingFailed", "pauseVideoRecording requires Android API +24.", null);
899-
}
894+
mediaRecorder.pause();
900895
} catch (IllegalStateException e) {
901896
throw new Messages.FlutterError("videoRecordingFailed", e.getMessage(), null);
902897
}
@@ -908,12 +903,7 @@ public void resumeVideoRecording() {
908903
}
909904

910905
try {
911-
if (SdkCapabilityChecker.supportsVideoPause()) {
912-
mediaRecorder.resume();
913-
} else {
914-
throw new Messages.FlutterError(
915-
"videoRecordingFailed", "resumeVideoRecording requires Android API +24.", null);
916-
}
906+
mediaRecorder.resume();
917907
} catch (IllegalStateException e) {
918908
throw new Messages.FlutterError("videoRecordingFailed", e.getMessage(), null);
919909
}

packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraApiImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ private Long instantiateCamera(String cameraName, Messages.PlatformMediaSettings
8686
return flutterSurfaceTexture.id();
8787
}
8888

89-
// We move catching CameraAccessException out of onMethodCall because it causes a crash
90-
// on plugin registration for sdks incompatible with Camera2 (< 21). We want this plugin to
91-
// to be able to compile with <21 sdks for apps that want the camera and support earlier version.
9289
@SuppressWarnings("ConstantConditions")
9390
private <T> void handleException(Exception exception, Messages.Result<T> result) {
9491
// The code below exactly preserves the format of the native exceptions generated by pre-Pigeon

packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ public interface CameraProperties {
224224
* @return android.graphics.Rect Area of the image sensor which corresponds to active pixels prior
225225
* to the application of any geometric distortion correction.
226226
*/
227-
@RequiresApi(api = VERSION_CODES.M)
228227
@NonNull
229228
Rect getSensorInfoPreCorrectionActiveArraySize();
230229

packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraPropertiesImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ public Size getSensorInfoPixelArraySize() {
140140
return cameraCharacteristics.get(CameraCharacteristics.SENSOR_INFO_PIXEL_ARRAY_SIZE);
141141
}
142142

143-
@RequiresApi(api = VERSION_CODES.M)
144143
@NonNull
145144
@Override
146145
public Rect getSensorInfoPreCorrectionActiveArraySize() {

packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/SdkCapabilityChecker.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,12 @@ public static boolean supportsEncoderProfiles() {
3434
return SDK_VERSION >= Build.VERSION_CODES.S;
3535
}
3636

37-
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.M)
38-
public static boolean supportsMarshmallowNoiseReductionModes() {
39-
// See https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES
40-
return SDK_VERSION >= Build.VERSION_CODES.M;
41-
}
42-
4337
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.P)
4438
public static boolean supportsSessionConfiguration() {
4539
// See https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration
4640
return SDK_VERSION >= Build.VERSION_CODES.P;
4741
}
4842

49-
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.N)
50-
public static boolean supportsVideoPause() {
51-
// See https://developer.android.com/reference/androidx/camera/video/VideoRecordEvent.Pause
52-
return SDK_VERSION >= Build.VERSION_CODES.N;
53-
}
54-
5543
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.R)
5644
public static boolean supportsZoomRatio() {
5745
// See https://developer.android.com/reference/android/hardware/camera2/CaptureRequest#CONTROL_ZOOM_RATIO

packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/noisereduction/NoiseReductionFeature.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import androidx.annotation.NonNull;
1111
import io.flutter.BuildConfig;
1212
import io.flutter.plugins.camera.CameraProperties;
13-
import io.flutter.plugins.camera.SdkCapabilityChecker;
1413
import io.flutter.plugins.camera.features.CameraFeature;
1514
import java.util.HashMap;
1615

@@ -35,12 +34,10 @@ public NoiseReductionFeature(@NonNull CameraProperties cameraProperties) {
3534
NOISE_REDUCTION_MODES.put(NoiseReductionMode.fast, CaptureRequest.NOISE_REDUCTION_MODE_FAST);
3635
NOISE_REDUCTION_MODES.put(
3736
NoiseReductionMode.highQuality, CaptureRequest.NOISE_REDUCTION_MODE_HIGH_QUALITY);
38-
if (SdkCapabilityChecker.supportsMarshmallowNoiseReductionModes()) {
39-
NOISE_REDUCTION_MODES.put(
40-
NoiseReductionMode.minimal, CaptureRequest.NOISE_REDUCTION_MODE_MINIMAL);
41-
NOISE_REDUCTION_MODES.put(
42-
NoiseReductionMode.zeroShutterLag, CaptureRequest.NOISE_REDUCTION_MODE_ZERO_SHUTTER_LAG);
43-
}
37+
NOISE_REDUCTION_MODES.put(
38+
NoiseReductionMode.minimal, CaptureRequest.NOISE_REDUCTION_MODE_MINIMAL);
39+
NOISE_REDUCTION_MODES.put(
40+
NoiseReductionMode.zeroShutterLag, CaptureRequest.NOISE_REDUCTION_MODE_ZERO_SHUTTER_LAG);
4441
}
4542

4643
@NonNull

0 commit comments

Comments
 (0)