Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-25565] Android: Prevent auto-focus callback from taking multiple pictures #9637

Merged
merged 8 commits into from
Jan 24, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -715,21 +715,24 @@ static public void takePicture()
AutoFocusCallback focusCallback = new AutoFocusCallback() {
public void onAutoFocus(boolean success, Camera camera)
{
try {
camera.takePicture(shutterCallback, null, jpegCallback);
} catch (Exception e) {
Log.w(TAG, "could not take picture: " + e.toString());
takingPicture = false;
}
if (!success) {
Log.w(TAG, "Unable to focus.");
if (takingPicture) {
try {
camera.takePicture(shutterCallback, null, jpegCallback);
} catch (Exception e) {
Log.w(TAG, "could not take picture: " + e.toString());
takingPicture = false;
}
if (!success) {
Log.w(TAG, "Unable to focus.");
}
}
// This is a Hotfix for TIMOB-20260
// "cancelAutoFocus" causes the camera to crash on M (probably due to discontinued support of android.hardware.camera)
// We need to move to android.hardware.camera2 APIs as soon as we can.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
camera.cancelAutoFocus();
}
camera.autoFocus(null);
}
};
camera.autoFocus(focusCallback);
Expand Down