Search in sources :

Example 6 with CameraInfo

use of android.hardware.CameraInfo in project android_frameworks_base by AOSPA.

the class CameraBinderTest method testCameraInfo.

@SmallTest
public void testCameraInfo() throws Exception {
    for (int cameraId = 0; cameraId < mUtils.getGuessedNumCameras(); ++cameraId) {
        CameraInfo info = mUtils.getCameraService().getCameraInfo(cameraId);
        assertTrue("Facing was not set for camera " + cameraId, info.info.facing != -1);
        assertTrue("Orientation was not set for camera " + cameraId, info.info.orientation != -1);
        Log.v(TAG, "Camera " + cameraId + " info: facing " + info.info.facing + ", orientation " + info.info.orientation);
    }
}
Also used : CameraInfo(android.hardware.CameraInfo) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 7 with CameraInfo

use of android.hardware.CameraInfo in project android_frameworks_base by AOSPA.

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)

Example 8 with CameraInfo

use of android.hardware.CameraInfo in project android_frameworks_base by DirtyUnicorns.

the class CameraBinderTest method testCameraInfo.

@SmallTest
public void testCameraInfo() throws Exception {
    for (int cameraId = 0; cameraId < mUtils.getGuessedNumCameras(); ++cameraId) {
        CameraInfo info = mUtils.getCameraService().getCameraInfo(cameraId);
        assertTrue("Facing was not set for camera " + cameraId, info.info.facing != -1);
        assertTrue("Orientation was not set for camera " + cameraId, info.info.orientation != -1);
        Log.v(TAG, "Camera " + cameraId + " info: facing " + info.info.facing + ", orientation " + info.info.orientation);
    }
}
Also used : CameraInfo(android.hardware.CameraInfo) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 9 with CameraInfo

use of android.hardware.CameraInfo in project android_frameworks_base by DirtyUnicorns.

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)

Example 10 with CameraInfo

use of android.hardware.CameraInfo in project android_frameworks_base by ResurrectionRemix.

the class CameraBinderTest method testCameraInfo.

@SmallTest
public void testCameraInfo() throws Exception {
    for (int cameraId = 0; cameraId < mUtils.getGuessedNumCameras(); ++cameraId) {
        CameraInfo info = mUtils.getCameraService().getCameraInfo(cameraId);
        assertTrue("Facing was not set for camera " + cameraId, info.info.facing != -1);
        assertTrue("Orientation was not set for camera " + cameraId, info.info.orientation != -1);
        Log.v(TAG, "Camera " + cameraId + " info: facing " + info.info.facing + ", orientation " + info.info.orientation);
    }
}
Also used : CameraInfo(android.hardware.CameraInfo) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

CameraInfo (android.hardware.CameraInfo)10 NonNull (android.annotation.NonNull)5 ICameraService (android.hardware.ICameraService)5 CameraMetadataNative (android.hardware.camera2.impl.CameraMetadataNative)5 RemoteException (android.os.RemoteException)5 ServiceSpecificException (android.os.ServiceSpecificException)5 SmallTest (android.test.suitebuilder.annotation.SmallTest)5