Merge "camera2: Remove CameraAccessException throw for vendor tag setup."
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user