Skip to content

Commit

Permalink
Merge branch '9_0_X' into TIMOB-27823-9_0_X
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtcoolguy committed Mar 26, 2020
2 parents 27506a8 + ab3d8c6 commit 88632de
Showing 1 changed file with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -716,31 +716,36 @@ static public void takePicture()
public void onAutoFocus(boolean success, Camera camera)
{
if (takingPicture) {
try {
camera.takePicture(shutterCallback, null, jpegCallback);
} catch (Exception e) {
Log.w(TAG, "could not take picture: " + e.toString());
takingPicture = false;
}
if (!success) {
if (success) {
try {
camera.takePicture(shutterCallback, null, jpegCallback);
} catch (Exception e) {
Log.w(TAG, "Could not take picture: " + e.toString());
takingPicture = false;
}

// This is required in order to continue auto-focus after taking a picture.
// Calling 'cancelAutofocus' may cause issues on Android M. (TIMOB-20260)
// Which is why this requires an exception handler.
// NOTE: We should really update to Camera2 API.
try {
camera.cancelAutoFocus();
camera.autoFocus(null);
} catch (Exception e) {
Log.w(TAG, "Failed to cancel auto focus: " + e.toString());
}
} else {
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);
} else {
camera.takePicture(shutterCallback, null, jpegCallback);
}
} catch (Exception e) {
Log.w(TAG, "could not take picture: " + e.toString());
Log.w(TAG, "Could not take picture: " + e.toString());
if (camera != null) {
camera.release();
}
Expand Down

0 comments on commit 88632de

Please sign in to comment.