Camera: Ensure correct error message for disconnected devices
After a device has been disconnected, should return consistent errors
to the caller if they invoke further device methods.
For API1, that's INVALID_OPERATION, and for API2, that's
ERROR_DISCONNECTED.
Change-Id: I0f3d889906a9818c0e03852702b146fd33c9e42a
Fixes: 27591189
diff --git a/services/camera/libcameraservice/api1/CameraClient.cpp b/services/camera/libcameraservice/api1/CameraClient.cpp
index 1086340..d2fedf8 100644
--- a/services/camera/libcameraservice/api1/CameraClient.cpp
+++ b/services/camera/libcameraservice/api1/CameraClient.cpp
@@ -147,12 +147,12 @@
}
status_t CameraClient::checkPidAndHardware() const {
- status_t result = checkPid();
- if (result != NO_ERROR) return result;
if (mHardware == 0) {
ALOGE("attempt to use a camera after disconnect() (pid %d)", getCallingPid());
return INVALID_OPERATION;
}
+ status_t result = checkPid();
+ if (result != NO_ERROR) return result;
return NO_ERROR;
}