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

Commit f6463fc6 authored by Chien-Yu Chen's avatar Chien-Yu Chen
Browse files

camera2: remove unnecessary flashlight error messages

Bug: 20069129
Change-Id: I0e721bfad1f0218744d3554397e3ec9b8bc07a19
parent 32495581
Loading
Loading
Loading
Loading
+18 −15
Original line number Original line Diff line number Diff line
@@ -299,12 +299,11 @@ void CameraService::onTorchStatusChangedLocked(const String8& cameraId,
    ICameraServiceListener::TorchStatus status;
    ICameraServiceListener::TorchStatus status;
    status_t res = getTorchStatusLocked(cameraId, &status);
    status_t res = getTorchStatusLocked(cameraId, &status);
    if (res) {
    if (res) {
        ALOGE("%s: cannot get torch status of camera %s", cameraId.string());
        ALOGE("%s: cannot get torch status of camera %s: %s (%d)",
                __FUNCTION__, cameraId.string(), strerror(-res), res);
        return;
        return;
    }
    }
    if (status == newStatus) {
    if (status == newStatus) {
        ALOGE("%s: Torch state transition to the same status 0x%x not allowed",
              __FUNCTION__, (uint32_t)newStatus);
        return;
        return;
    }
    }


@@ -1139,14 +1138,14 @@ status_t CameraService::setTorchMode(const String16& cameraId, bool enabled,
    // verify id is valid.
    // verify id is valid.
    auto state = getCameraState(id);
    auto state = getCameraState(id);
    if (state == nullptr) {
    if (state == nullptr) {
        ALOGE("%s: camera id is invalid %s", id.string());
        ALOGE("%s: camera id is invalid %s", __FUNCTION__, id.string());
        return -EINVAL;
        return -EINVAL;
    }
    }


    ICameraServiceListener::Status cameraStatus = state->getStatus();
    ICameraServiceListener::Status cameraStatus = state->getStatus();
    if (cameraStatus != ICameraServiceListener::STATUS_PRESENT &&
    if (cameraStatus != ICameraServiceListener::STATUS_PRESENT &&
            cameraStatus != ICameraServiceListener::STATUS_NOT_AVAILABLE) {
            cameraStatus != ICameraServiceListener::STATUS_NOT_AVAILABLE) {
        ALOGE("%s: camera id is invalid %s", id.string());
        ALOGE("%s: camera id is invalid %s", __FUNCTION__, id.string());
        return -EINVAL;
        return -EINVAL;
    }
    }


@@ -2204,16 +2203,20 @@ void CameraService::updateStatus(ICameraServiceListener::Status status, const St
    state->updateStatus(status, cameraId, rejectSourceStates, [this]
    state->updateStatus(status, cameraId, rejectSourceStates, [this]
            (const String8& cameraId, ICameraServiceListener::Status status) {
            (const String8& cameraId, ICameraServiceListener::Status status) {


            // Update torch status
            if (status != ICameraServiceListener::STATUS_ENUMERATING) {
            if (status == ICameraServiceListener::STATUS_NOT_PRESENT ||
                // Update torch status if it has a flash unit.
                status == ICameraServiceListener::STATUS_NOT_AVAILABLE) {
                Mutex::Autolock al(mTorchStatusMutex);
                // Update torch status to not available when the camera device becomes not present
                ICameraServiceListener::TorchStatus torchStatus;
                // or not available.
                if (getTorchStatusLocked(cameraId, &torchStatus) !=
                onTorchStatusChanged(cameraId, ICameraServiceListener::TORCH_STATUS_NOT_AVAILABLE);
                        NAME_NOT_FOUND) {
            } else if (status == ICameraServiceListener::STATUS_PRESENT) {
                    ICameraServiceListener::TorchStatus newTorchStatus =
                // Update torch status to available when the camera device becomes present or
                            status == ICameraServiceListener::STATUS_PRESENT ?
                // available
                            ICameraServiceListener::TORCH_STATUS_AVAILABLE_OFF :
                onTorchStatusChanged(cameraId, ICameraServiceListener::TORCH_STATUS_AVAILABLE_OFF);
                            ICameraServiceListener::TORCH_STATUS_NOT_AVAILABLE;
                    if (torchStatus != newTorchStatus) {
                        onTorchStatusChangedLocked(cameraId, newTorchStatus);
                    }
                }
            }
            }


            Mutex::Autolock lock(mStatusListenerLock);
            Mutex::Autolock lock(mStatusListenerLock);