I'm testing my Camera2 implementation on Nexus 5 with 6.0.1. The problem seems to be related to switching flash modes. Quite unpredictably, changing the flash and taking a picture results in AF not locking and the following appearing in logs:
01-13 11:02:53.184 214 7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.217 214 7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.251 214 7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.284 214 7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.318 214 7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.351 214 7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.385 214 7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.419 214 7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.452 214 7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.485 214 7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.519 214 7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.552 214 7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.586 214 7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.619 214 7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:53.653 214 7175 I mm-camera: af_exhaustive_search: AEC not settled. Returning!
01-13 11:02:54.031 214 7174 I mm-camera-sensor: port_sensor_process_aec_est:686 AEC EST DONE
01-13 11:02:54.031 214 7174 I mm-camera-sensor: port_sensor_process_aec_est:686 AEC EST DONE
01-13 11:02:54.031 214 7174 I mm-camera-sensor: port_sensor_process_aec_est:688 regular_led_trigger 1
01-13 11:02:54.648 804 1488 D NetlinkSocketObserver: NeighborEvent{elapsedMs=947757, 10.12.0.254, [000D483417C9], RTM_NEWNEIGH, NUD_PROBE}
01-13 11:02:56.000 197 791 D audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback
01-13 11:02:56.001 197 791 D audio_hw_primary: disable_snd_device: snd_device(2: speaker)
01-13 11:02:57.048 214 7192 E mm-camera-sensor: port_sensor_handle_upstream_module_event:1444 Reset previously set LED state!
01-13 11:02:57.048 214 7192 I AEC_PORT: aec_port_proc_downstream_event: Received LED state timeout. Reset LED state!
01-13 11:02:59.918 214 7175 E mm-camera: af_process_parse_stats: Invalid FV data!
01-13 11:02:59.918 214 7175 E mm-camera: af_process: Error processing AF stats!
01-13 11:02:59.952 214 7175 E mm-camera: af_process_parse_stats: Invalid FV data!
01-13 11:02:59.952 214 7175 E mm-camera: af_process: Error processing AF stats!
If I keep taking photos without switching flash modes, it works fine (even if the flash is always on). This happens only when I switch flash modes and it doesn't seem to matter which mode is active (so going from FLASH ON to FLASH AUTO or FLASH AUTO to FLASH OFF can both result in this error).
This is my code for changing flash modes:
private void setFlashMode(String mode) {
if (mode.equals(CAMERA_FLASH_OFF) ) {
mPreviewRequestBuilder
.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
}
else if(mode.equals(CAMERA_FLASH_AUTO)) {
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH);
mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
}
else if(mode.equals(CAMERA_FLASH_ON)) {
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_ALWAYS_FLASH);
mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
}
else if(mode.equals(CAMERA_FLASH_TORCH)) {
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_TORCH);
}
try {
mCaptureSession.setRepeatingRequest(mPreviewRequestBuilder.build(), null,
mBackgroundHandler);
if (getOnCameraParametersSetListener() != null) {
getOnCameraParametersSetListener().onCameraParametersSet();
}
} catch (CameraAccessException e) {
Log.e(TAG,
".setFlashMode() - Exception caught while setting the capture session request",
e);
}
}
Any help very much appreciated.
Looks like the problem was in not passing a callback when calling setRepeatingRequest
. The fix was to add the original callback.