Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6192b892 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala
Browse files

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
parent b06b9dfc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -147,12 +147,12 @@ status_t CameraClient::checkPid() const {
}

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;
}

+4 −0
Original line number Diff line number Diff line
@@ -1050,6 +1050,10 @@ void CameraDeviceClient::onResultAvailable(const CaptureResult& result) {
}

binder::Status CameraDeviceClient::checkPidStatus(const char* checkLocation) {
    if (mDisconnected) {
        return STATUS_ERROR(CameraService::ERROR_DISCONNECTED,
                "The camera device has been disconnected");
    }
    status_t res = checkPid(checkLocation);
    return (res == OK) ? binder::Status::ok() :
            STATUS_ERROR(CameraService::ERROR_PERMISSION_DENIED,