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

Commit 3be63a3f authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Implement legacy device stream combination query

Use the legacy stream configuration logic to check for
support of a given session configuration.

Bug: 111593096
Test:
runtest -x
cts/tests/camera/src/android/hardware/camera2/cts/MultiViewTest.java
runtest -x
cts/tests/camera/src/android/hardware/camera2/cts/RobustnessTest.java -m
testMandatoryOutputCombinations
runtest -x
cts/tests/camera/src/android/hardware/camera2/cts/RobustnessTest.java -m
testBadSurfaceDimensions
runtest -x
cts/tests/camera/src/android/hardware/camera2/cts/RobustnessTest.java -m
testMandatoryReprocessConfigurations
runtest -x
cts/tests/camera/src/android/hardware/camera2/cts/SurfaceViewPreviewTest.java
-m testDeferredSurfaces

Change-Id: I921f94be8212a55fa90150cb35ea06e488dc0b29
parent 275da0ba
Loading
Loading
Loading
Loading
+32 −2
Original line number Diff line number Diff line
@@ -484,8 +484,38 @@ public class CameraDeviceUserShim implements ICameraDeviceUser {

    @Override
    public boolean isSessionConfigurationSupported(SessionConfiguration sessionConfig) {
        // TODO: Add support for this in legacy mode
        throw new UnsupportedOperationException("Session configuration query not supported!");
        if (sessionConfig.getSessionType() != SessionConfiguration.SESSION_REGULAR) {
            Log.e(TAG, "Session type: " + sessionConfig.getSessionType() + " is different from " +
                    " regular. Legacy devices support only regular session types!");
            return false;
        }

        if (sessionConfig.getInputConfiguration() != null) {
            Log.e(TAG, "Input configuration present, legacy devices do not support this feature!");
            return false;
        }

        List<OutputConfiguration> outputConfigs = sessionConfig.getOutputConfigurations();
        if (outputConfigs.isEmpty()) {
            Log.e(TAG, "Empty output configuration list!");
            return false;
        }

        SparseArray<Surface> surfaces = new SparseArray<Surface>(outputConfigs.size());
        int idx = 0;
        for (OutputConfiguration outputConfig : outputConfigs) {
            List<Surface> surfaceList = outputConfig.getSurfaces();
            if (surfaceList.isEmpty() || (surfaceList.size() > 1)) {
                Log.e(TAG, "Legacy devices do not support deferred or shared surfaces!");
                return false;
            }

            surfaces.put(idx++, outputConfig.getSurface());
        }

        int ret = mLegacyDevice.configureOutputs(surfaces, /*validateSurfacesOnly*/true);

        return ret == LegacyExceptionUtils.NO_ERROR;
    }

    @Override
+26 −1
Original line number Diff line number Diff line
@@ -346,6 +346,25 @@ public class LegacyCameraDevice implements AutoCloseable {
     *          on success.
     */
    public int configureOutputs(SparseArray<Surface> outputs) {
        return configureOutputs(outputs, /*validateSurfacesOnly*/false);
    }

    /**
     * Configure the device with a set of output surfaces.
     *
     * <p>Using empty or {@code null} {@code outputs} is the same as unconfiguring.</p>
     *
     * <p>Every surface in {@code outputs} must be non-{@code null}.</p>
     *
     * @param outputs a list of surfaces to set. LegacyCameraDevice will take ownership of this
     *          list; it must not be modified by the caller once it's passed in.
     * @param validateSurfacesOnly If set it will only check whether the outputs are supported
     *                             and avoid any device configuration.
     * @return an error code for this binder operation, or {@link NO_ERROR}
     *          on success.
     * @hide
     */
    public int configureOutputs(SparseArray<Surface> outputs, boolean validateSurfacesOnly) {
        List<Pair<Surface, Size>> sizedSurfaces = new ArrayList<>();
        if (outputs != null) {
            int count = outputs.size();
@@ -397,7 +416,9 @@ public class LegacyCameraDevice implements AutoCloseable {
                        sizedSurfaces.add(new Pair<>(output, s));
                    }
                    // Lock down the size before configuration
                    if (!validateSurfacesOnly) {
                        setSurfaceDimens(output, s.getWidth(), s.getHeight());
                    }
                } catch (BufferQueueAbandonedException e) {
                    Log.e(TAG, "Surface bufferqueue is abandoned, cannot configure as output: ", e);
                    return BAD_VALUE;
@@ -406,6 +427,10 @@ public class LegacyCameraDevice implements AutoCloseable {
            }
        }

        if (validateSurfacesOnly) {
            return LegacyExceptionUtils.NO_ERROR;
        }

        boolean success = false;
        if (mDeviceState.setConfiguring()) {
            mRequestThreadManager.configure(sizedSurfaces);