use of android.os.ServiceSpecificException in project android_frameworks_base by AOSPA.
the class CameraDeviceUserShim method createDefaultRequest.
@Override
public CameraMetadataNative createDefaultRequest(int templateId) {
if (DEBUG) {
Log.d(TAG, "createDefaultRequest called.");
}
if (mLegacyDevice.isClosed()) {
String err = "Cannot create default request, device has been closed.";
Log.e(TAG, err);
throw new ServiceSpecificException(ICameraService.ERROR_DISCONNECTED, err);
}
CameraMetadataNative template;
try {
template = LegacyMetadataMapper.createRequestTemplate(mCameraCharacteristics, templateId);
} catch (IllegalArgumentException e) {
String err = "createDefaultRequest - invalid templateId specified";
Log.e(TAG, err);
throw new ServiceSpecificException(ICameraService.ERROR_ILLEGAL_ARGUMENT, err);
}
return template;
}
use of android.os.ServiceSpecificException in project android_frameworks_base by ResurrectionRemix.
the class CameraBinderTest method testAddRemoveListeners.
/**
* <pre>
* adb shell am instrument \
* -e class 'com.android.mediaframeworktest.integration.CameraBinderTest#testAddRemoveListeners' \
* -w com.android.mediaframeworktest/.MediaFrameworkIntegrationTestRunner
* </pre>
*/
@SmallTest
public void testAddRemoveListeners() throws Exception {
for (int cameraId = 0; cameraId < mUtils.getGuessedNumCameras(); ++cameraId) {
ICameraServiceListener listener = new DummyCameraServiceListener();
try {
mUtils.getCameraService().removeListener(listener);
fail("Listener was removed before added");
} catch (ServiceSpecificException e) {
assertEquals("Listener was removed before added", e.errorCode, ICameraService.ERROR_ILLEGAL_ARGUMENT);
}
mUtils.getCameraService().addListener(listener);
try {
mUtils.getCameraService().addListener(listener);
fail("Listener was wrongly added again");
} catch (ServiceSpecificException e) {
assertEquals("Listener was wrongly added again", e.errorCode, ICameraService.ERROR_ALREADY_EXISTS);
}
mUtils.getCameraService().removeListener(listener);
try {
mUtils.getCameraService().removeListener(listener);
fail("Listener was wrongly removed twice");
} catch (ServiceSpecificException e) {
assertEquals("Listener was wrongly removed twice", e.errorCode, ICameraService.ERROR_ILLEGAL_ARGUMENT);
}
}
}
use of android.os.ServiceSpecificException in project android_frameworks_base by ResurrectionRemix.
the class CameraDeviceBinderTest method testCreateStreamTwo.
@SmallTest
public void testCreateStreamTwo() throws Exception {
// Create first stream
int streamId = mCameraUser.createStream(mOutputConfiguration);
assertEquals(0, streamId);
try {
mCameraUser.createStream(mOutputConfiguration);
fail("Created same stream twice");
} catch (ServiceSpecificException e) {
assertEquals("Created same stream twice", ICameraService.ERROR_ALREADY_EXISTS, e.errorCode);
}
// Create second stream with a different surface.
SurfaceTexture surfaceTexture = new SurfaceTexture(/* ignored */
0);
surfaceTexture.setDefaultBufferSize(640, 480);
Surface surface2 = new Surface(surfaceTexture);
OutputConfiguration output2 = new OutputConfiguration(surface2);
int streamId2 = mCameraUser.createStream(output2);
assertEquals(1, streamId2);
// Clean up streams
mCameraUser.deleteStream(streamId);
mCameraUser.deleteStream(streamId2);
}
use of android.os.ServiceSpecificException 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);
}
use of android.os.ServiceSpecificException in project android_frameworks_base by ResurrectionRemix.
the class CameraDeviceUserShim method createDefaultRequest.
@Override
public CameraMetadataNative createDefaultRequest(int templateId) {
if (DEBUG) {
Log.d(TAG, "createDefaultRequest called.");
}
if (mLegacyDevice.isClosed()) {
String err = "Cannot create default request, device has been closed.";
Log.e(TAG, err);
throw new ServiceSpecificException(ICameraService.ERROR_DISCONNECTED, err);
}
CameraMetadataNative template;
try {
template = LegacyMetadataMapper.createRequestTemplate(mCameraCharacteristics, templateId);
} catch (IllegalArgumentException e) {
String err = "createDefaultRequest - invalid templateId specified";
Log.e(TAG, err);
throw new ServiceSpecificException(ICameraService.ERROR_ILLEGAL_ARGUMENT, err);
}
return template;
}
Aggregations