Search in sources :

Example 6 with ICameraDeviceUser

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

the class CameraDeviceImpl method setRemoteDevice.

/**
     * Set remote device, which triggers initial onOpened/onUnconfigured callbacks
     *
     * <p>This function may post onDisconnected and throw CAMERA_DISCONNECTED if remoteDevice dies
     * during setup.</p>
     *
     */
public void setRemoteDevice(ICameraDeviceUser remoteDevice) throws CameraAccessException {
    synchronized (mInterfaceLock) {
        // If setRemoteFailure already called, do nothing
        if (mInError)
            return;
        mRemoteDevice = new ICameraDeviceUserWrapper(remoteDevice);
        IBinder remoteDeviceBinder = remoteDevice.asBinder();
        // asBinder returns NULL.
        if (remoteDeviceBinder != null) {
            try {
                remoteDeviceBinder.linkToDeath(this, /*flag*/
                0);
            } catch (RemoteException e) {
                CameraDeviceImpl.this.mDeviceHandler.post(mCallOnDisconnected);
                throw new CameraAccessException(CameraAccessException.CAMERA_DISCONNECTED, "The camera device has encountered a serious error");
            }
        }
        mDeviceHandler.post(mCallOnOpened);
        mDeviceHandler.post(mCallOnUnconfigured);
    }
}
Also used : CameraAccessException(android.hardware.camera2.CameraAccessException) IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Example 7 with ICameraDeviceUser

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

the class CameraDeviceImpl method setRemoteDevice.

/**
     * Set remote device, which triggers initial onOpened/onUnconfigured callbacks
     *
     * <p>This function may post onDisconnected and throw CAMERA_DISCONNECTED if remoteDevice dies
     * during setup.</p>
     *
     */
public void setRemoteDevice(ICameraDeviceUser remoteDevice) throws CameraAccessException {
    synchronized (mInterfaceLock) {
        // If setRemoteFailure already called, do nothing
        if (mInError)
            return;
        mRemoteDevice = new ICameraDeviceUserWrapper(remoteDevice);
        IBinder remoteDeviceBinder = remoteDevice.asBinder();
        // asBinder returns NULL.
        if (remoteDeviceBinder != null) {
            try {
                remoteDeviceBinder.linkToDeath(this, /*flag*/
                0);
            } catch (RemoteException e) {
                CameraDeviceImpl.this.mDeviceHandler.post(mCallOnDisconnected);
                throw new CameraAccessException(CameraAccessException.CAMERA_DISCONNECTED, "The camera device has encountered a serious error");
            }
        }
        mDeviceHandler.post(mCallOnOpened);
        mDeviceHandler.post(mCallOnUnconfigured);
    }
}
Also used : CameraAccessException(android.hardware.camera2.CameraAccessException) IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Example 8 with ICameraDeviceUser

use of android.hardware.camera2.ICameraDeviceUser in project android_frameworks_base by AOSPA.

the class CameraDeviceImpl method setRemoteDevice.

/**
     * Set remote device, which triggers initial onOpened/onUnconfigured callbacks
     *
     * <p>This function may post onDisconnected and throw CAMERA_DISCONNECTED if remoteDevice dies
     * during setup.</p>
     *
     */
public void setRemoteDevice(ICameraDeviceUser remoteDevice) throws CameraAccessException {
    synchronized (mInterfaceLock) {
        // If setRemoteFailure already called, do nothing
        if (mInError)
            return;
        mRemoteDevice = new ICameraDeviceUserWrapper(remoteDevice);
        IBinder remoteDeviceBinder = remoteDevice.asBinder();
        // asBinder returns NULL.
        if (remoteDeviceBinder != null) {
            try {
                remoteDeviceBinder.linkToDeath(this, /*flag*/
                0);
            } catch (RemoteException e) {
                CameraDeviceImpl.this.mDeviceHandler.post(mCallOnDisconnected);
                throw new CameraAccessException(CameraAccessException.CAMERA_DISCONNECTED, "The camera device has encountered a serious error");
            }
        }
        mDeviceHandler.post(mCallOnOpened);
        mDeviceHandler.post(mCallOnUnconfigured);
    }
}
Also used : CameraAccessException(android.hardware.camera2.CameraAccessException) IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Example 9 with ICameraDeviceUser

use of android.hardware.camera2.ICameraDeviceUser in project android_frameworks_base by AOSPA.

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 10 with ICameraDeviceUser

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

the class CameraDeviceImpl method setRemoteDevice.

/**
     * Set remote device, which triggers initial onOpened/onUnconfigured callbacks
     *
     * <p>This function may post onDisconnected and throw CAMERA_DISCONNECTED if remoteDevice dies
     * during setup.</p>
     *
     */
public void setRemoteDevice(ICameraDeviceUser remoteDevice) throws CameraAccessException {
    synchronized (mInterfaceLock) {
        // If setRemoteFailure already called, do nothing
        if (mInError)
            return;
        mRemoteDevice = new ICameraDeviceUserWrapper(remoteDevice);
        IBinder remoteDeviceBinder = remoteDevice.asBinder();
        // asBinder returns NULL.
        if (remoteDeviceBinder != null) {
            try {
                remoteDeviceBinder.linkToDeath(this, /*flag*/
                0);
            } catch (RemoteException e) {
                CameraDeviceImpl.this.mDeviceHandler.post(mCallOnDisconnected);
                throw new CameraAccessException(CameraAccessException.CAMERA_DISCONNECTED, "The camera device has encountered a serious error");
            }
        }
        mDeviceHandler.post(mCallOnOpened);
        mDeviceHandler.post(mCallOnUnconfigured);
    }
}
Also used : CameraAccessException(android.hardware.camera2.CameraAccessException) IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Aggregations

CameraAccessException (android.hardware.camera2.CameraAccessException)5 ICameraDeviceCallbacks (android.hardware.camera2.ICameraDeviceCallbacks)5 ICameraDeviceUser (android.hardware.camera2.ICameraDeviceUser)5 IBinder (android.os.IBinder)5 RemoteException (android.os.RemoteException)5 SmallTest (android.test.suitebuilder.annotation.SmallTest)5