From ec948d06f9a00339da7df7e2893b64950df7dd74 Mon Sep 17 00:00:00 2001 From: Adam Velebil Date: Fri, 10 Feb 2023 09:30:14 +0100 Subject: [PATCH] fix camera related crashes on Chromebook --- .../main/kotlin/com/yubico/authenticator/MainActivity.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/kotlin/com/yubico/authenticator/MainActivity.kt b/android/app/src/main/kotlin/com/yubico/authenticator/MainActivity.kt index a85b2c61..cef14dd1 100644 --- a/android/app/src/main/kotlin/com/yubico/authenticator/MainActivity.kt +++ b/android/app/src/main/kotlin/com/yubico/authenticator/MainActivity.kt @@ -19,6 +19,7 @@ package com.yubico.authenticator import android.content.* import android.content.SharedPreferences.OnSharedPreferenceChangeListener import android.content.pm.PackageManager +import android.hardware.camera2.CameraCharacteristics import android.hardware.camera2.CameraManager import android.hardware.usb.UsbDevice import android.hardware.usb.UsbManager @@ -352,7 +353,10 @@ class MainActivity : FlutterFragmentActivity() { val cameraService = getSystemService(Context.CAMERA_SERVICE) as CameraManager result.success( - cameraService.cameraIdList.isNotEmpty() + cameraService.cameraIdList.any { + cameraService.getCameraCharacteristics(it) + .get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_BACK + } ) } else -> Log.w(TAG, "Unknown app method: ${methodCall.method}")