Control commit

This commit is contained in:
Captain Arepa 2024-05-31 14:50:24 -04:00
parent 10540e3821
commit 6fc8abde7f

View file

@ -90,7 +90,9 @@ public class SegpassCamera {
/**
* Error constants
*/
private static final String ERROR_CAMERA_ACCESS = "Camera access error.";
private static final String ERROR_MSG_CAMERA_ACCESS = "Camera access error.";
private static final String ERROR_MSG_CAMERA_TIMEOUT = "Timeout waiting to lock camera opening.";
private static final String ERROR_MSG_NO_CAMERA_PREVIEW_SIZE = "No compatible picture image sizes found.";
/**
* ID of the current {@link CameraDevice}.
@ -538,7 +540,7 @@ public class SegpassCamera {
CameraManager manager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE);
try {
if (!mCameraOpenCloseLock.tryAcquire(2500, TimeUnit.MILLISECONDS)) {
throw new SegpassCameraException("Time out waiting to lock camera opening.");
throw new SegpassCameraException(ERROR_MSG_CAMERA_TIMEOUT);
}
manager.openCamera(mCameraId, mStateCallback, mBackgroundHandler);
} catch (CameraAccessException e) {
@ -628,7 +630,7 @@ public class SegpassCamera {
);
} catch (CameraAccessException e) {
Log.e(TAG, "createCameraPreviewSession(): " + e.getMessage());
mCameraCallback.onCameraInitError(ERROR_CAMERA_ACCESS);
mCameraCallback.onCameraInitError(ERROR_MSG_CAMERA_ACCESS);
}
}
@ -680,7 +682,7 @@ public class SegpassCamera {
// Obtains list of image size supported by the selected camera sensor.
Size[] jpegSizes = Objects.requireNonNull(characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)).getOutputSizes(ImageFormat.JPEG);
if (jpegSizes == null) throw new NullPointerException("Error taking picture");
if (jpegSizes == null) throw new NullPointerException(ERROR_MSG_NO_CAMERA_PREVIEW_SIZE);
// Default dimensions
int width = 640;
@ -734,7 +736,7 @@ public class SegpassCamera {
session.capture(captureBuilder.build(), captureListener, mBackgroundHandler);
} catch (CameraAccessException e) {
Log.e(TAG, "onConfigured@takePicture(): " + e.getMessage());
mCameraCallback.onCameraInitError(ERROR_CAMERA_ACCESS);
mCameraCallback.onCameraInitError(ERROR_MSG_CAMERA_ACCESS);
}
}
@ -745,7 +747,7 @@ public class SegpassCamera {
}, mBackgroundHandler);
} catch (CameraAccessException e) {
Log.e(TAG, "CameraAccessException@takePicture(): " + e.getMessage());
mCameraCallback.onCameraInitError(ERROR_CAMERA_ACCESS);
mCameraCallback.onCameraInitError(ERROR_MSG_CAMERA_ACCESS);
}
}