From d71b7869a6855f4b93446000764cceae5a2abf16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Cotta?= Date: Wed, 11 Sep 2019 02:44:26 -0300 Subject: [PATCH 1/2] fixed NullPointerException when the device has only front-facing camera. --- .../io/flutter/plugins/camera/CameraUtils.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/camera/android/src/main/java/io/flutter/plugins/camera/CameraUtils.java b/packages/camera/android/src/main/java/io/flutter/plugins/camera/CameraUtils.java index e4613fb237c1..a7bb3b7d4914 100644 --- a/packages/camera/android/src/main/java/io/flutter/plugins/camera/CameraUtils.java +++ b/packages/camera/android/src/main/java/io/flutter/plugins/camera/CameraUtils.java @@ -77,32 +77,31 @@ static CamcorderProfile getBestAvailableCamcorderProfileForResolutionPreset( // All of these cases deliberately fall through to get the best available profile. case max: if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_HIGH)) { - return CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH); + return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_HIGH); } case ultraHigh: if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_2160P)) { - return CamcorderProfile.get(CamcorderProfile.QUALITY_2160P); + return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_2160P); } case veryHigh: if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_1080P)) { - return CamcorderProfile.get(CamcorderProfile.QUALITY_1080P); + return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_1080P); } case high: if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_720P)) { - return CamcorderProfile.get(CamcorderProfile.QUALITY_720P); + return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_720P); } case medium: if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_480P)) { - return CamcorderProfile.get(CamcorderProfile.QUALITY_480P); + return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_480P); } case low: if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_QVGA)) { - return CamcorderProfile.get(CamcorderProfile.QUALITY_QVGA); + return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_QVGA); } default: - if (CamcorderProfile.hasProfile( - Integer.parseInt(cameraName), CamcorderProfile.QUALITY_LOW)) { - return CamcorderProfile.get(CamcorderProfile.QUALITY_LOW); + if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_LOW)) { + return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_LOW); } else { throw new IllegalArgumentException( "No capture session available for current capture session."); From b6e11b104d50ba38fc308f2d58b7d88e5c469d76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Cotta?= Date: Wed, 11 Sep 2019 02:45:19 -0300 Subject: [PATCH 2/2] updated CHANGELOG.md and pubspec.yaml --- packages/camera/CHANGELOG.md | 4 ++++ packages/camera/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/camera/CHANGELOG.md b/packages/camera/CHANGELOG.md index 9ed7a78f1bb1..45a2235043e6 100644 --- a/packages/camera/CHANGELOG.md +++ b/packages/camera/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.4+2 + +* Fix Android NullPointerException on devices with only front-facing camera. + ## 0.5.4+1 * Fix Android pause and resume video crash when executing in APIs below 24. diff --git a/packages/camera/pubspec.yaml b/packages/camera/pubspec.yaml index c9e715225d59..e7c8632b042f 100644 --- a/packages/camera/pubspec.yaml +++ b/packages/camera/pubspec.yaml @@ -2,7 +2,7 @@ name: camera description: A Flutter plugin for getting information about and controlling the camera on Android and iOS. Supports previewing the camera feed, capturing images, capturing video, and streaming image buffers to dart. -version: 0.5.4+1 +version: 0.5.4+2 authors: - Flutter Team