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

Commit ca5ffee3 authored by Emilian Peev's avatar Emilian Peev Committed by android-build-merger
Browse files

Camera: Camera shouldn't throw 'RejectedExecutionException'

am: b9a5194e

Change-Id: Ic4dd87d89f91822fce82c5ca27632f69716279e5
parents f18ec573 b9a5194e
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.hardware.camera2.impl;

import static com.android.internal.util.function.pooled.PooledLambda.obtainRunnable;

import android.annotation.NonNull;
import android.hardware.ICameraService;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
@@ -38,7 +39,6 @@ import android.hardware.camera2.utils.SurfaceUtils;
import android.os.Binder;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
@@ -49,6 +49,8 @@ import android.util.Size;
import android.util.SparseArray;
import android.view.Surface;

import com.android.internal.util.Preconditions;

import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.Collection;
@@ -2292,6 +2294,27 @@ public class CameraDeviceImpl extends CameraDevice

    } // public class CameraDeviceCallbacks

    /**
     * A camera specific adapter {@link Executor} that posts all executed tasks onto the given
     * {@link Handler}.
     *
     * @hide
     */
    private static class CameraHandlerExecutor implements Executor {
        private final Handler mHandler;

        public CameraHandlerExecutor(@NonNull Handler handler) {
            mHandler = Preconditions.checkNotNull(handler);
        }

        @Override
        public void execute(Runnable command) {
            // Return value of 'post()' will be ignored in order to keep the
            // same camera behavior. For further details see b/74605221 .
            mHandler.post(command);
        }
    }

    /**
     * Instantiate a new Executor.
     *
@@ -2304,7 +2327,7 @@ public class CameraDeviceImpl extends CameraDevice
        }

        if (handler != null) {
            return new HandlerExecutor(handler);
            return new CameraHandlerExecutor(handler);
        }

        return null;
@@ -2320,7 +2343,7 @@ public class CameraDeviceImpl extends CameraDevice
     * </p>
     */
    static Executor checkAndWrapHandler(Handler handler) {
        return new HandlerExecutor(checkHandler(handler));
        return new CameraHandlerExecutor(checkHandler(handler));
    }

    /**