Skip to content

Commit

Permalink
Merge pull request #9637 from garymathews/TIMOB-25565
Browse files Browse the repository at this point in the history
[TIMOB-25565] Android: Prevent auto-focus callback from taking multiple pictures
  • Loading branch information
Lokesh Choudhary committed Jan 24, 2018
2 parents 27d5ccd + f8b2783 commit bd94d84
Showing 1 changed file with 11 additions and 8 deletions.
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

0 comments on commit bd94d84

Please sign in to comment.