From 6fc8abde7f886d5884dd267321ad01c3579ff2ec Mon Sep 17 00:00:00 2001 From: Captain Arepa Date: Fri, 31 May 2024 14:50:24 -0400 Subject: [PATCH] Control commit --- .../cameraxtestappjava/segpass/SegpassCamera.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/example/cameraxtestappjava/segpass/SegpassCamera.java b/app/src/main/java/com/example/cameraxtestappjava/segpass/SegpassCamera.java index 93f1dff..ceda08f 100644 --- a/app/src/main/java/com/example/cameraxtestappjava/segpass/SegpassCamera.java +++ b/app/src/main/java/com/example/cameraxtestappjava/segpass/SegpassCamera.java @@ -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); } }