Search in sources :

Example 66 with CameraAccessException

use of android.hardware.camera2.CameraAccessException in project platform_frameworks_base by android.

the class Camera2Focuser method cancelAutoFocus.

/**
     * Cancel ongoing auto focus, unlock the auto-focus if it was locked, and
     * resume to passive continuous auto focus.
     *
     * @throws CameraAccessException
     */
public synchronized void cancelAutoFocus() throws CameraAccessException {
    mSuccess = false;
    mLocked = false;
    // reset the AF regions:
    setAfRegions(null);
    // Create request builders, the af regions are automatically updated.
    mRepeatingBuilder = createRequestBuilder();
    CaptureRequest.Builder requestBuilder = createRequestBuilder();
    mAutoFocus.setPassiveAutoFocus(/*picture*/
    true, mRepeatingBuilder);
    mAutoFocus.unlockAutoFocus(mRepeatingBuilder, requestBuilder);
    CaptureCallback listener = createCaptureListener();
    mSession.setRepeatingRequest(mRepeatingBuilder.build(), listener, mHandler);
    mSession.capture(requestBuilder.build(), listener, mHandler);
}
Also used : CaptureCallback(android.hardware.camera2.CameraCaptureSession.CaptureCallback) CaptureRequest(android.hardware.camera2.CaptureRequest)

Example 67 with CameraAccessException

use of android.hardware.camera2.CameraAccessException in project platform_frameworks_base by android.

the class Camera2Focuser method startAutoFocusFullActiveLocked.

private void startAutoFocusFullActiveLocked() throws CameraAccessException {
    // Create request builders, the af regions are automatically updated.
    mRepeatingBuilder = createRequestBuilder();
    CaptureRequest.Builder requestBuilder = createRequestBuilder();
    mAutoFocus.setActiveAutoFocus(mRepeatingBuilder, requestBuilder);
    if (mRepeatingBuilder.get(CaptureRequest.CONTROL_AF_TRIGGER) != CaptureRequest.CONTROL_AF_TRIGGER_IDLE) {
        throw new AssertionError("Wrong trigger set in repeating request");
    }
    if (requestBuilder.get(CaptureRequest.CONTROL_AF_TRIGGER) != CaptureRequest.CONTROL_AF_TRIGGER_START) {
        throw new AssertionError("Wrong trigger set in queued request");
    }
    mAutoFocus.resetState();
    CaptureCallback listener = createCaptureListener();
    mSession.setRepeatingRequest(mRepeatingBuilder.build(), listener, mHandler);
    mSession.capture(requestBuilder.build(), listener, mHandler);
}
Also used : CaptureCallback(android.hardware.camera2.CameraCaptureSession.CaptureCallback) CaptureRequest(android.hardware.camera2.CaptureRequest)

Example 68 with CameraAccessException

use of android.hardware.camera2.CameraAccessException in project platform_frameworks_base by android.

the class CameraUtilsUncheckedThrowTest method testUncheckedThrow.

@SmallTest
public void testUncheckedThrow() {
    try {
        UncheckedThrow.throwAnyException(new CameraAccessException(CameraAccessException.CAMERA_DISCONNECTED));
        Assert.fail("unreachable");
        fakeNeverThrowsCameraAccess();
    } catch (CameraAccessException e) {
    }
}
Also used : CameraAccessException(android.hardware.camera2.CameraAccessException) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 69 with CameraAccessException

use of android.hardware.camera2.CameraAccessException in project platform_frameworks_base by android.

the class CameraCaptureSessionImpl method captureBurst.

@Override
public synchronized int captureBurst(List<CaptureRequest> requests, CaptureCallback callback, Handler handler) throws CameraAccessException {
    if (requests == null) {
        throw new IllegalArgumentException("Requests must not be null");
    } else if (requests.isEmpty()) {
        throw new IllegalArgumentException("Requests must have at least one element");
    }
    for (CaptureRequest request : requests) {
        if (request.isReprocess()) {
            if (!isReprocessable()) {
                throw new IllegalArgumentException("This capture session cannot handle " + "reprocess requests");
            } else if (request.getReprocessableSessionId() != mId) {
                throw new IllegalArgumentException("Capture request was created for another " + "session");
            }
        }
    }
    checkNotClosed();
    handler = checkHandler(handler, callback);
    if (DEBUG) {
        CaptureRequest[] requestArray = requests.toArray(new CaptureRequest[0]);
        Log.v(TAG, mIdString + "captureBurst - requests " + Arrays.toString(requestArray) + ", callback " + callback + " handler " + handler);
    }
    return addPendingSequence(mDeviceImpl.captureBurst(requests, createCaptureCallbackProxy(handler, callback), mDeviceHandler));
}
Also used : CaptureRequest(android.hardware.camera2.CaptureRequest)

Example 70 with CameraAccessException

use of android.hardware.camera2.CameraAccessException in project platform_frameworks_base by android.

the class CameraManager method getCameraCharacteristics.

/**
     * <p>Query the capabilities of a camera device. These capabilities are
     * immutable for a given camera.</p>
     *
     * @param cameraId The id of the camera device to query
     * @return The properties of the given camera
     *
     * @throws IllegalArgumentException if the cameraId does not match any
     *         known camera device.
     * @throws CameraAccessException if the camera device has been disconnected.
     *
     * @see #getCameraIdList
     * @see android.app.admin.DevicePolicyManager#setCameraDisabled
     */
@NonNull
public CameraCharacteristics getCameraCharacteristics(@NonNull String cameraId) throws CameraAccessException {
    CameraCharacteristics characteristics = null;
    synchronized (mLock) {
        if (!getOrCreateDeviceIdListLocked().contains(cameraId)) {
            throw new IllegalArgumentException(String.format("Camera id %s does not match any" + " currently connected camera device", cameraId));
        }
        int id = Integer.parseInt(cameraId);
        /*
             * Get the camera characteristics from the camera service directly if it supports it,
             * otherwise get them from the legacy shim instead.
             */
        ICameraService cameraService = CameraManagerGlobal.get().getCameraService();
        if (cameraService == null) {
            throw new CameraAccessException(CameraAccessException.CAMERA_DISCONNECTED, "Camera service is currently unavailable");
        }
        try {
            if (!supportsCamera2ApiLocked(cameraId)) {
                // Legacy backwards compatibility path; build static info from the camera
                // parameters
                String parameters = cameraService.getLegacyParameters(id);
                CameraInfo info = cameraService.getCameraInfo(id);
                characteristics = LegacyMetadataMapper.createCharacteristics(parameters, info);
            } else {
                // Normal path: Get the camera characteristics directly from the camera service
                CameraMetadataNative info = cameraService.getCameraCharacteristics(id);
                characteristics = new CameraCharacteristics(info);
            }
        } catch (ServiceSpecificException e) {
            throwAsPublicException(e);
        } catch (RemoteException e) {
            // Camera service died - act as if the camera was disconnected
            throw new CameraAccessException(CameraAccessException.CAMERA_DISCONNECTED, "Camera service is currently unavailable", e);
        }
    }
    return characteristics;
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) CameraMetadataNative(android.hardware.camera2.impl.CameraMetadataNative) RemoteException(android.os.RemoteException) ICameraService(android.hardware.ICameraService) CameraInfo(android.hardware.CameraInfo) NonNull(android.annotation.NonNull)

Aggregations

ArrayList (java.util.ArrayList)50 Surface (android.view.Surface)42 OutputConfiguration (android.hardware.camera2.params.OutputConfiguration)40 CameraAccessException (android.hardware.camera2.CameraAccessException)35 CaptureRequest (android.hardware.camera2.CaptureRequest)35 CameraCharacteristics (android.hardware.camera2.CameraCharacteristics)25 StreamConfigurationMap (android.hardware.camera2.params.StreamConfigurationMap)21 RemoteException (android.os.RemoteException)15 BlockingSessionCallback (com.android.ex.camera2.blocking.BlockingSessionCallback)14 CameraCaptureSession (android.hardware.camera2.CameraCaptureSession)12 Size (android.util.Size)11 ICameraService (android.hardware.ICameraService)10 CaptureCallback (android.hardware.camera2.CameraCaptureSession.CaptureCallback)10 CameraMetadataNative (android.hardware.camera2.impl.CameraMetadataNative)10 ServiceSpecificException (android.os.ServiceSpecificException)10 CameraManager (android.hardware.camera2.CameraManager)6 NonNull (android.annotation.NonNull)5 CameraInfo (android.hardware.CameraInfo)5 InputConfiguration (android.hardware.camera2.params.InputConfiguration)5 SubmitInfo (android.hardware.camera2.utils.SubmitInfo)5