fix camera related crashes on Chromebook

This commit is contained in:
Adam Velebil 2023-02-10 09:30:14 +01:00
parent 1ae5704a28
commit ec948d06f9
No known key found for this signature in database
GPG Key ID: C9B1E4A3CBBD2E10

View File

@ -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}")