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

Commit 876e6afd authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Disallow concurrent extension sessions

Support for concurrent extension processing sessions
is not yet mandated. To avoid inconsistent behavior
across devices, explicitly document and disallow
concurrent extension sessions at the framework level.

Bug: 187341271
Test: Manual using test application,
Camera CTS

Change-Id: Ibff194c58bbb37e884c27151a2a27fb21e3db928
parent c46c9e64
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.graphics.ImageFormat;
import android.hardware.camera2.extension.IAdvancedExtenderImpl;
import android.hardware.camera2.extension.ICameraExtensionsProxyService;
import android.hardware.camera2.extension.IImageCaptureExtenderImpl;
import android.hardware.camera2.extension.IInitializeSessionCallback;
import android.hardware.camera2.extension.IPreviewExtenderImpl;
import android.hardware.camera2.extension.LatencyRange;
import android.hardware.camera2.extension.SizeList;
@@ -357,6 +358,27 @@ public final class CameraExtensionCharacteristics {
            }
        }

        public void initializeSession(IInitializeSessionCallback cb) throws RemoteException {
            synchronized (mLock) {
                if (mProxy != null) {
                    mProxy.initializeSession(cb);
                }
            }
        }

        public void releaseSession() {
            synchronized (mLock) {
                if (mProxy != null) {
                    try {
                        mProxy.releaseSession();
                    } catch (RemoteException e) {
                        Log.e(TAG, "Failed to release session! Extension service does"
                                + " not respond!");
                    }
                }
            }
        }

        public boolean areAdvancedExtensionsSupported() {
            return mSupportsAdvancedExtensions;
        }
@@ -409,6 +431,20 @@ public final class CameraExtensionCharacteristics {
        CameraExtensionManagerGlobal.get().unregisterClient(clientId);
    }

    /**
     * @hide
     */
    public static void initializeSession(IInitializeSessionCallback cb) throws RemoteException {
        CameraExtensionManagerGlobal.get().initializeSession(cb);
    }

    /**
     * @hide
     */
    public static void releaseSession() {
        CameraExtensionManagerGlobal.get().releaseSession();
    }

    /**
     * @hide
     */
+3 −2
Original line number Diff line number Diff line
@@ -195,8 +195,9 @@ public abstract class CameraExtensionSession implements AutoCloseable {
         * This method is called if the session cannot be configured as requested.
         *
         * <p>This can happen if the set of requested outputs contains unsupported sizes,
         * too many outputs are requested at once or the camera device encounters an
         * unrecoverable error during configuration.</p>
         * too many outputs are requested at once or when trying to initialize multiple
         * concurrent extension sessions from two (or more) separate camera devices
         * or the camera device encounters an unrecoverable error during configuration.</p>
         *
         * <p>The session is considered to be closed, and all methods called on it after this
         * callback is invoked will throw an IllegalStateException.</p>
+3 −0
Original line number Diff line number Diff line
@@ -162,6 +162,9 @@ public final class CameraManager {
     * <p>The set of combinations may include camera devices that may be in use by other camera API
     * clients.</p>
     *
     * <p>Concurrent camera extension sessions {@link CameraExtensionSession} are not currently
     * supported.</p>
     *
     * <p>The set of combinations doesn't contain physical cameras that can only be used as
     * part of a logical multi-camera device.</p>
     *
+3 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.hardware.camera2.extension;
import android.hardware.camera2.extension.IAdvancedExtenderImpl;
import android.hardware.camera2.extension.IPreviewExtenderImpl;
import android.hardware.camera2.extension.IImageCaptureExtenderImpl;
import android.hardware.camera2.extension.IInitializeSessionCallback;

/** @hide */
interface ICameraExtensionsProxyService
@@ -25,6 +26,8 @@ interface ICameraExtensionsProxyService
    long registerClient();
    void unregisterClient(long clientId);
    boolean advancedExtensionsSupported();
    void initializeSession(in IInitializeSessionCallback cb);
    void releaseSession();
    @nullable IPreviewExtenderImpl initializePreviewExtension(int extensionType);
    @nullable IImageCaptureExtenderImpl initializeImageExtension(int extensionType);
    @nullable IAdvancedExtenderImpl initializeAdvancedExtension(int extensionType);
+23 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2021, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.hardware.camera2.extension;

/** @hide */
interface IInitializeSessionCallback
{
    void onSuccess();
    void onFailure();
}
Loading