Search in sources :

Example 46 with SubmitInfo

use of android.hardware.camera2.utils.SubmitInfo in project android_frameworks_base by DirtyUnicorns.

the class CameraDeviceBinderTest method testWaitUntilIdle.

@SmallTest
public void testWaitUntilIdle() throws Exception {
    CaptureRequest.Builder builder = createDefaultBuilder(/* needStream */
    true);
    SubmitInfo requestInfoStreaming = submitCameraRequest(builder.build(), /* streaming */
    true);
    // Test Bad case first: waitUntilIdle when there is active repeating request
    try {
        mCameraUser.waitUntilIdle();
    } catch (ServiceSpecificException e) {
        assertEquals("waitUntilIdle is invalid operation when there is active repeating request", ICameraService.ERROR_INVALID_OPERATION, e.errorCode);
    }
    // Test good case, waitUntilIdle when there is no active repeating request
    long lastFrameNumber = mCameraUser.cancelRequest(requestInfoStreaming.getRequestId());
    mCameraUser.waitUntilIdle();
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) SubmitInfo(android.hardware.camera2.utils.SubmitInfo) CaptureRequest(android.hardware.camera2.CaptureRequest) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 47 with SubmitInfo

use of android.hardware.camera2.utils.SubmitInfo in project android_frameworks_base by AOSPA.

the class CameraDeviceBinderTest method testFlush.

@SmallTest
public void testFlush() throws Exception {
    int status;
    // Initial flush should work
    long lastFrameNumber = mCameraUser.flush();
    // Then set up a stream
    CaptureRequest request = createDefaultBuilder(/* needStream */
    true).build();
    // Flush should still be a no-op, really
    lastFrameNumber = mCameraUser.flush();
    // Submit a few capture requests
    SubmitInfo requestInfo1 = submitCameraRequest(request, /* streaming */
    false);
    SubmitInfo requestInfo2 = submitCameraRequest(request, /* streaming */
    false);
    SubmitInfo requestInfo3 = submitCameraRequest(request, /* streaming */
    false);
    SubmitInfo requestInfo4 = submitCameraRequest(request, /* streaming */
    false);
    SubmitInfo requestInfo5 = submitCameraRequest(request, /* streaming */
    false);
    // Then flush and wait for idle
    lastFrameNumber = mCameraUser.flush();
    verify(mMockCb, timeout(WAIT_FOR_FLUSH_TIMEOUT_MS).times(1)).onDeviceIdle();
    // Now a streaming request
    SubmitInfo streamingInfo = submitCameraRequest(request, /* streaming */
    true);
    // Wait a bit to fill up the queue
    SystemClock.sleep(WAIT_FOR_WORK_MS);
    // Then flush and wait for the idle callback
    lastFrameNumber = mCameraUser.flush();
    verify(mMockCb, timeout(WAIT_FOR_FLUSH_TIMEOUT_MS).times(2)).onDeviceIdle();
// TODO: When errors are hooked up, count that errors + successful
// requests equal to 5.
}
Also used : SubmitInfo(android.hardware.camera2.utils.SubmitInfo) CaptureRequest(android.hardware.camera2.CaptureRequest) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 48 with SubmitInfo

use of android.hardware.camera2.utils.SubmitInfo in project android_frameworks_base by AOSPA.

the class CameraDeviceBinderTest method testSubmitBadRequest.

@SmallTest
public void testSubmitBadRequest() throws Exception {
    CaptureRequest.Builder builder = createDefaultBuilder(/* needStream */
    false);
    CaptureRequest request1 = builder.build();
    try {
        SubmitInfo requestInfo = mCameraUser.submitRequest(request1, /* streaming */
        false);
        fail("Exception expected");
    } catch (ServiceSpecificException e) {
        assertEquals("Expected submitRequest to throw ServiceSpecificException with BAD_VALUE " + "since we had 0 surface targets set.", ICameraService.ERROR_ILLEGAL_ARGUMENT, e.errorCode);
    }
    builder.addTarget(mSurface);
    CaptureRequest request2 = builder.build();
    try {
        SubmitInfo requestInfo = mCameraUser.submitRequest(request2, /* streaming */
        false);
        fail("Exception expected");
    } catch (ServiceSpecificException e) {
        assertEquals("Expected submitRequest to throw ILLEGAL_ARGUMENT " + "ServiceSpecificException since the target wasn't registered with createStream.", ICameraService.ERROR_ILLEGAL_ARGUMENT, e.errorCode);
    }
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) SubmitInfo(android.hardware.camera2.utils.SubmitInfo) CaptureRequest(android.hardware.camera2.CaptureRequest) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 49 with SubmitInfo

use of android.hardware.camera2.utils.SubmitInfo in project android_frameworks_base by AOSPA.

the class CameraDeviceBinderTest method testSubmitStreamingRequest.

@SmallTest
public void testSubmitStreamingRequest() throws Exception {
    CaptureRequest.Builder builder = createDefaultBuilder(/* needStream */
    true);
    CaptureRequest request = builder.build();
    // Submit valid request once (non-streaming), and another time
    // (streaming)
    SubmitInfo requestInfo1 = submitCameraRequest(request, /* streaming */
    false);
    SubmitInfo requestInfoStreaming = submitCameraRequest(request, /* streaming */
    true);
    assertNotSame("Request IDs should be unique for multiple requests", requestInfo1.getRequestId(), requestInfoStreaming.getRequestId());
    try {
        long lastFrameNumber = mCameraUser.cancelRequest(-1);
        fail("Expected exception");
    } catch (ServiceSpecificException e) {
        assertEquals("Invalid request IDs should not be cancellable", ICameraService.ERROR_ILLEGAL_ARGUMENT, e.errorCode);
    }
    try {
        long lastFrameNumber = mCameraUser.cancelRequest(requestInfo1.getRequestId());
        fail("Expected exception");
    } catch (ServiceSpecificException e) {
        assertEquals("Non-streaming request IDs should not be cancellable", ICameraService.ERROR_ILLEGAL_ARGUMENT, e.errorCode);
    }
    long lastFrameNumber = mCameraUser.cancelRequest(requestInfoStreaming.getRequestId());
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) SubmitInfo(android.hardware.camera2.utils.SubmitInfo) CaptureRequest(android.hardware.camera2.CaptureRequest) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 50 with SubmitInfo

use of android.hardware.camera2.utils.SubmitInfo in project android_frameworks_base by AOSPA.

the class CameraDeviceBinderTest method testSubmitGoodRequest.

@SmallTest
public void testSubmitGoodRequest() throws Exception {
    CaptureRequest.Builder builder = createDefaultBuilder(/* needStream */
    true);
    CaptureRequest request = builder.build();
    // Submit valid request twice.
    SubmitInfo requestInfo1 = submitCameraRequest(request, /* streaming */
    false);
    SubmitInfo requestInfo2 = submitCameraRequest(request, /* streaming */
    false);
    assertNotSame("Request IDs should be unique for multiple requests", requestInfo1.getRequestId(), requestInfo2.getRequestId());
}
Also used : SubmitInfo(android.hardware.camera2.utils.SubmitInfo) CaptureRequest(android.hardware.camera2.CaptureRequest) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

SubmitInfo (android.hardware.camera2.utils.SubmitInfo)55 CaptureRequest (android.hardware.camera2.CaptureRequest)45 SmallTest (android.test.suitebuilder.annotation.SmallTest)35 ServiceSpecificException (android.os.ServiceSpecificException)20 Surface (android.view.Surface)10 CaptureResultExtras (android.hardware.camera2.impl.CaptureResultExtras)5 Handler (android.os.Handler)5 ArrayList (java.util.ArrayList)5