Close ImageProxy in ImageAnalysis tests
The opened ImageProxy causes the CameraDevice#close() will be sutck.
Close the ImageProxy immediately to prevent the closing of the
CameraDevice from being stuck.
Bug: 267590298
Test: Camera2CameraControlDeviceTest, Camera2InteropIntegrationTest
CameraControlAdapterDeviceTest, EvCompDeviceTest on Nexus 5
Change-Id: Ib9db3274ff55b70b5fc4d730d0a9566436ba3c6e
diff --git a/camera/camera-camera2-pipe-integration/src/androidTest/java/androidx/camera/camera2/pipe/integration/Camera2CameraControlDeviceTest.kt b/camera/camera-camera2-pipe-integration/src/androidTest/java/androidx/camera/camera2/pipe/integration/Camera2CameraControlDeviceTest.kt
index 95ed3c0..2ce4722 100644
--- a/camera/camera-camera2-pipe-integration/src/androidTest/java/androidx/camera/camera2/pipe/integration/Camera2CameraControlDeviceTest.kt
+++ b/camera/camera-camera2-pipe-integration/src/androidTest/java/androidx/camera/camera2/pipe/integration/Camera2CameraControlDeviceTest.kt
@@ -404,7 +404,9 @@
}.build().apply {
// set analyzer to make it active.
setAnalyzer(Dispatchers.Default.asExecutor()) {
- // Fake analyzer, do nothing.
+ // Fake analyzer, do nothing. Close the ImageProxy immediately to prevent the
+ // closing of the CameraDevice from being stuck.
+ it.close()
}
}
@@ -477,7 +479,9 @@
useCase: UseCase = ImageAnalysis.Builder().build().apply {
// set analyzer to make it active.
setAnalyzer(Dispatchers.Default.asExecutor()) {
- // Fake analyzer, do nothing.
+ // Fake analyzer, do nothing. Close the ImageProxy immediately to prevent the
+ // closing of the CameraDevice from being stuck.
+ it.close()
}
}
) {
diff --git a/camera/camera-camera2-pipe-integration/src/androidTest/java/androidx/camera/camera2/pipe/integration/CameraControlAdapterDeviceTest.kt b/camera/camera-camera2-pipe-integration/src/androidTest/java/androidx/camera/camera2/pipe/integration/CameraControlAdapterDeviceTest.kt
index a9e2aeb..10e7fc0 100644
--- a/camera/camera-camera2-pipe-integration/src/androidTest/java/androidx/camera/camera2/pipe/integration/CameraControlAdapterDeviceTest.kt
+++ b/camera/camera-camera2-pipe-integration/src/androidTest/java/androidx/camera/camera2/pipe/integration/CameraControlAdapterDeviceTest.kt
@@ -111,7 +111,9 @@
private val imageAnalysis = ImageAnalysis.Builder().build().apply {
// set analyzer to make it active.
setAnalyzer(Dispatchers.Default.asExecutor()) {
- // Fake analyzer, do nothing.
+ // Fake analyzer, do nothing. Close the ImageProxy immediately to prevent the closing
+ // of the CameraDevice from being stuck.
+ it.close()
}
}
diff --git a/camera/camera-camera2-pipe-integration/src/androidTest/java/androidx/camera/camera2/pipe/integration/EvCompDeviceTest.kt b/camera/camera-camera2-pipe-integration/src/androidTest/java/androidx/camera/camera2/pipe/integration/EvCompDeviceTest.kt
index b1781dd..fe02a63 100644
--- a/camera/camera-camera2-pipe-integration/src/androidTest/java/androidx/camera/camera2/pipe/integration/EvCompDeviceTest.kt
+++ b/camera/camera-camera2-pipe-integration/src/androidTest/java/androidx/camera/camera2/pipe/integration/EvCompDeviceTest.kt
@@ -258,7 +258,9 @@
ImageAnalysis.Builder().build().apply {
// set analyzer to make it active.
setAnalyzer(Dispatchers.Default.asExecutor()) {
- // Fake analyzer, do nothing.
+ // Fake analyzer, do nothing. Close the ImageProxy immediately to prevent the
+ // closing of the CameraDevice from being stuck.
+ it.close()
}
},
)
diff --git a/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/Camera2InteropIntegrationTest.kt b/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/Camera2InteropIntegrationTest.kt
index 812f339..c4eddbe 100644
--- a/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/Camera2InteropIntegrationTest.kt
+++ b/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/Camera2InteropIntegrationTest.kt
@@ -262,7 +262,9 @@
setAnalyzer(
CameraXExecutors.highPriorityExecutor()
) {
- // Analyzer nothing to to
+ // Fake analyzer, do nothing. Close the ImageProxy immediately to prevent the
+ // closing of the CameraDevice from being stuck.
+ it.close()
}
}