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

Commit 11a68483 authored by Jyoti Bhayana's avatar Jyoti Bhayana
Browse files

Fixing test failures im SharedCameraTest.

Fixing following issues found during test failure for
testSharedSessionUnsupportedOperations:

1) Fixing the issue of device lock not being released when
unsupported operations error occur.
2) adding the check in create session ndk call to return error if
the output configuration has sharing enabled.
3) removing the shared surfaces from the splitter when the shared client disconnects.

Flag: com.android.internal.camera.flags.camera_multi_client
Bug: 394083987
Test: run CTS test testSharedSessionUnsupportedOperations
Change-Id: If893afd206eb2a418724979dc3ad2e6bcf905d27
parent c9c7d934
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ ACameraCaptureSession::stopRepeating() {
    dev->lockDeviceForSessionOps();
    {
        if (dev->isSharedMode() && !dev->isPrimaryClient()) {
            dev->unlockDevice();
            return ACAMERA_ERROR_UNSUPPORTED_OPERATION;
        }
        Mutex::Autolock _l(mSessionLock);
@@ -138,11 +139,11 @@ ACameraCaptureSession::abortCaptures() {
        ALOGE("Error: Device associated with session %p has been closed!", this);
        return ACAMERA_ERROR_SESSION_CLOSED;
    }

    camera_status_t ret;
    dev->lockDeviceForSessionOps();
    {
        if (dev->isSharedMode() && !dev->isPrimaryClient()) {
            dev->unlockDevice();
            return ACAMERA_ERROR_UNSUPPORTED_OPERATION;
        }
        Mutex::Autolock _l(mSessionLock);
@@ -167,6 +168,7 @@ camera_status_t ACameraCaptureSession::updateOutputConfiguration(ACaptureSession
    dev->lockDeviceForSessionOps();
    {
        if (dev->isSharedMode()) {
            dev->unlockDevice();
            return ACAMERA_ERROR_UNSUPPORTED_OPERATION;
        }
        Mutex::Autolock _l(mSessionLock);
@@ -191,6 +193,7 @@ camera_status_t ACameraCaptureSession::prepare(ANativeWindow* window) {
    dev->lockDeviceForSessionOps();
    {
        if (dev->isSharedMode()) {
            dev->unlockDevice();
            return ACAMERA_ERROR_UNSUPPORTED_OPERATION;
        }
        Mutex::Autolock _l(mSessionLock);
+5 −0
Original line number Diff line number Diff line
@@ -711,6 +711,11 @@ CameraDevice::configureStreamsLocked(const ACaptureSessionOutputContainer* outpu
        if (ret != ACAMERA_OK) {
            return ret;
        }
        // Surface sharing cannot be enabled when a camera has been opened
        // in shared mode.
        if (flags::camera_multi_client() && mSharedMode && outConfig.mIsShared) {
            return ACAMERA_ERROR_INVALID_PARAMETER;
        }
        ParcelableSurfaceType pSurface = flagtools::convertSurfaceTypeToParcelable(surface);
        outputSet.insert(std::make_pair(
                anw,
+20 −0
Original line number Diff line number Diff line
@@ -2485,6 +2485,26 @@ void CameraDeviceClient::detachDevice() {
                    camera2::FrameProcessorBase::FRAME_PROCESSOR_LISTENER_MIN_ID,
                    camera2::FrameProcessorBase::FRAME_PROCESSOR_LISTENER_MAX_ID, /*listener*/this);
    }

    if (flags::camera_multi_client() && mSharedMode) {
        for (auto streamInfo : mStreamInfoMap) {
            int streamToDelete = streamInfo.first;
            std::vector<size_t> removedSurfaceIds;
            for (size_t i = 0; i < mStreamMap.size(); ++i) {
                if (streamToDelete == mStreamMap.valueAt(i).streamId()) {
                    removedSurfaceIds.push_back(mStreamMap.valueAt(i).surfaceId());
                }
            }
            status_t err = mDevice->removeSharedSurfaces(streamToDelete, removedSurfaceIds);
            if (err != OK) {
                std::string msg = fmt::sprintf("Camera %s: Unexpected error %s (%d) when removing"
                        "shared surfaces from stream %d", mCameraIdStr.c_str(), strerror(-err),
                        err, streamToDelete);
                ALOGE("%s: %s", __FUNCTION__, msg.c_str());
            }
        }
    }

    if (!flags::camera_multi_client() || !mSharedMode ||
            (mSharedMode && sCameraService->isOnlyClient(this))){
        ALOGV("Camera %s: Stopping processors", mCameraIdStr.c_str());