Camera: Fix openLegacy error codes
Fix error handling regressions from the Binder interface refactor
- Error codes from openLegacy became incorrect
- Client initialize() call error codes were not discriminated between
Bug: 27657269
Change-Id: I2379d45d5fe5c2ad43c78bcfd18ea4c833adc987
diff --git a/camera/Camera.cpp b/camera/Camera.cpp
index 8d7a107..c52e581 100644
--- a/camera/Camera.cpp
+++ b/camera/Camera.cpp
@@ -98,9 +98,37 @@
c->mStatus = NO_ERROR;
camera = c;
} else {
- ALOGW("An error occurred while connecting to camera %d: %s", cameraId,
- (cs != nullptr) ? "Service not available" : ret.toString8().string());
- status = -EINVAL;
+ switch(ret.serviceSpecificErrorCode()) {
+ case hardware::ICameraService::ERROR_DISCONNECTED:
+ status = -ENODEV;
+ break;
+ case hardware::ICameraService::ERROR_CAMERA_IN_USE:
+ status = -EBUSY;
+ break;
+ case hardware::ICameraService::ERROR_INVALID_OPERATION:
+ status = -EINVAL;
+ break;
+ case hardware::ICameraService::ERROR_MAX_CAMERAS_IN_USE:
+ status = -EUSERS;
+ break;
+ case hardware::ICameraService::ERROR_ILLEGAL_ARGUMENT:
+ status = BAD_VALUE;
+ break;
+ case hardware::ICameraService::ERROR_DEPRECATED_HAL:
+ status = -EOPNOTSUPP;
+ break;
+ case hardware::ICameraService::ERROR_DISABLED:
+ status = -EACCES;
+ break;
+ case hardware::ICameraService::ERROR_PERMISSION_DENIED:
+ status = PERMISSION_DENIED;
+ break;
+ default:
+ status = -EINVAL;
+ ALOGW("An error occurred while connecting to camera %d: %s", cameraId,
+ (cs != nullptr) ? "Service not available" : ret.toString8().string());
+ break;
+ }
c.clear();
}
return status;