google/cameraview

autoFocus is lost after switching camera facing

siralam opened this issue · 1 comments

OMG... How come such an apparent bug.

In updateAutoFocus(), mAutoFocus is set to false if the camera does not support autoFocus.

So:
(1) mAutoFocus is now true
(2) Switch to front camera, which does not support auto focus
(3) mAutoFocus is now false
(4) Switch back to back camera
(5) in updateAutoFocus, since mAutoFocus is false, the camera is directly set to not auto focus.

The best approach to solve this problem is to separate autoFocus from setting, and whether we need to auto focus now.

For those who want to solve this problem, you may take a look at my commits. Just 4 lines of code to change in total:

siralam@8890f5f

siralam@5e1d4a8