Merge "camera2: Remove CameraAccessException throw for vendor tag setup."

This commit is contained in:
Ruben Brunk
2014-05-24 02:03:50 +00:00
committed by Android (Google) Code Review
2 changed files with 18 additions and 4 deletions

View File

@@ -114,7 +114,10 @@ public class CameraAccessException extends AndroidException {
mReason = problem;
}
private static String getDefaultMessage(int problem) {
/**
* @hide
*/
public static String getDefaultMessage(int problem) {
switch (problem) {
case CAMERA_IN_USE:
return "The camera device is in use already";

View File

@@ -84,9 +84,8 @@ public final class CameraManager {
try {
CameraBinderDecorator.throwOnError(
CameraMetadataNative.nativeSetupGlobalVendorTagDescriptor());
} catch(CameraRuntimeException e) {
throw new IllegalStateException("Failed to setup camera vendor tags",
e.asChecked());
} catch (CameraRuntimeException e) {
handleRecoverableSetupErrors(e, "Failed to set up vendor tags");
}
try {
@@ -424,6 +423,18 @@ public final class CameraManager {
return mDeviceIdList;
}
private void handleRecoverableSetupErrors(CameraRuntimeException e, String msg) {
int problem = e.getReason();
switch (problem) {
case CameraAccessException.CAMERA_DISCONNECTED:
String errorMsg = CameraAccessException.getDefaultMessage(problem);
Log.w(TAG, msg + ": " + errorMsg);
break;
default:
throw new IllegalStateException(msg, e.asChecked());
}
}
// TODO: this class needs unit tests
// TODO: extract class into top level
private class CameraServiceListener extends ICameraServiceListener.Stub {