Search in sources :

Example 1 with ICameraDeviceCallbacks

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

the class CameraBinderTest method testConnectDevice.

@SmallTest
public void testConnectDevice() throws Exception {
    for (int cameraId = 0; cameraId < mUtils.getGuessedNumCameras(); ++cameraId) {
        ICameraDeviceCallbacks dummyCallbacks = new DummyCameraDeviceCallbacks();
        String clientPackageName = getContext().getPackageName();
        ICameraDeviceUser cameraUser = mUtils.getCameraService().connectDevice(dummyCallbacks, cameraId, clientPackageName, ICameraService.USE_CALLING_UID);
        assertNotNull(String.format("Camera %s was null", cameraId), cameraUser);
        Log.v(TAG, String.format("Camera %s connected", cameraId));
        cameraUser.disconnect();
    }
}
Also used : ICameraDeviceCallbacks(android.hardware.camera2.ICameraDeviceCallbacks) ICameraDeviceUser(android.hardware.camera2.ICameraDeviceUser) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 2 with ICameraDeviceCallbacks

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

the class CameraDeviceUserShim method connectBinderShim.

public static CameraDeviceUserShim connectBinderShim(ICameraDeviceCallbacks callbacks, int cameraId) {
    if (DEBUG) {
        Log.d(TAG, "Opening shim Camera device");
    }
    /*
         * Put the camera open on a separate thread with its own looper; otherwise
         * if the main thread is used then the callbacks might never get delivered
         * (e.g. in CTS which run its own default looper only after tests)
         */
    CameraLooper init = new CameraLooper(cameraId);
    CameraCallbackThread threadCallbacks = new CameraCallbackThread(callbacks);
    // TODO: Make this async instead of blocking
    int initErrors = init.waitForOpen(OPEN_CAMERA_TIMEOUT_MS);
    Camera legacyCamera = init.getCamera();
    // Check errors old HAL initialization
    LegacyExceptionUtils.throwOnServiceError(initErrors);
    // Disable shutter sounds (this will work unconditionally) for api2 clients
    legacyCamera.disableShutterSound();
    CameraInfo info = new CameraInfo();
    Camera.getCameraInfo(cameraId, info);
    Camera.Parameters legacyParameters = null;
    try {
        legacyParameters = legacyCamera.getParameters();
    } catch (RuntimeException e) {
        throw new ServiceSpecificException(ICameraService.ERROR_INVALID_OPERATION, "Unable to get initial parameters: " + e.getMessage());
    }
    CameraCharacteristics characteristics = LegacyMetadataMapper.createCharacteristics(legacyParameters, info);
    LegacyCameraDevice device = new LegacyCameraDevice(cameraId, legacyCamera, characteristics, threadCallbacks);
    return new CameraDeviceUserShim(cameraId, device, characteristics, init, threadCallbacks);
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) CameraCharacteristics(android.hardware.camera2.CameraCharacteristics) Camera(android.hardware.Camera) CameraInfo(android.hardware.Camera.CameraInfo)

Example 3 with ICameraDeviceCallbacks

use of android.hardware.camera2.ICameraDeviceCallbacks in project android_frameworks_base by ResurrectionRemix.

the class CameraBinderTest method testConnectDevice.

@SmallTest
public void testConnectDevice() throws Exception {
    for (int cameraId = 0; cameraId < mUtils.getGuessedNumCameras(); ++cameraId) {
        ICameraDeviceCallbacks dummyCallbacks = new DummyCameraDeviceCallbacks();
        String clientPackageName = getContext().getPackageName();
        ICameraDeviceUser cameraUser = mUtils.getCameraService().connectDevice(dummyCallbacks, cameraId, clientPackageName, ICameraService.USE_CALLING_UID);
        assertNotNull(String.format("Camera %s was null", cameraId), cameraUser);
        Log.v(TAG, String.format("Camera %s connected", cameraId));
        cameraUser.disconnect();
    }
}
Also used : ICameraDeviceCallbacks(android.hardware.camera2.ICameraDeviceCallbacks) ICameraDeviceUser(android.hardware.camera2.ICameraDeviceUser) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 4 with ICameraDeviceCallbacks

use of android.hardware.camera2.ICameraDeviceCallbacks in project android_frameworks_base by ResurrectionRemix.

the class CameraDeviceUserShim method connectBinderShim.

public static CameraDeviceUserShim connectBinderShim(ICameraDeviceCallbacks callbacks, int cameraId) {
    if (DEBUG) {
        Log.d(TAG, "Opening shim Camera device");
    }
    /*
         * Put the camera open on a separate thread with its own looper; otherwise
         * if the main thread is used then the callbacks might never get delivered
         * (e.g. in CTS which run its own default looper only after tests)
         */
    CameraLooper init = new CameraLooper(cameraId);
    CameraCallbackThread threadCallbacks = new CameraCallbackThread(callbacks);
    // TODO: Make this async instead of blocking
    int initErrors = init.waitForOpen(OPEN_CAMERA_TIMEOUT_MS);
    Camera legacyCamera = init.getCamera();
    // Check errors old HAL initialization
    LegacyExceptionUtils.throwOnServiceError(initErrors);
    // Disable shutter sounds (this will work unconditionally) for api2 clients
    legacyCamera.disableShutterSound();
    CameraInfo info = new CameraInfo();
    Camera.getCameraInfo(cameraId, info);
    Camera.Parameters legacyParameters = null;
    try {
        legacyParameters = legacyCamera.getParameters();
    } catch (RuntimeException e) {
        throw new ServiceSpecificException(ICameraService.ERROR_INVALID_OPERATION, "Unable to get initial parameters: " + e.getMessage());
    }
    CameraCharacteristics characteristics = LegacyMetadataMapper.createCharacteristics(legacyParameters, info);
    LegacyCameraDevice device = new LegacyCameraDevice(cameraId, legacyCamera, characteristics, threadCallbacks);
    return new CameraDeviceUserShim(cameraId, device, characteristics, init, threadCallbacks);
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) CameraCharacteristics(android.hardware.camera2.CameraCharacteristics) Camera(android.hardware.Camera) CameraInfo(android.hardware.Camera.CameraInfo)

Example 5 with ICameraDeviceCallbacks

use of android.hardware.camera2.ICameraDeviceCallbacks in project android_frameworks_base by DirtyUnicorns.

the class CameraBinderTest method testConnectDevice.

@SmallTest
public void testConnectDevice() throws Exception {
    for (int cameraId = 0; cameraId < mUtils.getGuessedNumCameras(); ++cameraId) {
        ICameraDeviceCallbacks dummyCallbacks = new DummyCameraDeviceCallbacks();
        String clientPackageName = getContext().getPackageName();
        ICameraDeviceUser cameraUser = mUtils.getCameraService().connectDevice(dummyCallbacks, cameraId, clientPackageName, ICameraService.USE_CALLING_UID);
        assertNotNull(String.format("Camera %s was null", cameraId), cameraUser);
        Log.v(TAG, String.format("Camera %s connected", cameraId));
        cameraUser.disconnect();
    }
}
Also used : ICameraDeviceCallbacks(android.hardware.camera2.ICameraDeviceCallbacks) ICameraDeviceUser(android.hardware.camera2.ICameraDeviceUser) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

Camera (android.hardware.Camera)5 CameraInfo (android.hardware.Camera.CameraInfo)5 CameraCharacteristics (android.hardware.camera2.CameraCharacteristics)5 ICameraDeviceCallbacks (android.hardware.camera2.ICameraDeviceCallbacks)5 ICameraDeviceUser (android.hardware.camera2.ICameraDeviceUser)5 ServiceSpecificException (android.os.ServiceSpecificException)5 SmallTest (android.test.suitebuilder.annotation.SmallTest)5