RedApparat / Fotoapparat

Making Camera for Android more friendly. 📸
Apache License 2.0
3.82k stars 405 forks source link

Bug: Illegal lens position on very specific device #224

Closed luhmirin-s closed 6 years ago

luhmirin-s commented 6 years ago

I personally was not able to reproduce this is issue and I have a serious suspicion that it is very device specific. Still I think it is something that should be reported.

What are you trying to achieve or the steps to reproduce?

Following crash report came in Fabric:

Caused by java.lang.IllegalArgumentException: Lens position 2 is not supported.
       at io.fotoapparat.characteristic.LensPositionCharacteristicKt.toLensPosition(LensPositionCharacteristic.kt:19)
       at io.fotoapparat.characteristic.CameraInfoProviderKt.getCharacteristics(CameraInfoProvider.kt:13)
       at io.fotoapparat.hardware.Device.<init>(Device.kt:38)
       at io.fotoapparat.hardware.Device.<init>(Device.kt:31)
       at io.fotoapparat.Fotoapparat.<init>(Fotoapparat.kt:61)
       at io.fotoapparat.Fotoapparat.<init>(Fotoapparat.kt:54)

From what I understand this function is the source of exception. Somehow Camera.CameraInfo constants have value other than specified in docs.

The only device with this crash is Leagoo T5.

What would be the proper way of handling such cases?

Context:

Diolor commented 6 years ago

I hope that position 2 means external (at least in camera 2). So we can simply add a case when position is 2 to return LensPosition.External.

I also think their dev team made the mistake to mark the 2nd camera as external instead of back facing. But the best thing we can do is assume it's external.

Feel free to send a PR!