Aperture: change to FlashMode.OFF before switching usecases
Not all cameras might have the same flash modes.
If front facing camera is switched to screen flash mode,
and the camera flip button is pressed to switch to the back
camera, the app crashes with the following error.
Not a front camera despite setting FLASH_MODE_SCREEN.
CameraX disallows FLASH_MODE_SCREEN usage on back camera.
Aperture does not switch the flash mode before switching
camera usecase.
Fix this by changing to FlashMode.OFF before switching
usecase.
Change-Id: I77e5144120ec1724e175c84400b7346da74bc779
diff --git a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
index 78ad6dc..50296c3 100644
--- a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
@@ -1518,6 +1518,11 @@
photoEffect = ExtensionMode.NONE
}
+ // Fallback to FlashMode.OFF if necessary
+ if (!camera.supportedFlashModes.contains(flashMode)) {
+ changeFlashMode(FlashMode.OFF)
+ }
+
// Initialize the use case we want and set its properties
val cameraUseCases = when (cameraMode) {
CameraMode.QR -> {