From 4991ba70c93c792ca50cb613071adff01461ea8c Mon Sep 17 00:00:00 2001 From: Yin-Chia Yeh Date: Wed, 9 Dec 2020 15:57:31 -0800 Subject: [PATCH] Camera: improve session.close documentation Added descriptio about preferred way to close camera faster. Test: build (doc only update) Bug: 175104220 Change-Id: I750b57afab65b4e77fff6ef79ec64dcebe74e47f --- .../android/hardware/camera2/CameraCaptureSession.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/java/android/hardware/camera2/CameraCaptureSession.java b/core/java/android/hardware/camera2/CameraCaptureSession.java index e8581595ad916..bd47463698110 100644 --- a/core/java/android/hardware/camera2/CameraCaptureSession.java +++ b/core/java/android/hardware/camera2/CameraCaptureSession.java @@ -964,12 +964,20 @@ public abstract class CameraCaptureSession implements AutoCloseable { *

Closing a session frees up the target output Surfaces of the session for reuse with either * a new session, or to other APIs that can draw to Surfaces.

* - *

Note that creating a new capture session with {@link CameraDevice#createCaptureSession} + *

Note that for common usage scenarios like creating a new session or closing the camera + * device, it is faster to call respective APIs directly (see below for more details) without + * calling into this method. This API is only useful when application wants to uncofigure the + * camera but keep the device open for later use.

+ * + *

Creating a new capture session with {@link CameraDevice#createCaptureSession} * will close any existing capture session automatically, and call the older session listener's * {@link StateCallback#onClosed} callback. Using {@link CameraDevice#createCaptureSession} * directly without closing is the recommended approach for quickly switching to a new session, * since unchanged target outputs can be reused more efficiently.

* + *

Closing the device with {@link CameraDevice#close} directly without calling this API is + * also recommended for quickly closing the camera.

+ * *

Once a session is closed, all methods on it will throw an IllegalStateException, and any * repeating requests or bursts are stopped (as if {@link #stopRepeating()} was called). * However, any in-progress capture requests submitted to the session will be completed as